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.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index ebcf8573ccd..0e3945bff15 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -20,6 +20,8 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLT_translation.h"
+
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
@@ -299,6 +301,10 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op)
bool changed = false;
if (RNA_boolean_get(op->ptr, "all")) {
+ if (RNA_boolean_get(op->ptr, "apply_mix")) {
+ float *arr = BKE_key_evaluate_object_ex(ob, NULL, NULL, 0, ob->data);
+ MEM_freeN(arr);
+ }
changed = BKE_object_shapekey_free(bmain, ob);
}
else {
@@ -315,6 +321,34 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+static bool shape_key_remove_poll_property(const bContext *UNUSED(C),
+ wmOperator *op,
+ const PropertyRNA *prop)
+{
+ const char *prop_id = RNA_property_identifier(prop);
+ const bool do_all = RNA_enum_get(op->ptr, "all");
+
+ /* Only show seed for randomize action! */
+ if (STREQ(prop_id, "apply_mix") && !do_all) {
+ return false;
+ }
+ return true;
+}
+
+static char *shape_key_remove_get_description(bContext *UNUSED(C),
+ wmOperatorType *UNUSED(ot),
+ PointerRNA *ptr)
+{
+ const bool do_apply_mix = RNA_boolean_get(ptr, "apply_mix");
+
+ if (do_apply_mix) {
+ return BLI_strdup(
+ TIP_("Apply current visible shape to the object data, and delete all shape keys"));
+ }
+
+ return NULL;
+}
+
void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
{
/* identifiers */
@@ -325,12 +359,19 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
/* api callbacks */
ot->poll = shape_key_mode_exists_poll;
ot->exec = shape_key_remove_exec;
+ ot->poll_property = shape_key_remove_poll_property;
+ ot->get_description = shape_key_remove_get_description;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- RNA_def_boolean(ot->srna, "all", 0, "All", "Remove all shape keys");
+ RNA_def_boolean(ot->srna, "all", false, "All", "Remove all shape keys");
+ RNA_def_boolean(ot->srna,
+ "apply_mix",
+ false,
+ "Apply Mix",
+ "Apply current mix of shape keys to the geometry before removing them");
}
/** \} */