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:
authorMatt Ebb <matt@mke3.net>2010-03-31 04:55:01 +0400
committerMatt Ebb <matt@mke3.net>2010-03-31 04:55:01 +0400
commit4a451714d64e0628e06cce6f7cdedcb88a79efc5 (patch)
tree15aa4fd835f0d309f5f2fbe0d09f11efc3bd14c6 /source/blender/editors/object
parent05c2906b769a3a56939bd870589dab637b73d63d (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')
-rw-r--r--source/blender/editors/object/object_constraint.c23
-rw-r--r--source/blender/editors/object/object_edit.c10
-rw-r--r--source/blender/editors/object/object_modifier.c4
3 files changed, 17 insertions, 20 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;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index a2ad5cf4471..419956c6626 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -120,6 +120,16 @@ static int pupmenu(const char *msg) {return 0;}
static bContext *C;
static void error_libdata() {}
+
+/* find the correct active object per context */
+Object *ED_object_active_context(bContext *C)
+{
+ Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ if (!ob) ob= CTX_data_active_object(C);
+ return ob;
+}
+
+
/* ********* clear/set restrict view *********/
static int object_restrictview_clear_exec(bContext *C, wmOperator *op)
{
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 8150bd9b84f..a43f3de9b14 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -499,7 +499,7 @@ static int modifier_poll(bContext *C)
static int modifier_add_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
+ Object *ob = ED_object_active_context(C);
int type= RNA_enum_get(op->ptr, "type");
if(!ED_object_modifier_add(op->reports, scene, ob, NULL, type))
@@ -512,7 +512,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *free)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob= ED_object_active_context(C);
EnumPropertyItem *item= NULL, *md_item;
ModifierTypeInfo *mti;
int totitem= 0, a;