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:
-rw-r--r--source/blender/blenkernel/intern/brush.c13
-rw-r--r--source/blender/makesrna/intern/rna_brush.c15
2 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 98c540f53b7..25b60fef6dd 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1251,6 +1251,19 @@ static short unified_settings(Brush *brush)
return 0;
}
+// XXX: be careful about setting size and unprojected radius
+// because they depend on one another
+// these functions do not set the other corresponding value
+// this can lead to odd behavior if size and unprojected
+// radius become inconsistent.
+// the biggest problem is that it isn't possible to change
+// unprojected radius because a view context is not
+// available. my ussual solution to this is to use the
+// ratio of change of the size to change the unprojected
+// radius. Not completely convinced that is correct.
+// In anycase, a better solution is needed to prevent
+// inconsistency.
+
static void set_unified_size(Brush *brush, int value)
{
Scene *sce;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index a6e26583a6a..012d3fa675a 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
+#include <assert.h>
#include "RNA_define.h"
@@ -166,6 +167,13 @@ static void rna_Brush_icon_update(Main *bmain, Scene *scene, PointerRNA *ptr)
static void rna_Brush_set_size(PointerRNA *ptr, int value)
{
Brush* me = (Brush*)(ptr->data);
+
+ // set unprojected radius, so they remain consistent
+ double size= (double)brush_size(me);
+ assert(size != 0); // paranoia: sanity checks during load and rna make sure we don't divide by zero here
+ float unprojected_radius= (float)(brush_unprojected_radius(me) * (double)value / size);
+ brush_set_unprojected_radius(me, unprojected_radius);
+
brush_set_size(me, value);
}
@@ -214,6 +222,13 @@ static int rna_Brush_get_use_alpha_pressure(PointerRNA *ptr)
static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
{
Brush* me = (Brush*)(ptr->data);
+
+ // set size, so they remain consistent
+ double unprojected_radius= (double)brush_unprojected_radius(me);
+ assert(unprojected_radius != 0); // paranoia: sanity checks during load and rna make sure we don't divide by zero here
+ int size= (int)((double)brush_size(me) * (double)value / unprojected_radius);
+ brush_set_size(me, size);
+
brush_set_unprojected_radius(me, value);
}