diff options
author | Matt Ebb <matt@mke3.net> | 2010-03-31 04:55:01 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-03-31 04:55:01 +0400 |
commit | 4a451714d64e0628e06cce6f7cdedcb88a79efc5 (patch) | |
tree | 15aa4fd835f0d309f5f2fbe0d09f11efc3bd14c6 /source/blender/editors/object/object_constraint.c | |
parent | 05c2906b769a3a56939bd870589dab637b73d63d (diff) |
Fix [#21832] Add Modifier, Pinned Context
Added convenience function ED_object_active_context(C) to get either the
object in the data context, or if not, the active object.
Diffstat (limited to 'source/blender/editors/object/object_constraint.c')
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 38d560c5c8e..0db31b90365 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -64,6 +64,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" +#include "ED_object.h" #include "ED_screen.h" #include "UI_interface.h" @@ -801,7 +802,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_active_context(C); Scene *scene= CTX_data_scene(C); /* do freeing */ @@ -835,7 +836,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) /* get the Object and/or PoseChannel to use as target */ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, short add) { - Object *obact= CTX_data_active_object(C); + Object *obact= ED_object_active_context(C); bPoseChannel *pchanact= get_active_posechannel(obact); short only_curve= 0, only_mesh= 0, only_ob= 0; short found= 0; @@ -1090,17 +1091,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* dummy operator callback */ static int object_constraint_add_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - Object *ob; + Object *ob=ED_object_active_context(C); int type= RNA_enum_get(op->ptr, "type"); short with_targets= 0; - /* get active object from context */ - if (sa->spacetype == SPACE_BUTS) - ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - else - ob= CTX_data_active_object(C); - if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to."); return OPERATOR_CANCELLED; @@ -1118,17 +1112,10 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) /* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - Object *ob; + Object *ob= ED_object_active_context(C); int type= RNA_enum_get(op->ptr, "type"); short with_targets= 0; - /* get active object from context */ - if (sa->spacetype == SPACE_BUTS) - ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - else - ob= CTX_data_active_object(C); - if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to."); return OPERATOR_CANCELLED; |