* 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. 10
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/PaintTerrainToolAction.java

@ -102,7 +102,7 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
} }
public Vector2f getPointPercentagePosition(Terrain terrain, Vector3f worldLoc) { 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; float scale = ((Node)terrain).getLocalScale().x;
uv.subtractLocal(((Node)terrain).getLocalTranslation().x*scale, ((Node)terrain).getLocalTranslation().z*scale); // center it on 0,0 uv.subtractLocal(((Node)terrain).getLocalTranslation().x*scale, ((Node)terrain).getLocalTranslation().z*scale); // center it on 0,0
@ -157,10 +157,10 @@ public class PaintTerrainToolAction extends AbstractTerrainToolAction {
float width = image.getWidth(); float width = image.getWidth();
float height = image.getHeight(); float height = image.getHeight();
int minx = (int) (uv.x*width - radius*width); // convert percents to pixels to limit how much we iterate int minx = (int) Math.max(0, (uv.x*width - radius*width)); // convert percents to pixels to limit how much we iterate
int maxx = (int) (uv.x*width + radius*width); int maxx = (int) Math.min(width,(uv.x*width + radius*width));
int miny = (int) (uv.y*height - radius*height); int miny = (int) Math.max(0,(uv.y*height - radius*height));
int maxy = (int) (uv.y*height + radius*height); int maxy = (int) Math.min(height,(uv.y*height + radius*height));
float radiusSquared = radius*radius; float radiusSquared = radius*radius;
float radiusFalloff = radius*fadeFalloff; float radiusFalloff = radius*fadeFalloff;

Loading…
Cancel
Save