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:
authorGaia Clary <gaia.clary@machinimatrix.org>2013-06-27 02:29:31 +0400
committerGaia Clary <gaia.clary@machinimatrix.org>2013-06-27 02:29:31 +0400
commitdc16faaaaf8803a6914095acbf602daf4cb9924b (patch)
tree6fc7d5b54acd2b4ead5b471ada1c2a6f88ed216b /source/blender/editors
parent15f5da4cd4bb2eed8e8c33e914d1c1c40e2af2c2 (diff)
Added checks to vertex Weight editor to respect locked Vertex Groups
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/object/object_vgroup.c38
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c30
2 files changed, 52 insertions, 16 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 7144ef07e74..df043820000 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -4101,11 +4101,33 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
}
}
+static bool check_vertex_group_accessible(wmOperator *op, Object *ob, int def_nr)
+{
+ bDeformGroup *dg = BLI_findlink(&ob->defbase, def_nr);
+
+ if (!dg) {
+ BKE_report(op->reports, RPT_ERROR, "Invalid Weight Group Index");
+ return true;
+ }
+
+ if (dg->flag & DG_LOCK_WEIGHT) {
+ BKE_report(op->reports, RPT_ERROR, "Weight Group is locked");
+ return true;
+ }
+
+ return false;
+}
+
static int vertex_weight_paste(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- const int wg_index = RNA_int_get(op->ptr, "weight_group");
- vgroup_copy_active_to_sel_single(ob, wg_index);
+ const int def_nr = RNA_int_get(op->ptr, "weight_group");
+ if (!check_vertex_group_accessible(op, ob, def_nr)) {
+ return OPERATOR_CANCELLED;
+ }
+
+
+ vgroup_copy_active_to_sel_single(ob, def_nr);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -4119,7 +4141,7 @@ void OBJECT_OT_vertex_weight_paste(wmOperatorType *ot)
ot->name = "Paste weight to Selected";
ot->idname = "OBJECT_OT_vertex_weight_paste";
- ot->description = "Copy this group's weight to other selected verts";
+ ot->description = "Copy this group's weight to other selected verts (disabled if vertex Group is locked)";
prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
"Index of source weight in active Weight Group", -1, INT_MAX);
@@ -4136,8 +4158,12 @@ void OBJECT_OT_vertex_weight_paste(wmOperatorType *ot)
static int vertex_weight_delete(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- const int wg_index = RNA_int_get(op->ptr, "weight_group");
- vgroup_remove_weight(ob, wg_index);
+ const int def_nr = RNA_int_get(op->ptr, "weight_group");
+ if (check_vertex_group_accessible(op, ob, def_nr)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ vgroup_remove_weight(ob, def_nr);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -4151,7 +4177,7 @@ void OBJECT_OT_vertex_weight_delete(wmOperatorType *ot)
ot->name = "Delete Weight";
ot->idname = "OBJECT_OT_vertex_weight_delete";
- ot->description = "Delete this weight from the vertex";
+ ot->description = "Delete this weight from the vertex (disabled if vertex Group is locked)";
prop = RNA_def_int(ot->srna, "weight_group", -1, -1, INT_MAX, "Weight Index",
"Index of source weight in active Weight Group", -1, INT_MAX);
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index 860807946a0..daed039ee28 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -839,13 +839,13 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
const bool *vgroup_validmap;
eVGroupSelect subset_type = ts->vgroupsubset;
int yco = 0;
- int locked = 0;
+ int lock_count = 0;
uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL);
bcol = uiLayoutColumn(pa->layout, true);
row = uiLayoutRow(bcol, true); /* The filter button row */
-
+
RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr);
uiItemR(row, &tools_ptr, "vertex_group_subset", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -853,11 +853,14 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count);
for (i = 0, dg = ob->defbase.first; dg; i++, dg = dg->next) {
+ bool locked = dg->flag & DG_LOCK_WEIGHT;
if (vgroup_validmap[i]) {
MDeformWeight *dw = defvert_find_index(dv, i);
if (dw) {
int x, xco = 0;
- row = uiLayoutRow(col, true);
+ int icon;
+ uiLayout *split = uiLayoutSplit(col, 0.45, true);
+ row = uiLayoutRow(split, true);
/* The Weight Group Name */
@@ -872,15 +875,17 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
}
xco += x;
+ row = uiLayoutRow(split, true);
+ uiLayoutSetEnabled(row, !locked);
+
/* The weight group value */
/* To be reworked still */
but = uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + i, "",
xco, yco, (x = UI_UNIT_X * 4), UI_UNIT_Y,
&dw->weight, 0.0, 1.0, 1, 3, "");
uiButSetFlag(but, UI_TEXT_LEFT);
- if (dg->flag & DG_LOCK_WEIGHT) {
- uiButSetFlag(but, UI_BUT_DISABLED);
- locked++;
+ if (locked) {
+ lock_count++;
}
xco += x;
@@ -889,14 +894,16 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
ot = ot_weight_paste;
WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_int_set(&op_ptr, "weight_group", i);
- uiItemFullO_ptr(row, ot, "", ICON_PASTEDOWN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ icon = (locked) ? ICON_BLANK1:ICON_PASTEDOWN;
+ uiItemFullO_ptr(row, ot, "", icon, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
/* The weight entry delete function */
ot = ot_weight_delete;
WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_int_set(&op_ptr, "weight_group", i);
- uiItemFullO_ptr(row, ot, "", ICON_X, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ icon = (locked) ? ICON_LOCKED:ICON_X;
+ uiItemFullO_ptr(row, ot, "", icon, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
yco -= UI_UNIT_Y;
@@ -914,14 +921,17 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Normalize",
0, yco, UI_UNIT_X * 5, UI_UNIT_Y,
TIP_("Normalize weights of active vertex (if affected groups are unlocked"));
- if (locked) {
+ if (lock_count) {
uiButSetFlag(but, UI_BUT_DISABLED);
}
ot = WM_operatortype_find("OBJECT_OT_vertex_weight_copy", 1);
but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Copy",
UI_UNIT_X * 5, yco, UI_UNIT_X * 5, UI_UNIT_Y,
- TIP_("Copy active vertex to other selected verts"));
+ TIP_("Copy active vertex to other selected verts (if affected groups are unlocked)"));
+ if (lock_count) {
+ uiButSetFlag(but, UI_BUT_DISABLED);
+ }
}
}