Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c19
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h2
4 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 5a4fda033d8..e9e1615b27d 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -515,10 +515,10 @@ BlurKernel *paint_new_blur_kernel(Brush *br)
{
int i, j;
BlurKernel *kernel = MEM_mallocN(sizeof(BlurKernel), "blur kernel");
- float pixel_len = br->blur_kernel_radius / 2.0f;
+ int pixel_len = br->blur_kernel_radius;
BlurKernelType type = br->blur_mode;
- kernel->side = br->blur_kernel_radius + 1;
+ kernel->side = pixel_len * 2 + 1;
kernel->side_squared = kernel->side * kernel->side;
kernel->wdata = MEM_mallocN(sizeof(float) * kernel->side_squared, "blur kernel data");
kernel->pixel_len = pixel_len;
@@ -531,19 +531,26 @@ BlurKernel *paint_new_blur_kernel(Brush *br)
case KERNEL_GAUSSIAN:
{
- float standard_dev = pixel_len / 3.0f; /* at standard deviation of 3.0 kernel is at about zero */
+ float standard_dev = pixel_len / 3.0; /* at standard deviation of 3.0 kernel is at about zero */
+ int i_term = pixel_len + 1;
/* make the necessary adjustment to the value for use in the normal distribution formula */
standard_dev = standard_dev * standard_dev * 2;
- for (i = 0; i < kernel->side; i++) {
- for (j = 0; j < kernel->side; j++) {
+ kernel->wdata[pixel_len + pixel_len * kernel->side] = 1.0;
+ /* fill in all four quadrants at once */
+ for (i = 0; i < i_term; i++) {
+ for (j = 0; j < pixel_len; j++) {
float idist = pixel_len - i;
float jdist = pixel_len - j;
float value = exp((idist * idist + jdist * jdist) / standard_dev);
- kernel->wdata[i + j * kernel->side] = value;
+ kernel->wdata[i + j * kernel->side] =
+ kernel->wdata[(kernel->side - j - 1) + i * kernel->side] =
+ kernel->wdata[(kernel->side - i - 1) + (kernel->side - j - 1) * kernel->side] =
+ kernel->wdata[j + (kernel->side - i - 1) * kernel->side] =
+ value;
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 14429eb8aca..1cba8a2cf23 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -877,10 +877,8 @@ static void paint_2d_lift_soften(ImagePaintState *s, ImBuf *ibuf, ImBuf *ibufb,
for (yk = 0; yk < kernel->side; yk++) {
for (xk = 0; xk < kernel->side; xk++) {
- float x_offs = xk - kernel->pixel_len;
- float y_offs = yk - kernel->pixel_len;
- count += paint_2d_ibuf_add_if(ibuf, xi + signf(x_offs) * fabs(x_offs + 0.51f),
- yi + signf(y_offs) * fabs(y_offs + 0.51f), outrgb, is_torus,
+ count += paint_2d_ibuf_add_if(ibuf, xi + xk - kernel->pixel_len,
+ yi + yk - kernel->pixel_len, outrgb, is_torus,
kernel->wdata[xk + yk * kernel->side]);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 72c226f825b..4b381c90119 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3763,9 +3763,7 @@ static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, f
for (yk = 0; yk < kernel->side; yk++) {
for (xk = 0; xk < kernel->side; xk++) {
float rgba_tmp[4];
- float x_offs = xk - kernel->pixel_len;
- float y_offs = yk - kernel->pixel_len;
- float co_ofs[2] = {x_offs, y_offs};
+ float co_ofs[2] = {xk - kernel->pixel_len, yk - kernel->pixel_len};
add_v2_v2(co_ofs, projPixel->projCoSS);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 8d42bbb7800..d0cd59d7be6 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -288,7 +288,7 @@ typedef struct {
float *wdata; /* actual kernel */
int side; /* kernel side */
int side_squared; /* data side */
- float pixel_len; /* pixels around center that kernel is wide */
+ int pixel_len; /* pixels around center that kernel is wide */
} BlurKernel;
enum BlurKernelType;