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/editors/sculpt_paint/paint_image.c
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/editors/sculpt_paint/paint_image.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c19
1 files changed, 6 insertions, 13 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;
}
}