Hey,
It seems to me that the getHeight and setHeight methods aren’t consistent with each other.
When you call getHeight the vec2 given is translated by the world transform but the vec2 in setHeight isn’t.
Is there any reason for this?
Looking at the source: getHeight(vec2):
public float getHeight(Vector2f xz) {
// offset
float x = (float)(((xz.x - getWorldTranslation().x) / getWorldScale().x) + (float)(totalSize-1) / 2f);
float z = (float)(((xz.y - getWorldTranslation().z) / getWorldScale().z) + (float)(totalSize-1) / 2f);
if (!isInside((int)x, (int)z))
return Float.NaN;
float height = getHeight((int)x, (int)z, (x%1f), (z%1f));
height *= getWorldScale().y;
return height;
}
and setHeight(Vec2, f) calls:
public void setHeight(Vector2f xz, float height) {
...
protected void setHeight(List<Vector2f> xz, List<Float> height, boolean overrideHeight) {
...
// offset
for (int i=0; i<xz.size(); i++) {
int x = Math.round((xz.get(i).x / getWorldScale().x) + halfSize);
int z = Math.round((xz.get(i).y / getWorldScale().z) + halfSize);
if (!isInside(x, z))
continue;
locations.add(new LocationHeight(x,z,height.get(i)));
}
setHeight(locations, overrideHeight); // adjust height of the actual mesh
...