* terrain paint tool will no longer wrap; bug fix thanks to pitoui

* flipped paint coords to match flipped terrain coords in last commit

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8062 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent 55a53de90e
commit 82a405f067
  1. 12
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/PaintTerrainToolAction.java

@ -102,14 +102,14 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
}
public Vector2f getPointPercentagePosition(Terrain terrain, Vector3f worldLoc) {
Vector2f uv = new Vector2f(worldLoc.x,worldLoc.z);
Vector2f uv = new Vector2f(worldLoc.x,-worldLoc.z);
float scale = ((Node)terrain).getLocalScale().x;
uv.subtractLocal(((Node)terrain).getLocalTranslation().x*scale, ((Node)terrain).getLocalTranslation().z*scale); // center it on 0,0
float scaledSize = terrain.getTerrainSize()*scale;
uv.addLocal(scaledSize/2, scaledSize/2); // shift the bottom left corner up to 0,0
uv.divideLocal(scaledSize); // get the location as a percentage
return uv;
}
@ -157,10 +157,10 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
float width = image.getWidth();
float height = image.getHeight();
int minx = (int) (uv.x*width - radius*width); // convert percents to pixels to limit how much we iterate
int maxx = (int) (uv.x*width + radius*width);
int miny = (int) (uv.y*height - radius*height);
int maxy = (int) (uv.y*height + radius*height);
int minx = (int) Math.max(0, (uv.x*width - radius*width)); // convert percents to pixels to limit how much we iterate
int maxx = (int) Math.min(width,(uv.x*width + radius*width));
int miny = (int) Math.max(0,(uv.y*height - radius*height));
int maxy = (int) Math.min(height,(uv.y*height + radius*height));
float radiusSquared = radius*radius;
float radiusFalloff = radius*fadeFalloff;

Loading…
Cancel
Save