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>2013-12-10 00:36:33 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-12-10 00:40:02 +0400
commitf0675b14d84392e65c9e746752defa707335626c (patch)
tree063c281b5b063d506d9a46bb1970e69f33975470 /source/blender/editors/sculpt_paint
parentec30d711ccfc28be494580df38d4fce9c0a00875 (diff)
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.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c20
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c20
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c20
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c25
6 files changed, 44 insertions, 55 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 56143d00afe..2dc6babdfa6 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 6ffa54c5569..47ca3e5ce0c 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 9b906c460e3..c421080956b 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 397baeae4c9..0c28081723f 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 cursor display */
+ if (!(stroke->brush->flag & BRUSH_RAKE))
+ ups->brush_rotation = 0.0f;
if (stroke->stroke_started) {
if (stroke->redraw)
@@ -556,7 +568,7 @@ bool paint_supports_smooth_stroke(Brush *br, PaintMode mode)
{
if (!(br->flag & BRUSH_SMOOTH_STROKE) ||
(br->flag & BRUSH_ANCHORED) ||
- (br->flag & BRUSH_RESTORE_MESH))
+ (br->flag & BRUSH_DRAG_DOT))
{
return false;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 7d62ca0535d..9d7bad2591e 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2255,11 +2255,6 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNU
if (me->editflag & ME_EDIT_MIRROR_X) {
wpd->vgroup_mirror = wpaint_mirror_vgroup_ensure(ob, wpd->vgroup_active);
}
-
- {
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->draw_pressure = true;
- }
return TRUE;
}
@@ -2553,11 +2548,6 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
}
}
- {
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->draw_pressure = false;
- }
-
DAG_id_tag_update(ob->data, 0);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2875,11 +2865,6 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
invert_m4_m4(imat, mat);
copy_m3_m4(vpd->vpimat, imat);
- {
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->draw_pressure = true;
- }
-
return 1;
}
@@ -3103,11 +3088,6 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
if (vpd->mfacetag)
MEM_freeN(vpd->mfacetag);
- {
- UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->draw_pressure = false;
- }
-
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
MEM_freeN(vpd);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 33ba4f6fef0..b8a082398ef 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -418,7 +418,7 @@ static int sculpt_stroke_dynamic_topology(const SculptSession *ss,
/* Requires mesh restore, which doesn't work with
* dynamic-topology */
!(brush->flag & BRUSH_ANCHORED) &&
- !(brush->flag & BRUSH_RESTORE_MESH) &&
+ !(brush->flag & BRUSH_DRAG_DOT) &&
(!ELEM6(brush->sculpt_tool,
/* These brushes, as currently coded, cannot
@@ -762,15 +762,15 @@ static float integrate_overlap(Brush *br)
/* Uses symm to selectively flip any axis of a coordinate. */
static void flip_v3_v3(float out[3], const float in[3], 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];
@@ -820,7 +820,7 @@ static float calc_radial_symmetry_feather(Sculpt *sd, StrokeCache *cache, const
static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
{
- if (sd->flags & SCULPT_SYMMETRY_FEATHER) {
+ if (sd->paint.symmetry_flags & PAINT_SYMMETRY_FEATHER) {
float overlap;
int symm = cache->symmetry;
int i;
@@ -3467,7 +3467,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob,
Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- const char symm = sd->flags & 7;
+ const char symm = sd->paint.symmetry_flags & 7;
int i;
float feather = calc_symmetry_feather(sd, ss->cache);
@@ -4015,7 +4015,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
/* location stays the same for finding vertices in brush radius */
copy_v3_v3(cache->true_location, cache->orig_grab_location);
- ups->draw_anchored = 1;
+ ups->draw_anchored = true;
copy_v2_v2(ups->anchored_initial_mouse, cache->initial_mouse);
ups->anchored_size = ups->pixel_radius;
}
@@ -4142,7 +4142,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
#undef PIXEL_INPUT_THRESHHOLD
}
- ups->draw_anchored = 1;
+ ups->draw_anchored = true;
copy_v2_v2(ups->anchored_initial_mouse, cache->initial_mouse);
copy_v3_v3(cache->anchored_location, cache->true_location);
ups->anchored_size = ups->pixel_radius;
@@ -4314,7 +4314,7 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
if ((brush->flag & BRUSH_ANCHORED) ||
(brush->sculpt_tool == SCULPT_TOOL_GRAB &&
BKE_brush_use_size_pressure(ss->cache->vc->scene, brush)) ||
- (brush->flag & BRUSH_RESTORE_MESH))
+ (brush->flag & BRUSH_DRAG_DOT))
{
paint_mesh_restore_co(sd, ob);
}
@@ -4456,7 +4456,6 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
{
- UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
SculptSession *ss = ob->sculpt;
@@ -4464,10 +4463,6 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
sculpt_omp_done(ss);
- /* reset values used to draw brush after completing the stroke */
- ups->draw_anchored = 0;
- ups->draw_pressure = 0;
-
/* Finished */
if (ss->cache) {
Brush *brush = BKE_paint_brush(&sd->paint);
@@ -5068,7 +5063,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data");
/* Turn on X plane mirror symmetry by default */
- ts->sculpt->flags |= SCULPT_SYMM_X;
+ ts->sculpt->paint.symmetry_flags |= PAINT_SYMM_X;
/* Make sure at least dyntopo subdivision is enabled */
ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE;