diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-28 05:36:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-28 05:36:00 +0400 |
commit | 1e3f98c000619e5fffd737df6d32f72ed313a443 (patch) | |
tree | ee30f626a1699550eb06d9be1270494bfc6cff04 /source/blender/editors/sculpt_paint | |
parent | 71dbd39891ad8109a208f389e518a446b487ef34 (diff) |
remove unneeded inline lookups and fix error with wpaint_stroke_test_start returning OPERATOR_PASS_THROUGH rather then a boolean.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 73 |
2 files changed, 42 insertions, 32 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 9ebeb61a7bb..2f4115dcd94 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -416,6 +416,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) if (!stroke->stroke_started) { copy_v2_v2(stroke->last_mouse_position, sample_average.mouse); stroke->stroke_started = stroke->test_start(C, op, sample_average.mouse); + BLI_assert((stroke->stroke_started & ~1) == 0); /* 0/1 */ if (stroke->stroke_started) { stroke->smooth_stroke_cursor = diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index bc1d0cd2f69..0ad7d144496 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -372,31 +372,22 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) bDeformGroup *defgroup = BLI_findlink(&ob->defbase, vgroup_active); if (defgroup) { - bDeformGroup *curdef; int mirrdef; char name[MAXBONENAME]; flip_side_name(name, defgroup->name, FALSE); - - if (strcmp(name, defgroup->name) != 0) { - for (curdef = ob->defbase.first, mirrdef = 0; curdef; curdef = curdef->next, mirrdef++) { - if (!strcmp(curdef->name, name)) { - break; - } - } - - if (curdef == NULL) { - int olddef = ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ - curdef = ED_vgroup_add_name(ob, name); - ob->actdef = olddef; - } - - /* curdef should never be NULL unless this is - * a lamp and ED_vgroup_add_name fails */ - if (curdef) { - return mirrdef; + mirrdef = defgroup_name_index(ob, name); + if (mirrdef == -1) { + int olddef = ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ + if (ED_vgroup_add_name(ob, name)) { + mirrdef = BLI_countlist(&ob->defbase) - 1; } + ob->actdef = olddef; } + + /* curdef should never be NULL unless this is + * a lamp and ED_vgroup_add_name fails */ + return mirrdef; } return -1; @@ -2061,32 +2052,29 @@ struct WPaintData { int vgroup_mirror; DMCoNo *vertexcosnos; float wpimat[3][3]; - + /* variables for auto normalize */ const char *vgroup_validmap; /* stores if vgroups tie to deforming bones or not */ const char *lock_flags; int defbase_tot; }; -static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNUSED(mouse[2])) +/* ensure we have data on wpaint start, add if needed */ +static int wpaint_ensure_data(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - struct PaintStroke *stroke = op->customdata; - ToolSettings *ts = scene->toolsettings; - VPaint *wp = ts->wpaint; Object *ob = CTX_data_active_object(C); - struct WPaintData *wpd; - Mesh *me; + Mesh *me = BKE_mesh_from_object(ob); - float mat[4][4], imat[4][4]; - if (scene->obedit) { return FALSE; } - + me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; - + if (me == NULL || me->totpoly == 0) { + return FALSE; + } + /* if nothing was added yet, we make dverts and a vertex deform group */ if (!me->dvert) { ED_vgroup_data_create(&me->id); @@ -2125,6 +2113,25 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNU return FALSE; } + return TRUE; +} + +static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNUSED(mouse[2])) +{ + Scene *scene = CTX_data_scene(C); + struct PaintStroke *stroke = op->customdata; + ToolSettings *ts = scene->toolsettings; + VPaint *wp = ts->wpaint; + Object *ob = CTX_data_active_object(C); + Mesh *me = BKE_mesh_from_object(ob); + struct WPaintData *wpd; + + float mat[4][4], imat[4][4]; + + if (wpaint_ensure_data(C, op) == FALSE) { + return FALSE; + } + { /* check if we are attempting to paint onto a locked vertex group, * and other options disallow it from doing anything useful */ @@ -3208,7 +3215,9 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, wmEvent *event) { - int ret = WM_gesture_straightline_invoke(C, op, event); + int ret; + + ret = WM_gesture_straightline_invoke(C, op, event); if (ret & OPERATOR_RUNNING_MODAL) { struct ARegion *ar = CTX_wm_region(C); if (ar->regiontype == RGN_TYPE_WINDOW) { |