[Bf-blender-cvs] [f838e36] soc-2014-shapekey: Merge branch 'master' into soc-2014-shapekey
Bastien Montagne
noreply at git.blender.org
Sun Aug 10 17:27:36 CEST 2014
Commit: f838e3632d6cdf5fcc11f4c3ed044afeafa6e23f
Author: Bastien Montagne
Date: Sun Aug 10 16:58:22 2014 +0200
Branches: soc-2014-shapekey
https://developer.blender.org/rBf838e3632d6cdf5fcc11f4c3ed044afeafa6e23f
Merge branch 'master' into soc-2014-shapekey
Conflicts:
source/blender/editors/object/object_shapekey.c
===================================================================
===================================================================
diff --cc source/blender/editors/mesh/editmesh_tools.c
index 27145cc,92bbd94..ddf7650
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@@ -3050,11 -2422,11 +3050,11 @@@ static int edbm_knife_cut_exec(bContex
/* allocd vars */
float (*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2];
-
+
/* edit-object needed for matrix, and ar->regiondata for projections to work */
- if (ELEM3(NULL, obedit, ar, ar->regiondata))
+ if (ELEM(NULL, obedit, ar, ar->regiondata))
return OPERATOR_CANCELLED;
-
+
if (bm->totvertsel < 2) {
BKE_report(op->reports, RPT_ERROR, "No edges are selected to operate on");
return OPERATOR_CANCELLED;
diff --cc source/blender/editors/object/object_shapekey.c
index be05091,9b6f6ad..d741991
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@@ -489,48 -482,88 +489,49 @@@ void OBJECT_OT_shape_key_mirror(wmOpera
}
-static int shape_key_move_exec(bContext *C, wmOperator *op)
+static int shape_key_move_poll(bContext *C)
{
Object *ob = ED_object_context(C);
+ ID *data = (ob) ? ob->data : NULL;
Key *key = BKE_key_from_object(ob);
- return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT && key && key->totkey);
- }
- if (!key) {
- return OPERATOR_CANCELLED;
- }
-
- {
- KeyBlock *kb, *kb_other, *kb_iter;
- const int type = RNA_enum_get(op->ptr, "type");
- const int shape_tot = BLI_countlist(&key->block);
- const int shapenr_act = ob->shapenr - 1;
- const int shapenr_swap = (shape_tot + shapenr_act + type) % shape_tot;
-
- kb = BLI_findlink(&key->block, shapenr_act);
- if (!kb || shape_tot == 1) {
- return OPERATOR_CANCELLED;
- }
-
- if (type == -1) {
- /* move back */
- kb_other = kb->prev;
- BLI_remlink(&key->block, kb);
- BLI_insertlinkbefore(&key->block, kb_other, kb);
- }
- else {
- /* move next */
- kb_other = kb->next;
- BLI_remlink(&key->block, kb);
- BLI_insertlinkafter(&key->block, kb_other, kb);
- }
++ return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT && key && key->totkey > 1);
++}
- ob->shapenr = shapenr_swap + 1;
+static EnumPropertyItem slot_move[] = {
+ { -2, "TOP", 0, "Top of the list", "" },
+ { -1, "UP", 0, "Up", "" },
+ { 1, "DOWN", 0, "Down", "" },
+ { 2, "BOTTOM", 0, "Bottom of the list", "" },
+ { 0, NULL, 0, NULL, NULL }
+};
- /* for relative shape keys */
- if (kb_other) {
- for (kb_iter = key->block.first; kb_iter; kb_iter = kb_iter->next) {
- if (kb_iter->relative == shapenr_act) {
- kb_iter->relative = shapenr_swap;
- }
- else if (kb_iter->relative == shapenr_swap) {
- kb_iter->relative = shapenr_act;
- }
- }
- }
- /* First key became last, or vice-versa, we have to change all keys' relative value. */
- else {
- for (kb_iter = key->block.first; kb_iter; kb_iter = kb_iter->next) {
- if (kb_iter->relative == shapenr_act) {
- kb_iter->relative = shapenr_swap;
- }
- else {
- kb_iter->relative += type;
- }
- }
- }
+static int shape_key_move_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = ED_object_context(C);
- int type = RNA_enum_get(op->ptr, "type");
- int act_index = ob->shapenr - 1;
- int new_index = act_index;
- /* for absolute shape keys */
- if (kb_other) {
- SWAP(float, kb_other->pos, kb->pos);
- }
- /* First key became last, or vice-versa, we have to change all keys' pos value. */
- else {
- float pos = kb->pos;
- if (type == -1) {
- for (kb_iter = key->block.first; kb_iter; kb_iter = kb_iter->next) {
- SWAP(float, kb_iter->pos, pos);
- }
- }
- else {
- for (kb_iter = key->block.last; kb_iter; kb_iter = kb_iter->prev) {
- SWAP(float, kb_iter->pos, pos);
- }
- }
- }
+ Key *key = BKE_key_from_object(ob);
+ KeyBlock *kb = BKE_keyblock_from_object(ob);
++ const int type = RNA_enum_get(op->ptr, "type");
++ const int totkey = key->totkey;
++ const int act_index = ob->shapenr - 1;
++ int new_index;
- if (type >= -1 && type <= 1) {
- new_index = act_index + type;
- }
- else if (type == 2) {
- new_index = key->totkey - 1;
- /* First key is refkey, matches interface and BKE_key_sort */
- key->refkey = key->block.first;
++ if (type == 2) {
++ new_index = totkey - 1;
+ }
+ else if (type == -2) {
+ if (act_index == 1 || act_index == 0)
+ new_index = 0; /* replace the ref key only if we're at the top already */
+ else
+ new_index = 1;
+ }
++ else {
++ new_index = (totkey + act_index + type) % totkey;
+ }
+ BKE_keyblock_move(ob, kb, new_index);
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
More information about the Bf-blender-cvs
mailing list