diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-03-30 14:48:58 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-03-30 15:32:51 (GMT) |
| commit | 57aa7b88f1cab19c091c6c700035812731052089 (patch) | |
| tree | 821e08d9fd23eabbd4b56bd04484399a9eacfecb /src | |
| parent | a7e5f3651afd1f1577fdd00c3971f53fac1543ed (diff) | |
| download | powder-57aa7b88f1cab19c091c6c700035812731052089.zip powder-57aa7b88f1cab19c091c6c700035812731052089.tar.gz | |
More brush fixes
Fixes a problem with the triangle brush caused by InCurrentBrush
calculating the bottom left or bottom right points to be outside the
triangle at certain brush sizes.
Also fixes some points in the brush outline being heated twice when a
line is drawn with the heat tool.
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 4 | ||||
| -rw-r--r-- | src/powder.c | 14 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/graphics.c b/src/graphics.c index 00e4466..8f4a8de 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3706,9 +3706,11 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) { int tempy = y, i, j, oldy; if (CURRENT_BRUSH == TRI_BRUSH) - tempy = y + ry - 1; + tempy = y + ry; for (i = x - rx; i <= x; i++) { oldy = tempy; + if (!InCurrentBrush(i-x,tempy-y,rx,ry)) + continue; while (InCurrentBrush(i-x,tempy-y,rx,ry)) tempy = tempy - 1; tempy = tempy + 1; diff --git a/src/powder.c b/src/powder.c index e9ae42b..67a16f8 100644 --- a/src/powder.c +++ b/src/powder.c @@ -3081,10 +3081,15 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags, int fill) else { int tempy = y, i, j, jmax, oldy; + // tempy is the smallest y value that is still inside the brush + // jmax is the largest y value that is still inside the brush if (CURRENT_BRUSH == TRI_BRUSH) tempy = y + ry; for (i = x - rx; i <= x; i++) { oldy = tempy; + // Fix a problem with the triangle brush which occurs if the bottom corner (the first point tested) isn't recognised as being inside the brush + if (!InCurrentBrush(i-x,tempy-y,rx,ry)) + continue; while (InCurrentBrush(i-x,tempy-y,rx,ry)) tempy = tempy - 1; tempy = tempy + 1; @@ -3112,11 +3117,11 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags, int fill) j2 = y+ry; if (create_parts2(fn,i,j,c,rx,ry,flags)) f = 1; - if (create_parts2(fn,i2,j,c,rx,ry,flags)) + if (i2 != i && create_parts2(fn,i2,j,c,rx,ry,flags)) f = 1; - if (create_parts2(fn,i,j2,c,rx,ry,flags)) + if (j2 != j && create_parts2(fn,i,j2,c,rx,ry,flags)) f = 1; - if (create_parts2(fn,i2,j2,c,rx,ry,flags)) + if (i2 != i && j2 != j && create_parts2(fn,i2,j2,c,rx,ry,flags)) f = 1; } } @@ -3161,7 +3166,8 @@ int InCurrentBrush(int i, int j, int rx, int ry) return (abs(i) <= rx && abs(j) <= ry); break; case TRI_BRUSH: - return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ; + // -1e-9 because due to rounding errors, the corner at i=rx is not considered to be inside the brush at some brush sizes + return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i)-ry-1e-9) && ( j >= (((-2.0*ry)/(-rx))*i)-ry-1e-9) ; break; default: return 0; |
