tweaks to getHeightmapHeight, removed old code

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7648 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 14 years ago
parent f02c21a51f
commit 4148e216b4
  1. 13
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java
  2. 5
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java

@ -327,19 +327,6 @@ public class TerrainPatch extends Geometry {
getMesh().setBuffer(Type.Position, 3, newVertexBuffer); getMesh().setBuffer(Type.Position, 3, newVertexBuffer);
} }
public void adjustHeight(float x, float z, float delta) {
if (x < 0 || z < 0 || x >= size || z >= size)
return;
int idx = (int) (z * size + x);
float h = getMesh().getFloatBuffer(Type.Position).get(idx*3+1);
geomap.getHeightData().put(idx, h+delta);
FloatBuffer newVertexBuffer = geomap.writeVertexArray(null, stepScale, false);
getMesh().clearBuffer(Type.Position);
getMesh().setBuffer(Type.Position, 3, newVertexBuffer);
}
/** /**
* recalculate all of this normal vectors in this terrain patch * recalculate all of this normal vectors in this terrain patch
*/ */

@ -860,8 +860,9 @@ public class TerrainQuad extends Node implements Terrain {
public float getHeightmapHeight(Vector2f xz) { public float getHeightmapHeight(Vector2f xz) {
// offset // offset
int x = Math.round((xz.x / getLocalScale().x) + (float)totalSize / 2f); int halfSize = totalSize / 2;
int z = Math.round((xz.y / getLocalScale().z) + (float)totalSize / 2f); int x = Math.round((xz.x / getLocalScale().x) + halfSize);
int z = Math.round((xz.y / getLocalScale().z) + halfSize);
return getHeightmapHeight(x, z); return getHeightmapHeight(x, z);
} }

Loading…
Cancel
Save