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:
Diffstat (limited to 'source/blender/editors/object/object_shapekey.c')
-rw-r--r--source/blender/editors/object/object_shapekey.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 7b1ab933e28..d8e54a73500 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -38,6 +38,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_utildefines.h"
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
@@ -53,6 +54,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_object.h"
+#include "BKE_curve.h"
#include "BLO_sys_types.h" // for intptr_t support
@@ -100,8 +102,25 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
BLI_remlink(&key->block, kb);
key->totkey--;
- if(key->refkey== kb)
+ if(key->refkey== kb) {
key->refkey= key->block.first;
+
+ if(key->refkey) {
+ /* apply new basis key on original data */
+ switch(ob->type) {
+ case OB_MESH:
+ key_to_mesh(key->refkey, ob->data);
+ break;
+ case OB_CURVE:
+ case OB_SURF:
+ key_to_curve(key->refkey, ob->data, BKE_curve_nurbs(ob->data));
+ break;
+ case OB_LATTICE:
+ key_to_latt(key->refkey, ob->data);
+ break;
+ }
+ }
+ }
if(kb->data) MEM_freeN(kb->data);
MEM_freeN(kb);
@@ -137,13 +156,13 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
free_libblock_us(&(bmain->key), key);
}
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return 1;
}
-static int ED_object_shape_key_mirror(bContext *C, Scene *scene, Object *ob)
+static int object_shape_key_mirror(bContext *C, Object *ob)
{
KeyBlock *kb;
Key *key;
@@ -198,7 +217,7 @@ static int ED_object_shape_key_mirror(bContext *C, Scene *scene, Object *ob)
MEM_freeN(tag_elem);
}
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return 1;
@@ -235,8 +254,8 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Shape Key";
- ot->name= "Add shape key to the object.";
ot->idname= "OBJECT_OT_shape_key_add";
+ ot->description= "Add shape key to the object";
/* api callbacks */
ot->poll= shape_key_mode_poll;
@@ -249,7 +268,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "from_mix", 1, "From Mix", "Create the new shape key from the existing mix of keys.");
}
-static int shape_key_remove_exec(bContext *C, wmOperator *op)
+static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
@@ -263,8 +282,8 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Remove Shape Key";
- ot->name= "Remove shape key from the object.";
ot->idname= "OBJECT_OT_shape_key_remove";
+ ot->description= "Remove shape key from the object";
/* api callbacks */
ot->poll= shape_key_mode_poll;
@@ -274,7 +293,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int shape_key_clear_exec(bContext *C, wmOperator *op)
+static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Key *key= ob_get_key(ob);
@@ -286,7 +305,7 @@ static int shape_key_clear_exec(bContext *C, wmOperator *op)
for(kb=key->block.first; kb; kb=kb->next)
kb->curval= 0.0f;
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
@@ -307,12 +326,11 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int shape_key_mirror_exec(bContext *C, wmOperator *op)
+static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
- if(!ED_object_shape_key_mirror(C, scene, ob))
+ if(!object_shape_key_mirror(C, ob))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -375,7 +393,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op)
}
}
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;