getMesh().setBuffer(Type.Position, 3, newVertexBuffer);\r
}\r
\r
- public void adjustHeight(float x, float z, float delta) {\r
- if (x < 0 || z < 0 || x >= size || z >= size)\r
- return;\r
- int idx = (int) (z * size + x);\r
- float h = getMesh().getFloatBuffer(Type.Position).get(idx*3+1);\r
- \r
- geomap.getHeightData().put(idx, h+delta);\r
-\r
- FloatBuffer newVertexBuffer = geomap.writeVertexArray(null, stepScale, false);\r
- getMesh().clearBuffer(Type.Position);\r
- getMesh().setBuffer(Type.Position, 3, newVertexBuffer);\r
- }\r
-\r
/**\r
* recalculate all of this normal vectors in this terrain patch\r
*/\r
\r
public float getHeightmapHeight(Vector2f xz) {\r
// offset\r
- int x = Math.round((xz.x / getLocalScale().x) + (float)totalSize / 2f);\r
- int z = Math.round((xz.y / getLocalScale().z) + (float)totalSize / 2f);\r
+ int halfSize = totalSize / 2;\r
+ int x = Math.round((xz.x / getLocalScale().x) + halfSize);\r
+ int z = Math.round((xz.y / getLocalScale().z) + halfSize);\r
\r
return getHeightmapHeight(x, z);\r
}\r