Image Paint: Support single pixel drawing
With !142495, the minimum brush radius became 0.5px, so clamp to that instead of 1px to allow drawing single pixels. Also change how drawing with anti-aliasing disabled works to avoid 1 pixel brush strokes not always appearing. Now when AA is disabled, snap the cursor to either the corners or centers of the pixels, depending on if the diameter is even or odd, respectively. Fixes #71403 Pull Request: https://projects.blender.org/blender/blender/pulls/146384
This commit is contained in:
@@ -54,7 +54,7 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache,
|
||||
{
|
||||
BLI_assert(curve_mask_cache->curve_mask != nullptr);
|
||||
int offset = int(floorf(diameter / 2.0f));
|
||||
int clamped_radius = max_ff(radius, 1.0);
|
||||
float clamped_radius = max_ff(radius, 0.5f);
|
||||
|
||||
ushort *m = curve_mask_cache->curve_mask;
|
||||
|
||||
@@ -68,6 +68,20 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache,
|
||||
|
||||
float weight_factor = 65535.0f / float(aa_samples * aa_samples);
|
||||
|
||||
if (aa_samples == 1) {
|
||||
/* When AA is disabled, snap the cursor to either the corners or centers of the pixels,
|
||||
* depending on if the diameter is even or odd, respectively.*/
|
||||
|
||||
if (int(clamped_radius * 2) % 2 == 0) {
|
||||
bpos[0] = roundf(bpos[0]);
|
||||
bpos[1] = roundf(bpos[1]);
|
||||
}
|
||||
else {
|
||||
bpos[0] = floorf(bpos[0]) + 0.5f;
|
||||
bpos[1] = floorf(bpos[1]) + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < diameter; y++) {
|
||||
for (int x = 0; x < diameter; x++, m++) {
|
||||
float pixel_xy[2];
|
||||
|
||||
Reference in New Issue
Block a user