diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-11 22:58:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-11 22:58:30 +0300 |
commit | 53250f85dbecdc4cdd6eded772972b137f3f8c6c (patch) | |
tree | 2deea82dca566fd752753d34b7df3e38ba4d0216 /source/blender | |
parent | 047ee04418a5a785177258dd965f94571d553b57 (diff) |
object.constraints.add()/remove()/active, same for PoseChannel
modified internal api for minimal rna wrapper functions.
TODO
- missing updates for pose channels
- typecheck for pose/object constraints
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_constraint.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 85 | ||||
-rw-r--r-- | source/blender/editors/include/ED_object.h | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 87 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 15 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 35 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 48 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 40 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose_api.c | 58 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 4 |
12 files changed, 285 insertions, 96 deletions
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index f957c5e17d4..7e0bb9fa08e 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -102,6 +102,9 @@ typedef struct bConstraintTypeInfo { bConstraintTypeInfo *constraint_get_typeinfo(struct bConstraint *con); bConstraintTypeInfo *get_constraint_typeinfo(int type); +struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short type); +struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type); + /* ---------------------------------------------------------------------------- */ /* Useful macros for testing various common flag combinations */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 55001f58d2f..6fce9a29962 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3601,6 +3601,91 @@ bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con) return NULL; } +/* Creates a new constraint, initialises its data, and returns it */ +static bConstraint *add_new_constraint_internal(const char *name, short type) +{ + bConstraint *con; + bConstraintTypeInfo *cti; + + con = MEM_callocN(sizeof(bConstraint), "Constraint"); + + /* Set up a generic constraint datablock */ + con->type = type; + con->flag |= CONSTRAINT_EXPAND; + con->enforce = 1.0f; + + /* Load the data for it */ + cti = constraint_get_typeinfo(con); + if (cti) { + con->data = MEM_callocN(cti->size, cti->structName); + + /* only constraints that change any settings need this */ + if (cti->new_data) + cti->new_data(con->data); + + /* set the name based on the type of constraint */ + name= name ? name : cti->name; + } + else + name= name ? name : "Const"; + + strcpy(con->name, name); + + return con; +} + +/* if pchan is not NULL then assume we're adding a pose constraint */ +static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type) +{ + bConstraint *con; + ListBase *list; + + con= add_new_constraint_internal(name, type); + + if(pchan) list= &pchan->constraints; + else list= &ob->constraints; + + if (list) { + bConstraint *coniter; + + /* add new constraint to end of list of constraints before ensuring that it has a unique name + * (otherwise unique-naming code will fail, since it assumes element exists in list) + */ + BLI_addtail(list, con); + unique_constraint_name(con, list); + + /* if the target list is a list on some PoseChannel belonging to a proxy-protected + * Armature layer, we must tag newly added constraints with a flag which allows them + * to persist after proxy syncing has been done + */ + if (proxylocked_constraints_owner(ob, pchan)) + con->flag |= CONSTRAINT_PROXY_LOCAL; + + /* make this constraint the active one + * - since constraint was added at end of stack, we can just go + * through deactivating all previous ones + */ + con->flag |= CONSTRAINT_ACTIVE; + for (coniter= con->prev; coniter; coniter= coniter->prev) + coniter->flag &= ~CONSTRAINT_ACTIVE; + } + + return con; +} + +bConstraint *add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type) +{ + if(pchan==NULL) + return NULL; + + return add_new_constraint(ob, pchan, name, type); +} + +bConstraint *add_ob_constraint(Object *ob, const char *name, short type) +{ + return add_new_constraint(ob, NULL, name, type); +} + /* ************************* General Constraints API ************************** */ /* The functions here are called by various parts of Blender. Very few (should be none if possible) * constraint-specific code should occur here. diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index b2d92869a2f..f9cf6edc6ac 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -91,9 +91,6 @@ int object_is_libdata(struct Object *ob); int object_data_is_libdata(struct Object *ob); /* constraints */ -struct bConstraint *add_new_constraint(short type); -void add_constraint_to_object(struct bConstraint *con, struct Object *ob); - struct ListBase *get_active_constraints(struct Object *ob); struct bConstraint *get_active_constraint(struct Object *ob); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 2d98a284df0..9c890006c45 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -187,56 +187,6 @@ void update_pyconstraint_cb (void *arg1, void *arg2) #endif } -/* Creates a new constraint, initialises its data, and returns it */ -bConstraint *add_new_constraint (short type) -{ - bConstraint *con; - bConstraintTypeInfo *cti; - - con = MEM_callocN(sizeof(bConstraint), "Constraint"); - - /* Set up a generic constraint datablock */ - con->type = type; - con->flag |= CONSTRAINT_EXPAND; - con->enforce = 1.0f; - - /* Load the data for it */ - cti = constraint_get_typeinfo(con); - if (cti) { - con->data = MEM_callocN(cti->size, cti->structName); - - /* only constraints that change any settings need this */ - if (cti->new_data) - cti->new_data(con->data); - - /* set the name based on the type of constraint */ - strcpy(con->name, cti->name); - } - else - strcpy(con->name, "Const"); - - return con; -} - -/* Adds the given constraint to the Object-level set of constraints for the given Object */ -void add_constraint_to_object (bConstraint *con, Object *ob) -{ - ListBase *list; - list = &ob->constraints; - - if (list) { - unique_constraint_name(con, list); - BLI_addtail(list, con); - - if (proxylocked_constraints_owner(ob, NULL)) - con->flag |= CONSTRAINT_PROXY_LOCAL; - - con->flag |= CONSTRAINT_ACTIVE; - for (con= con->prev; con; con= con->prev) - con->flag &= ~CONSTRAINT_ACTIVE; - } -} - /* helper function for add_constriant - sets the last target for the active constraint */ static void set_constraint_nth_target (bConstraint *con, Object *target, char subtarget[], int index) { @@ -1076,9 +1026,14 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget) { Scene *scene= CTX_data_scene(C); - bPoseChannel *pchan= get_active_posechannel(ob); + bPoseChannel *pchan; bConstraint *con; + if(list == &ob->constraints) + pchan= NULL; + else + pchan= get_active_posechannel(ob); + /* check if constraint to be added is valid for the given constraints stack */ if (type == CONSTRAINT_TYPE_NULL) { return OPERATOR_CANCELLED; @@ -1097,32 +1052,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase } /* create a new constraint of the type requried, and add it to the active/given constraints list */ - con = add_new_constraint(type); - - if (list) { - bConstraint *coniter; - - /* add new constraint to end of list of constraints before ensuring that it has a unique name - * (otherwise unique-naming code will fail, since it assumes element exists in list) - */ - BLI_addtail(list, con); - unique_constraint_name(con, list); - - /* if the target list is a list on some PoseChannel belonging to a proxy-protected - * Armature layer, we must tag newly added constraints with a flag which allows them - * to persist after proxy syncing has been done - */ - if (proxylocked_constraints_owner(ob, pchan)) - con->flag |= CONSTRAINT_PROXY_LOCAL; - - /* make this constraint the active one - * - since constraint was added at end of stack, we can just go - * through deactivating all previous ones - */ - con->flag |= CONSTRAINT_ACTIVE; - for (coniter= con->prev; coniter; coniter= coniter->prev) - coniter->flag &= ~CONSTRAINT_ACTIVE; - } + if(pchan) + con = add_pose_constraint(ob, pchan, NULL, type); + else + con = add_ob_constraint(ob, NULL, type); /* get the first selected object/bone, and make that the target * - apart from the buttons-window add buttons, we shouldn't add in this way diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 95b874e7145..7e7b1d99825 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -608,14 +608,11 @@ static int parent_set_exec(bContext *C, wmOperator *op) bFollowPathConstraint *data; float cmat[4][4], vec[3]; - con = add_new_constraint(CONSTRAINT_TYPE_FOLLOWPATH); - strcpy (con->name, "AutoPath"); + con = add_ob_constraint(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH); data = con->data; data->tar = par; - add_constraint_to_object(con, ob); - get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob)); sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); @@ -923,8 +920,7 @@ static int track_set_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(ob!=obact) { - con = add_new_constraint(CONSTRAINT_TYPE_TRACKTO); - strcpy (con->name, "AutoTrack"); + con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); data = con->data; data->tar = obact; @@ -935,8 +931,6 @@ static int track_set_exec(bContext *C, wmOperator *op) data->reserved1 = TRACK_nZ; data->reserved2 = UP_Y; } - - add_constraint_to_object(con, ob); } } CTX_DATA_END; @@ -947,8 +941,7 @@ static int track_set_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(ob!=obact) { - con = add_new_constraint(CONSTRAINT_TYPE_LOCKTRACK); - strcpy (con->name, "AutoTrack"); + con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK); data = con->data; data->tar = obact; @@ -959,8 +952,6 @@ static int track_set_exec(bContext *C, wmOperator *op) data->trackflag = TRACK_nZ; data->lockflag = LOCK_Y; } - - add_constraint_to_object(con, ob); } } CTX_DATA_END; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 808b3ffa4ff..618e71951c2 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -878,7 +878,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) } } - con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC); + con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC); BLI_addtail(&pchan->constraints, con); pchan->constflag |= (PCHAN_HAS_IK|PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */ data= con->data; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index d90b4f17c85..64af7e07fd5 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -213,6 +213,7 @@ void RNA_api_main(struct StructRNA *srna); void RNA_api_material(StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); void RNA_api_object(struct StructRNA *srna); +void RNA_api_pose_channel(struct StructRNA *srna); void RNA_api_scene(struct StructRNA *srna); void RNA_api_text(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 63a7d68a0cd..652d018c345 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -86,6 +86,7 @@ EnumPropertyItem object_type_items[] = { #include "BLI_math.h" #include "DNA_key_types.h" +#include "DNA_constraint_types.h" #include "BKE_armature.h" #include "BKE_bullet.h" @@ -859,6 +860,30 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd); } +static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + bConstraint *con; + for(con= ob->constraints.first; con; con= con->next) { + if(con->flag & CONSTRAINT_ACTIVE) + break; + } + + return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con); +} + +static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value) +{ + Object *ob= (Object*)ptr->id.data; + bConstraint *con; + for(con= ob->constraints.first; con; con= con->next) { + if(value.data==con) + con->flag |= CONSTRAINT_ACTIVE; + else + con->flag &= ~CONSTRAINT_ACTIVE; + } +} + #else static void rna_def_vertex_group(BlenderRNA *brna) @@ -1428,6 +1453,16 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Constraint"); RNA_def_property_ui_text(prop, "Constraints", "Constraints of the object."); + RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); + + { /* Collection active property */ + PropertyRNA *prop_act= RNA_def_property(srna, "constraints__active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop_act, "Constraint"); + RNA_def_property_pointer_funcs(prop_act, "rna_Object_active_constraint_get", "rna_Object_active_constraint_set", NULL); + RNA_def_property_flag(prop_act, PROP_EDITABLE); + RNA_def_property_ui_text(prop_act, "Active Constraint", "Active Object constraint."); + RNA_def_property_collection_active(prop, prop_act); + } prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Modifier"); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 8fcc4e49986..6435102d8e4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -33,6 +33,7 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "DNA_object_types.h" @@ -50,6 +51,7 @@ #include "BKE_mesh.h" #include "BKE_DerivedMesh.h" +#include "BKE_constraint.h" #include "BKE_customdata.h" #include "BKE_anim.h" #include "BKE_depsgraph.h" @@ -64,6 +66,7 @@ #include "DNA_meshdata_types.h" #include "DNA_curve_types.h" #include "DNA_modifier_types.h" +#include "DNA_constraint_types.h" #include "MEM_guardedalloc.h" @@ -349,6 +352,30 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int } */ +static bConstraint *rna_Object_constraints_add(Object *object, bContext *C, int type) +{ + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object); + return add_ob_constraint(object, NULL, type); +} + +static int rna_Object_constraints_remove(Object *object, bContext *C, int index) +{ + bConstraint *con= BLI_findlink(&object->constraints, index); + + if(con) { + free_constraint_data(con); + BLI_freelinkN(&object->constraints, con); + + ED_object_constraint_set_active(object, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, object); + + return 1; + } + else { + return 0; + } +} + #else void RNA_api_object(StructRNA *srna) @@ -424,6 +451,27 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_boolean(func, "is_visible", 0, "", "Object visibility."); RNA_def_function_return(func, parm); + + /* Constraint collection */ + func= RNA_def_function(srna, "constraints__add", "rna_Object_constraints_add"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add a constraint to this object"); + /* return type */ + parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint."); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "constraints__remove", "rna_Object_constraints_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove a constraint from this object."); + /* return type */ + parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully."); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); } #endif diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 5d2c281fb62..7199bdaa2f6 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -414,6 +414,32 @@ static void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *r } #endif +static PointerRNA rna_PoseChannel_active_constraint_get(PointerRNA *ptr) +{ + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + + bConstraint *con; + for(con= pchan->constraints.first; con; con= con->next) { + if(con->flag & CONSTRAINT_ACTIVE) + break; + } + + return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con); +} + +static void rna_PoseChannel_active_constraint_set(PointerRNA *ptr, PointerRNA value) +{ + bPoseChannel *pchan= (bPoseChannel*)ptr->data; + + bConstraint *con; + for(con= pchan->constraints.first; con; con= con->next) { + if(value.data==con) + con->flag |= CONSTRAINT_ACTIVE; + else + con->flag &= ~CONSTRAINT_ACTIVE; + } +} + #else static void rna_def_bone_group(BlenderRNA *brna) @@ -512,7 +538,17 @@ static void rna_def_pose_channel(BlenderRNA *brna) /* Bone Constraints */ prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Constraint"); - RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel."); + RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel."); + RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); + + { /* Collection active property */ + PropertyRNA *prop_act= RNA_def_property(srna, "constraints__active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop_act, "Constraint"); + RNA_def_property_pointer_funcs(prop_act, "rna_PoseChannel_active_constraint_get", "rna_PoseChannel_active_constraint_set", NULL); + RNA_def_property_flag(prop_act, PROP_EDITABLE); + RNA_def_property_ui_text(prop_act, "Active Constraint", "Active PoseChannel constraint."); + RNA_def_property_collection_active(prop, prop_act); + } /* Name + Selection Status */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); @@ -791,6 +827,8 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + + RNA_api_pose_channel(srna); } static void rna_def_pose_itasc(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c index 40bb131b3f9..ae83b728dd6 100644 --- a/source/blender/makesrna/intern/rna_pose_api.c +++ b/source/blender/makesrna/intern/rna_pose_api.c @@ -33,6 +33,7 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "DNA_object_types.h" @@ -43,14 +44,71 @@ /* #include "DNA_anim_types.h" */ #include "DNA_action_types.h" /* bPose */ +#include "BKE_constraint.h" /* bPose */ + +static bConstraint *rna_PoseChannel_constraints_add(bPoseChannel *pchan, bContext *C, int type) +{ + //WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object); + // TODO, pass object also + // TODO, new pose bones don't have updated draw flags + return add_pose_constraint(NULL, pchan, NULL, type); +} + +static int rna_PoseChannel_constraints_remove(bPoseChannel *pchan, bContext *C, int index) +{ + bConstraint *con= BLI_findlink(&pchan->constraints, index); + + if(con) { + free_constraint_data(con); + BLI_freelinkN(&pchan->constraints, con); + + //ED_object_constraint_set_active(object, NULL); + //WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, object); + + return 1; + } + else { + return 0; + } +} + #else void RNA_api_pose(StructRNA *srna) { /* FunctionRNA *func; */ /* PropertyRNA *parm; */ +} + +void RNA_api_pose_channel(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + + /* Constraint collection */ + func= RNA_def_function(srna, "constraints__add", "rna_PoseChannel_constraints_add"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add a constraint to this object"); + /* return type */ + parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint."); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "constraints__remove", "rna_PoseChannel_constraints_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove a constraint from this object."); + /* return type */ + parm= RNA_def_boolean(func, "success", 0, "Success", "Removed the constraint successfully."); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); } + #endif diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 943d559133f..4805d6e8156 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2229,7 +2229,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop_act, "ObjectBase"); RNA_def_property_pointer_sdna(prop_act, NULL, "basact"); RNA_def_property_flag(prop_act, PROP_EDITABLE); - RNA_def_property_ui_text(prop_act, "Active Base", "Active object in the scene."); + RNA_def_property_ui_text(prop_act, "Active Base", "Active object base in the scene."); RNA_def_property_update(prop_act, NC_SCENE|ND_OB_ACTIVE, NULL); RNA_def_property_collection_active(prop, prop_act); } @@ -2245,7 +2245,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop_act, "Object"); RNA_def_property_pointer_funcs(prop_act, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL); RNA_def_property_flag(prop_act, PROP_EDITABLE); - RNA_def_property_ui_text(prop_act, "Object", "Object to use as projector transform."); + RNA_def_property_ui_text(prop_act, "Active Object", "Active object for this scene."); /* Could call: ED_base_object_activate(C, scene->basact); * but would be a bad level call and it seems the notifier is enough */ RNA_def_property_update(prop_act, NC_SCENE|ND_OB_ACTIVE, NULL); |