Little fix for sdk class com.jme3.gde.terraineditor.tools.PaintTerrainToolAction

Hi,



While playing with it I noticed when you are close to the edge and applying texture painting, you end up painting other edge too

reason is min/max for pixel iteration in doPaintAction goes over limit of image size

like min < 0 or max > width or height



so I fixed it locally by changing the 4 line



[java] int minx = (int) (uv.xwidth - radiuswidth); // convert percents to pixels to limit how much we iterate

int maxx = (int) (uv.xwidth + radiuswidth);

int miny = (int) (uv.yheight - radiusheight);

int maxy = (int) (uv.yheight + radiusheight);[/java]



To



[java]int minx = (int) Math.max(0, (uv.xwidth - radiuswidth)); // convert percents to pixels to limit how much we iterate

int maxx = (int) Math.min(width,(uv.xwidth + radiuswidth));

int miny = (int) Math.max(0,(uv.yheight - radiusheight));

int maxy = (int) Math.min(height,(uv.yheight + radiusheight));[/java]



so stays within to image, and do not cuase undesired side effect when going over



Pitoui

1 Like

Excellent, thanks @pitoui !

I’ve been meaning to fix that but it keeps getting pushed aside.



I will try and get your fix in this weekend.

cheers

np at all, my pleasure

okay, I finally patched it.