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:
authorDalai Felinto <dfelinto@gmail.com>2010-04-12 02:08:58 +0400
committerDalai Felinto <dfelinto@gmail.com>2010-04-12 02:08:58 +0400
commit139a0e7cb8a9003baa3d50d6d99d7f437b1d1899 (patch)
tree5cdc6d17feb66869a63d6963f22ac6f96bddab18
parent978609aa44659bbf4565ad413f5242654249fb22 (diff)
Copy Constraints Operator
the C code to copy the constraint was already there (same as 2.49) so this operator simply exposes it. I'm using the name Copy Constraints to Others based on what we have in material operators (e.g. Copy Material to Others). If we bring back the whole Copy Attributes menu (old Ctrl+C) having the individual operators is still important for scripts. Nevertheless I'm not comfortable with the name (to Others sounds unnecessary verbose) but so far having the functionality back is important (request from Caju Studio). I'll be glad to make any change later if needed. (no shortcut for that, to use it go to userpref->keymap and assign a shortcut for this operator or add it to the toolshelf)
-rw-r--r--source/blender/editors/object/object_constraint.c37
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_ops.c1
3 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 0db31b90365..90727cee53d 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1110,6 +1110,28 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
}
/* dummy operator callback */
+static int object_constraint_copy_exec(bContext *C, wmOperator *op)
+{
+ Object *ob=ED_object_active_context(C);
+
+ CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
+ if(ob != ob_iter) {
+ if (ob->data != ob_iter->data){
+ copy_constraints(&ob_iter->constraints, &ob->constraints);
+ }
+
+ if(ob_iter->totcol==ob->totcol) {
+ ob_iter->actcol= ob->actcol;
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter);
+ }
+ }
+ }
+ CTX_DATA_END;
+
+ return OPERATOR_FINISHED;
+}
+
+/* dummy operator callback */
static int pose_constraint_add_exec(bContext *C, wmOperator *op)
{
Object *ob= ED_object_active_context(C);
@@ -1170,6 +1192,21 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
}
+void OBJECT_OT_constraint_copy(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Copy Constraints to Others";
+ ot->description = "Copy constraints to other selected objects.";
+ ot->idname= "OBJECT_OT_constraint_copy";
+
+ /* api callbacks */
+ ot->exec= object_constraint_copy_exec;
+ ot->poll= ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
void POSE_OT_constraint_add(wmOperatorType *ot)
{
/* identifiers */
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 23f5d0c1475..6b43591479d 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -157,6 +157,7 @@ void OBJECT_OT_explode_refresh(struct wmOperatorType *ot);
/* object_constraint.c */
void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
void OBJECT_OT_constraint_add_with_targets(struct wmOperatorType *ot);
+void OBJECT_OT_constraint_copy(struct wmOperatorType *ot);
void POSE_OT_constraint_add(struct wmOperatorType *ot);
void POSE_OT_constraint_add_with_targets(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 2ff99bac1c5..082aa3db62b 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -143,6 +143,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_constraint_add);
WM_operatortype_append(OBJECT_OT_constraint_add_with_targets);
+ WM_operatortype_append(OBJECT_OT_constraint_copy);
WM_operatortype_append(POSE_OT_constraint_add);
WM_operatortype_append(POSE_OT_constraint_add_with_targets);
WM_operatortype_append(OBJECT_OT_constraints_clear);