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
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-08-12 21:45:57 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-08-12 21:45:57 +0400
commit7c7cb01aa5641414d9f0c39ab81df0f57205f362 (patch)
tree29731ff090dee60f90ea23ed19e6bcadea58ae6b /source/blender
parent561f375109c063663919e815b3c05c802e9428f8 (diff)
Fix part of T41406
Attempt to make soften brush faster by allowing non-symmetric kernels. Projective painting supports those naturally but for 2D painting there's a small hack to avoid shifting of the texture. Not totally correct but it works for now.
Diffstat (limited to 'source/blender')
-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, 14 insertions, 17 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index a556f22b8ec..85c76c24f35 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");
- int pixel_len = br->blur_kernel_radius;
+ float pixel_len = br->blur_kernel_radius / 2.0f;
BlurKernelType type = br->blur_mode;
- kernel->side = pixel_len * 2 + 1;
+ kernel->side = br->blur_kernel_radius + 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,26 +531,19 @@ BlurKernel *paint_new_blur_kernel(Brush *br)
case KERNEL_GAUSSIAN:
{
- float standard_dev = pixel_len / 3.0; /* at standard deviation of 3.0 kernel is at about zero */
- int i_term = pixel_len + 1;
+ float standard_dev = pixel_len / 3.0f; /* at standard deviation of 3.0 kernel is at about zero */
/* make the necessary adjustment to the value for use in the normal distribution formula */
standard_dev = standard_dev * standard_dev * 2;
- 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++) {
+ for (i = 0; i < kernel->side; i++) {
+ for (j = 0; j < kernel->side; 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] =
- 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;
+ kernel->wdata[i + j * 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 1cba8a2cf23..14429eb8aca 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -877,8 +877,10 @@ 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++) {
- count += paint_2d_ibuf_add_if(ibuf, xi + xk - kernel->pixel_len,
- yi + yk - kernel->pixel_len, outrgb, is_torus,
+ 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,
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 1bad0663611..ba6b6cacd73 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3763,7 +3763,9 @@ 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 co_ofs[2] = {xk - kernel->pixel_len, yk - kernel->pixel_len};
+ float x_offs = xk - kernel->pixel_len;
+ float y_offs = yk - kernel->pixel_len;
+ float co_ofs[2] = {x_offs, y_offs};
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 736e6d229b3..57285ad9bb6 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -287,7 +287,7 @@ typedef struct {
float *wdata; /* actual kernel */
int side; /* kernel side */
int side_squared; /* data side */
- int pixel_len; /* pixels around center that kernel is wide */
+ float pixel_len; /* pixels around center that kernel is wide */
} BlurKernel;
enum BlurKernelType;