diff options
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 37 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 |
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); |