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:
authorJulian Eisel <eiseljulian@gmail.com>2016-09-18 22:36:34 +0300
committerJulian Eisel <eiseljulian@gmail.com>2016-09-18 22:44:42 +0300
commit572bc1364ca9d978edf5aee991849dd4f8e56a52 (patch)
tree61e965068f2d6bc835ecb8bd0ffe29709c9f5c1d /source/blender/editors/object/object_vgroup.c
parent6c28d3bac26b22049768824bef6ae9d0e82bb71f (diff)
BLI_listbase: Add/use utility to move link (BLI_listbase_link_move)
We were calling BLI_remlink and then BLI_insertlinkbefore/after quite often. BLI_listbase_link_move simplifies code a bit and makes it easier to follow. It also returns if link position has changed which can be used to avoid unnecessary updates. Added it to a number of list reorder operators for now and made use of return value. Behavior shouldn't be changed. Also some minor cleanup.
Diffstat (limited to 'source/blender/editors/object/object_vgroup.c')
-rw-r--r--source/blender/editors/object/object_vgroup.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 3b7f518d36f..bd016b7fcfb 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -3633,7 +3633,8 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_context(C);
bDeformGroup *def;
char *name_array;
- int dir = RNA_enum_get(op->ptr, "direction"), ret;
+ int dir = RNA_enum_get(op->ptr, "direction");
+ int ret = OPERATOR_FINISHED;
def = BLI_findlink(&ob->defbase, ob->actdef - 1);
if (!def) {
@@ -3642,36 +3643,25 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
name_array = vgroup_init_remap(ob);
- if (dir == 1) { /*up*/
- void *prev = def->prev;
+ if (BLI_listbase_link_move(&ob->defbase, def, dir)) {
+ ret = vgroup_do_remap(ob, name_array, op);
- BLI_remlink(&ob->defbase, def);
- BLI_insertlinkbefore(&ob->defbase, prev, def);
- }
- else { /*down*/
- void *next = def->next;
-
- BLI_remlink(&ob->defbase, def);
- BLI_insertlinkafter(&ob->defbase, next, def);
+ if (ret != OPERATOR_CANCELLED) {
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
+ }
}
- ret = vgroup_do_remap(ob, name_array, op);
-
if (name_array) MEM_freeN(name_array);
- if (ret != OPERATOR_CANCELLED) {
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
- }
-
return ret;
}
void OBJECT_OT_vertex_group_move(wmOperatorType *ot)
{
static EnumPropertyItem vgroup_slot_move[] = {
- {1, "UP", 0, "Up", ""},
- {-1, "DOWN", 0, "Down", ""},
+ {-1, "UP", 0, "Up", ""},
+ {1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL}
};