[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36979] branches/soc-2010-jwilkins/source/ blender: Fix: The radial control would fail, in sculpt mode, to set size if object-space sizing was enabled.
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat May 28 14:43:47 CEST 2011
Revision: 36979
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36979
Author: jwilkins
Date: 2011-05-28 12:43:47 +0000 (Sat, 28 May 2011)
Log Message:
-----------
Fix: The radial control would fail, in sculpt mode, to set size if object-space sizing was enabled.
This was caused because a small part of sculpt's radial control code did not make it into the new version. The old code would set a new object-space size by scaling it proportional to how much the new screen-space size was changed.
The solution I implement here is to do the same scaling inside the RNA callbacks. This way, users of those properties do not have to worry about inconsistency.
I added a comment warning that brush_set_size, brush_set_unified_size, brush_unprojected_radius, and brush_set_unprojected_radius do not guarantee consistency because it is not always possible to precisely know what the new unprojected radius is in all contexts where you might set the size.
I would implement the consistency check at the lower level (in those listed functions) but at this time I think it needs to be looked at to make sure that won't cause problems. In addition, I am not sure that scaling by the ratio of change is strictly correct in all cases.
In any case, this at least fixes the immediate problem.
Modified Paths:
--------------
branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c 2011-05-28 12:33:53 UTC (rev 36978)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c 2011-05-28 12:43:47 UTC (rev 36979)
@@ -1274,6 +1274,19 @@
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(const Brush *brush, int value)
{
Scene *sce;
Modified: branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c 2011-05-28 12:33:53 UTC (rev 36978)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c 2011-05-28 12:43:47 UTC (rev 36979)
@@ -28,6 +28,7 @@
#include <stdlib.h>
+#include <assert.h>
#include "RNA_define.h"
@@ -180,6 +181,17 @@
static void rna_Brush_set_size(PointerRNA *ptr, int value)
{
Brush* me = (Brush*)(ptr->data);
+
+ float size= (float)brush_size(me);
+ float unprojected_radius;
+
+ // paranoia: previous checks should make sure we don't divide by zero
+ assert(size != 0);
+
+ // set unprojected radius, so it remains consistent with size
+ unprojected_radius= (float)(brush_unprojected_radius(me) * value / size);
+ brush_set_unprojected_radius(me, unprojected_radius);
+
brush_set_size(me, value);
}
@@ -228,6 +240,17 @@
static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
{
Brush* me = (Brush*)(ptr->data);
+
+ float unprojected_radius= brush_unprojected_radius(me);
+ int size;
+
+ // paranoia: previous checks should make sure we don't divide by zero
+ assert(unprojected_radius != 0.0f);
+
+ // set size, so that it is consistent with unprojected_radius
+ size= (int)((float)brush_size(me) * value / unprojected_radius);
+ brush_set_size(me, size);
+
brush_set_unprojected_radius(me, value);
}
More information about the Bf-blender-cvs
mailing list