[Bf-blender-cvs] [f0675b1] master: Refactoring/cleanup, borrowed from soc-2013-paint branch.
Antony Riakiotakis
noreply at git.blender.org
Mon Dec 9 21:45:18 CET 2013
Commit: f0675b14d84392e65c9e746752defa707335626c
Author: Antony Riakiotakis
Date: Mon Dec 9 22:36:33 2013 +0200
http://developer.blender.org/rBf0675b14d84392e65c9e746752defa707335626c
Refactoring/cleanup, borrowed from soc-2013-paint branch.
* Move symmetry options to the paint struct (where all paint systems can
make use of it)
* Rename draw_pressure to stroke_active. This is what is really checked
on those occasions that this is used. Also move turning on/off of this
option to the stroke level and avoid doing it on every stroke system.
* Rename BRUSH_RESTORE_MESH to BRUSH_DRAG_DOT. In image painting this
won't restore any mesh, so better have a name that is directly linked to
what the flag actually does.
===================================================================
M source/blender/blenkernel/BKE_blender.h
M source/blender/blenkernel/intern/brush.c
M source/blender/blenloader/intern/versioning_260.c
M source/blender/editors/sculpt_paint/paint_cursor.c
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_mask.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/makesdna/DNA_brush_types.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_brush.c
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index d1e9509..a240e79 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 269
-#define BLENDER_SUBVERSION 6
+#define BLENDER_SUBVERSION 7
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index de81ef1..8a59aab 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -307,7 +307,7 @@ void BKE_brush_debug_print_state(Brush *br)
BR_TEST_FLAG(BRUSH_ADAPTIVE_SPACE);
BR_TEST_FLAG(BRUSH_LOCK_SIZE);
BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE);
- BR_TEST_FLAG(BRUSH_RESTORE_MESH);
+ BR_TEST_FLAG(BRUSH_DRAG_DOT);
BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE);
BR_TEST_FLAG(BRUSH_RANDOM_ROTATION);
BR_TEST_FLAG(BRUSH_PLANE_TRIM);
@@ -910,7 +910,7 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2],
/* jitter-ed brush gives weird and unpredictable result for this
* kinds of stroke, so manually disable jitter usage (sergey) */
- use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH | BRUSH_ANCHORED)) == 0;
+ use_jitter &= (brush->flag & (BRUSH_DRAG_DOT | BRUSH_ANCHORED)) == 0;
if (use_jitter) {
float rand_pos[2];
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index e023e8e..5acf631 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -2625,4 +2625,24 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ if (!MAIN_VERSION_ATLEAST(main, 269, 7)) {
+ Scene *scene;
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
+ Sculpt *sd = scene->toolsettings->sculpt;
+
+ if (sd) {
+ int symmetry_flags = sd->flags & 7;
+
+ if (symmetry_flags & SCULPT_SYMM_X)
+ sd->paint.symmetry_flags |= PAINT_SYMM_X;
+ if (symmetry_flags & SCULPT_SYMM_Y)
+ sd->paint.symmetry_flags |= PAINT_SYMM_Y;
+ if (symmetry_flags & SCULPT_SYMM_Z)
+ sd->paint.symmetry_flags |= PAINT_SYMM_Z;
+ if (symmetry_flags & SCULPT_SYMMETRY_FEATHER)
+ sd->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER;
+ }
+ }
+ }
}
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 56143d0..2dc6bab 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -569,7 +569,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
glTranslatef(-0.5f, -0.5f, 0);
/* scale based on tablet pressure */
- if (primary && ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
+ if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
glTranslatef(0.5f, 0.5f, 0);
glScalef(1.0f / ups->pressure_value, 1.0f / ups->pressure_value, 1);
glTranslatef(-0.5f, -0.5f, 0);
@@ -694,7 +694,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
}
/* scale based on tablet pressure */
- if (ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
+ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
do_pop = true;
glPushMatrix();
glLoadIdentity();
@@ -788,7 +788,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon
projected_radius);
/* scale 3D brush radius by pressure */
- if (ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush))
+ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush))
unprojected_radius *= ups->pressure_value;
/* set cached value in either Brush or UnifiedPaintSettings */
@@ -828,11 +828,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
outline_col = brush->add_col;
final_radius = BKE_brush_size_get(scene, brush) * zoomx;
- if (brush->flag & BRUSH_RAKE)
- /* here, translation contains the mouse coordinates. */
- paint_calculate_rake_rotation(ups, translation);
- else if (!(brush->flag & BRUSH_ANCHORED))
- ups->brush_rotation = 0.0;
+ /* don't calculate rake angles while a stroke is active because the rake variables are global and
+ * we may get interference with the stroke itself. For line strokes, such interference is visible */
+ if (!ups->stroke_active) {
+ if (brush->flag & BRUSH_RAKE)
+ /* here, translation contains the mouse coordinates. */
+ paint_calculate_rake_rotation(ups, translation);
+ }
/* draw overlay */
paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode);
@@ -883,7 +885,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
glTranslatef(translation[0], translation[1], 0);
/* draw an inner brush */
- if (ups->draw_pressure && BKE_brush_use_size_pressure(scene, brush)) {
+ if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) {
/* inner at full alpha */
glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius * ups->pressure_value, 40);
/* outer at half alpha */
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 6ffa54c..47ca3e5 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -511,7 +511,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, float mou
{
UnifiedPaintSettings *ups = &settings->unified_paint_settings;
- ups->draw_pressure = true;
+ ups->stroke_active = true;
}
return pop;
@@ -595,7 +595,7 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- ups->draw_pressure = false;
+ ups->stroke_active = false;
}
}
@@ -766,7 +766,7 @@ void brush_drawcursor_texpaint_uvsculpt(bContext *C, int x, int y, void *UNUSED(
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
/* hrmf, duplicate paint_draw_cursor logic here */
- if (ups->draw_pressure && BKE_brush_use_size_pressure(scene, brush)) {
+ if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) {
/* inner at full alpha */
glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size * ups->pressure_value, 40);
/* outer at half alpha */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 9b906c4..c421080 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -165,15 +165,15 @@ static int is_effected(float planes[4][4], const float co[3])
static void flip_plane(float out[4], const float in[4], const char symm)
{
- if (symm & SCULPT_SYMM_X)
+ if (symm & PAINT_SYMM_X)
out[0] = -in[0];
else
out[0] = in[0];
- if (symm & SCULPT_SYMM_Y)
+ if (symm & PAINT_SYMM_Y)
out[1] = -in[1];
else
out[1] = in[1];
- if (symm & SCULPT_SYMM_Z)
+ if (symm & PAINT_SYMM_Z)
out[2] = -in[2];
else
out[2] = in[2];
@@ -198,7 +198,7 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU
PBVH *pbvh;
PBVHNode **nodes;
int totnode, i, symmpass;
- int symm = sd->flags & 7;
+ int symm = sd->paint.symmetry_flags & 7;
mode = PAINT_MASK_FLOOD_VALUE;
value = select ? 1.0 : 0.0;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 397baea..0c28081 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -76,6 +76,7 @@ typedef struct PaintStroke {
ViewContext vc;
bglMats mats;
Brush *brush;
+ UnifiedPaintSettings *ups;
/* Paint stroke can use up to PAINT_MAX_INPUT_SAMPLES prior inputs
* to smooth the stroke */
@@ -174,7 +175,7 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
/* Truly temporary data that isn't stored in properties */
- ups->draw_pressure = TRUE;
+ ups->stroke_active = true;
ups->pressure_value = stroke->cached_pressure;
ups->pixel_radius = BKE_brush_size_get(scene, brush);
@@ -247,7 +248,7 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
else
copy_v2_v2(ups->anchored_initial_mouse, stroke->initial_mouse);
- ups->draw_anchored = 1;
+ ups->draw_anchored = true;
}
else if (brush->flag & BRUSH_RAKE) {
if (!stroke->brush_init)
@@ -467,8 +468,10 @@ PaintStroke *paint_stroke_new(bContext *C,
StrokeDone done, int event_type)
{
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke");
-
+ ToolSettings *toolsettings = CTX_data_tool_settings(C);
+ UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
Brush *br = stroke->brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
+
view3d_set_viewcontext(C, &stroke->vc);
if (stroke->vc.v3d)
view3d_get_transformation(stroke->vc.ar, stroke->vc.rv3d, stroke->vc.obact, &stroke->mats);
@@ -479,6 +482,7 @@ PaintStroke *paint_stroke_new(bContext *C,
stroke->redraw = redraw;
stroke->done = done;
stroke->event_type = event_type; /* for modal, return event */
+ stroke->ups = ups;
/* initialize here to avoid initialization conflict with threaded strokes */
curvemapping_initialize(br->curve);
@@ -498,6 +502,14 @@ void paint_stroke_data_free(struct wmOperator *op)
static void stroke_done(struct bContext *C, struct wmOperator *op)
{
struct PaintStroke *stroke = op->customdata;
+ UnifiedPaintSettings *ups = stroke->ups;
+
+ ups->draw_anchored = false;
+ ups->stroke_active = false;
+
+ /* reset rotation here to avoid doing so in cur
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list