diff options
30 files changed, 451 insertions, 412 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 6a1ef195d1d..19c569f7d2a 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -683,10 +683,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *t_ptr); int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr); int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr); - -PropertyRNA *RNA_property_collection_active(PropertyRNA *prop); -FunctionRNA *RNA_property_collection_add_func(PropertyRNA *prop); -FunctionRNA *RNA_property_collection_remove_func(PropertyRNA *prop); +int RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr); /* efficient functions to set properties for arrays */ int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array); diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index ed4a371b9c3..5ed0fb5194d 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -163,8 +163,8 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item); void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set); void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef); -void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove); -void RNA_def_property_collection_active(PropertyRNA *prop, PropertyRNA *prop_act); +void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring); +void RNA_def_property_srna(PropertyRNA *prop, const char *type); /* Function */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 6f1e61e6869..526178d7b26 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -369,7 +369,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr if(strcmp(manualfunc, "rna_iterator_listbase_get") == 0 || strcmp(manualfunc, "rna_iterator_array_get") == 0 || strcmp(manualfunc, "rna_iterator_array_dereference_get") == 0) - fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->type)? (char*)cprop->type: "UnknownType", manualfunc); + fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->item_type)? (char*)cprop->item_type: "UnknownType", manualfunc); else fprintf(f, " return %s(iter);\n", manualfunc); } @@ -965,7 +965,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) DefRNA.error= 1; } } - if(!cprop->type) { + if(!cprop->item_type) { fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a struct type.\n", srna->identifier, prop->identifier); DefRNA.error= 1; } @@ -1132,8 +1132,8 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop; - if(cprop->type) - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->type, srna->identifier, prop->identifier); + if(cprop->item_type) + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (char*)cprop->item_type, srna->identifier, prop->identifier); else fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier); break; @@ -1357,8 +1357,8 @@ static void rna_auto_types() else if(dp->prop->type== PROP_COLLECTION) { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop; - if(!cprop->type && !cprop->get && strcmp(dp->dnatype, "ListBase")==0) - cprop->type= (StructRNA*)rna_find_type(dp->dnatype); + if(!cprop->item_type && !cprop->get && strcmp(dp->dnatype, "ListBase")==0) + cprop->item_type= (StructRNA*)rna_find_type(dp->dnatype); } } } @@ -1767,6 +1767,11 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop); else fprintf(f, "\t0, 0"); + + /* our own type - collections/arrays only */ + if(prop->srna) fprintf(f, ", &RNA_%s", (char*)prop->srna); + else fprintf(f, ", NULL"); + fprintf(f, "},\n"); switch(prop->type) { @@ -1830,13 +1835,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring)); - if(cprop->add) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->add); - else fprintf(f, "NULL, "); - if(cprop->remove) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->remove); - else fprintf(f, "NULL, "); - if(cprop->active) fprintf(f, "(PropertyRNA*)&rna_%s%s_%s, ", srna->identifier, strnest, cprop->active->identifier); - else fprintf(f, "NULL, "); - if(cprop->type) fprintf(f, "&RNA_%s\n", (char*)cprop->type); + if(cprop->item_type) fprintf(f, "&RNA_%s\n", (char*)cprop->item_type); else fprintf(f, "NULL\n"); break; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c8d488db6c3..d3c5df64c38 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -727,8 +727,8 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop) else if(prop->type == PROP_COLLECTION) { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - if(cprop->type) - return cprop->type; + if(cprop->item_type) + return cprop->item_type; } return &RNA_UnknownType; @@ -1490,8 +1490,8 @@ static void rna_property_collection_get_idp(CollectionPropertyIterator *iter) CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop; iter->ptr.data= rna_iterator_array_get(iter); - iter->ptr.type= cprop->type; - rna_pointer_inherit_id(cprop->type, &iter->parent, &iter->ptr); + iter->ptr.type= cprop->item_type; + rna_pointer_inherit_id(cprop->item_type, &iter->parent, &iter->ptr); } void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter) @@ -1617,7 +1617,7 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; r_ptr->data= IDP_GetIndexArray(idprop, idprop->len-1); - r_ptr->type= cprop->type; + r_ptr->type= cprop->item_type; rna_pointer_inherit_id(NULL, ptr, r_ptr); } else @@ -1772,22 +1772,10 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co } } -PropertyRNA *RNA_property_collection_active(PropertyRNA *prop) +int RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr) { - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - return cprop->active; -} - -FunctionRNA *RNA_property_collection_add_func(PropertyRNA *prop) -{ - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - return cprop->add; -} - -FunctionRNA *RNA_property_collection_remove_func(PropertyRNA *prop) -{ - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - return cprop->remove; + *r_ptr= *ptr; + return ((r_ptr->type = prop->srna)); } int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, PropertyRNA *itemprop, RawArray *array) diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index f73ac517213..25d602a8b2e 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -663,7 +663,7 @@ static void rna_def_armature(BlenderRNA *brna) /* Collections */ prop= RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "bonebase", NULL); - RNA_def_property_collection_funcs(prop, 0, "rna_Armature_bones_next", 0, 0, 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, "rna_Armature_bones_next", 0, 0, 0, 0, 0); RNA_def_property_struct_type(prop, "Bone"); RNA_def_property_ui_text(prop, "Bones", ""); @@ -676,7 +676,7 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_bone_set", NULL); /* todo, redraw */ - RNA_def_property_collection_active(prop, prop_act); +// RNA_def_property_collection_active(prop, prop_act); } prop= RNA_def_property(srna, "edit_bones", PROP_COLLECTION, PROP_NONE); @@ -692,7 +692,7 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop_act, "Active EditBone", "Armatures active edit bone."); //RNA_def_property_update(prop_act, 0, "rna_Armature_act_editbone_update"); RNA_def_property_pointer_funcs(prop_act, NULL, "rna_Armature_act_edit_bone_set", NULL); - RNA_def_property_collection_active(prop, prop_act); +// RNA_def_property_collection_active(prop, prop_act); } /* Enum values */ diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 4cef6fa481f..2a97eb78382 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -212,7 +212,7 @@ static void rna_def_curvemapping(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxy_range"); prop= RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0); RNA_def_property_struct_type(prop, "CurveMap"); RNA_def_property_ui_text(prop, "Curves", ""); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 77ae6ebf5c0..4c7a88d304b 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -889,7 +889,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "bp", NULL); RNA_def_property_struct_type(prop, "CurvePoint"); - RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0); RNA_def_property_ui_text(prop, "Points", "Collection of points that make up this poly or nurbs spline."); prop= RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 46c4a8af73a..891911d5765 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -654,7 +654,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * if(DefRNA.preprocess) { RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, "rna_builtin_properties_lookup_string", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, "rna_builtin_properties_lookup_string"); } else { #ifdef RNA_RUNTIME @@ -662,7 +662,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * cprop->begin= rna_builtin_properties_begin; cprop->next= rna_builtin_properties_next; cprop->get= rna_builtin_properties_get; - cprop->type= &RNA_Property; + cprop->item_type= &RNA_Property; #endif } @@ -1158,7 +1158,7 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type) } case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - cprop->type = (StructRNA*)type; + cprop->item_type = (StructRNA*)type; break; } default: @@ -1189,7 +1189,7 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type) } case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - cprop->type = type; + cprop->item_type = type; break; } default: @@ -1926,7 +1926,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch } } -void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove) +void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring) { StructRNA *srna= DefRNA.laststruct; @@ -1946,8 +1946,6 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con if(length) cprop->length= (PropCollectionLengthFunc)length; if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint; if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring; - if(add) cprop->add= (FunctionRNA*)add; - if(remove) cprop->remove= (FunctionRNA*)remove; break; } default: @@ -1957,24 +1955,9 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con } } -void RNA_def_property_collection_active(PropertyRNA *prop, PropertyRNA *prop_act) +void RNA_def_property_srna(PropertyRNA *prop, const char *type) { - if(!DefRNA.preprocess) { - fprintf(stderr, "RNA_def_property_collection_active: only during preprocessing.\n"); - return; - } - - switch(prop->type) { - case PROP_COLLECTION: { - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - cprop->active= prop_act; - break; - } - default: - fprintf(stderr, "RNA_def_property_collection_active: %s.%s, type is not collection.\n", prop->identifier, prop_act->identifier); - DefRNA.error= 1; - break; - } + prop->srna= (StructRNA*)type; } /* Compact definitions */ diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 085f0030422..84353cb273f 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -190,6 +190,26 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value) fcu->rna_path= NULL; } +DriverTarget *rna_Driver_add_target(ChannelDriver *driver, char *name) +{ + DriverTarget *dtar= driver_add_new_target(driver); + + /* set the name if given */ + if (name && name[0]) { + BLI_strncpy(dtar->name, name, 64); + BLI_uniquename(&driver->targets, dtar, "var", '_', offsetof(DriverTarget, name), 64); + } + + /* return this target for the users to play with */ + return dtar; +} + +void rna_Driver_remove_target(ChannelDriver *driver, DriverTarget *dtar) +{ + /* call the API function for this */ + driver_free_target(driver, dtar); +} + #else @@ -593,6 +613,41 @@ static void rna_def_drivertarget(BlenderRNA *brna) //RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX disabled for now, until we can turn off auto updates } + +/* channeldriver.targets.* */ +static void rna_def_channeldriver_targets(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; +// PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna= RNA_def_struct(brna, "ChannelDriverTargets", NULL); + RNA_def_struct_sdna(srna, "ChannelDriver"); + RNA_def_struct_ui_text(srna, "ChannelDriver Targets", "Collection of channel driver Targets."); + + RNA_def_property_srna(cprop, "ChannelDriverTargets"); + + + /* add target */ + func= RNA_def_function(srna, "add", "rna_Driver_add_target"); + RNA_def_function_ui_description(func, "Add a new target for the driver."); + /* return type */ + parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Newly created Driver Target."); + RNA_def_function_return(func, parm); + /* optional name parameter */ + parm= RNA_def_string(func, "name", "", 64, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)"); + + /* remove target */ + func= RNA_def_function(srna, "remove", "rna_Driver_remove_target"); + RNA_def_function_ui_description(func, "Remove an existing target from the driver."); + /* target to remove*/ + parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Target to remove from the driver."); + RNA_def_property_flag(parm, PROP_REQUIRED); + +} + static void rna_def_channeldriver(BlenderRNA *brna) { StructRNA *srna; @@ -622,9 +677,9 @@ static void rna_def_channeldriver(BlenderRNA *brna) /* Collections */ prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "targets", NULL); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "targets__add", "targets__remove"); RNA_def_property_struct_type(prop, "DriverTarget"); RNA_def_property_ui_text(prop, "Target Variables", "Properties acting as targets for this driver."); + rna_def_channeldriver_targets(brna, prop); /* Functions */ RNA_api_drivers(srna); diff --git a/source/blender/makesrna/intern/rna_fcurve_api.c b/source/blender/makesrna/intern/rna_fcurve_api.c index 0abb5e8e499..d066d4f63fb 100644 --- a/source/blender/makesrna/intern/rna_fcurve_api.c +++ b/source/blender/makesrna/intern/rna_fcurve_api.c @@ -43,48 +43,12 @@ #include "BKE_animsys.h" #include "BKE_fcurve.h" -DriverTarget *rna_Driver_add_target(ChannelDriver *driver, char *name) -{ - DriverTarget *dtar= driver_add_new_target(driver); - - /* set the name if given */ - if (name && name[0]) { - BLI_strncpy(dtar->name, name, 64); - BLI_uniquename(&driver->targets, dtar, "var", '_', offsetof(DriverTarget, name), 64); - } - - /* return this target for the users to play with */ - return dtar; -} - -void rna_Driver_remove_target(ChannelDriver *driver, DriverTarget *dtar) -{ - /* call the API function for this */ - driver_free_target(driver, dtar); -} - #else void RNA_api_drivers(StructRNA *srna) { - FunctionRNA *func; - PropertyRNA *parm; - - /* add target */ - func= RNA_def_function(srna, "targets__add", "rna_Driver_add_target"); - RNA_def_function_ui_description(func, "Add a new target for the driver."); - /* return type */ - parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Newly created Driver Target."); - RNA_def_function_return(func, parm); - /* optional name parameter */ - parm= RNA_def_string(func, "name", "", 64, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)"); - - /* remove target */ - func= RNA_def_function(srna, "targets__remove", "rna_Driver_remove_target"); - RNA_def_function_ui_description(func, "Remove an existing target from the driver."); - /* target to remove*/ - parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Target to remove from the driver."); - RNA_def_property_flag(parm, PROP_REQUIRED); +// FunctionRNA *func; +// PropertyRNA *parm; } #endif diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 8babb9593a0..a1b5bf85bf7 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -49,13 +49,13 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter) return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject*)internal->link)->ob); } -static int rna_Group_objects_add(Group *group, bContext *C, Object *object) +static int rna_Group_objects_link(Group *group, bContext *C, Object *object) { WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id); return add_to_group(group, object, CTX_data_scene(C), NULL); } -static int rna_Group_objects_remove(Group *group, bContext *C, Object *object) +static int rna_Group_objects_unlink(Group *group, bContext *C, Object *object) { WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id); return rem_from_group(group, object, CTX_data_scene(C), NULL); @@ -63,56 +63,73 @@ static int rna_Group_objects_remove(Group *group, bContext *C, Object *object) #else -void RNA_def_group(BlenderRNA *brna) +/* group.objects */ +static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; - PropertyRNA *prop; +// PropertyRNA *prop; FunctionRNA *func; PropertyRNA *parm; - - srna= RNA_def_struct(brna, "Group", "ID"); - RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks."); - RNA_def_struct_ui_icon(srna, ICON_GROUP); - - prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); - RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the center to use when instancing as DupliGroup."); - RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); - prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER); - RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); - RNA_def_property_array(prop, 20); - RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this groups is instanced as a dupli."); + srna= RNA_def_struct(brna, "GroupObjectCollection", NULL); + RNA_def_struct_sdna(srna, "Group"); + RNA_def_struct_ui_text(srna, "GroupObjects", "Collection of group objects."); + RNA_def_property_srna(cprop, "GroupObjectCollection"); /* add object */ - func= RNA_def_function(srna, "objects__add", "rna_Group_objects_add"); + func= RNA_def_function(srna, "link", "rna_Group_objects_link"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add this object to a group"); /* return type */ - parm= RNA_def_boolean(func, "success", 0, "Success", "Newly created Group Target."); + parm= RNA_def_boolean(func, "success", 0, "Success", ""); RNA_def_function_return(func, parm); /* object to add */ parm= RNA_def_pointer(func, "object", "Object", "", "Object to add."); RNA_def_property_flag(parm, PROP_REQUIRED); /* remove object */ - func= RNA_def_function(srna, "objects__remove", "rna_Group_objects_remove"); + func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink"); RNA_def_function_ui_description(func, "Remove this object to a group"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); /* return type */ - parm= RNA_def_boolean(func, "success", 0, "Success", "Newly created Group Target."); + parm= RNA_def_boolean(func, "success", 0, "Success", ""); RNA_def_function_return(func, parm); /* object to remove */ parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); +} + + +void RNA_def_group(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "Group", "ID"); + RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks."); + RNA_def_struct_ui_icon(srna, ICON_GROUP); + + prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "dupli_ofs"); + RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the center to use when instancing as DupliGroup."); + RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); + + prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER); + RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); + RNA_def_property_array(prop, 20); + RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this groups is instanced as a dupli."); + prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects."); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, "objects__add", "objects__remove"); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0); + + rna_def_group_objects(brna, prop); + } #endif diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 434e4ee6fe9..db2063b899c 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -154,6 +154,11 @@ struct PropertyRNA { /* raw access */ int rawoffset; RawPropertyType rawtype; + + /* This is used for accessing props/functions of this property + * any property can have this but should only be used for collections and arrays + * since python will convert int/bool/pointer's */ + struct StructRNA *srna; /* attributes attached directly to this collection */ }; /* Property Types */ @@ -255,11 +260,8 @@ typedef struct CollectionPropertyRNA { PropCollectionLengthFunc length; /* optional */ PropCollectionLookupIntFunc lookupint; /* optional */ PropCollectionLookupStringFunc lookupstring; /* optional */ - FunctionRNA *add, *remove; - - PropertyRNA *active; - struct StructRNA *type; + struct StructRNA *item_type; /* the type of this item */ } CollectionPropertyRNA; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index ca36da5d03b..49dd96241cd 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -434,7 +434,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "data", "totelem"); RNA_def_property_struct_type(prop, "UnknownType"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0); } static void rna_def_key(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 1f7eee4d2d8..aff38ebdd74 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -183,7 +183,7 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); RNA_def_property_struct_type(prop, "VertexGroupElement"); RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this point is member of."); } @@ -254,7 +254,7 @@ static void rna_def_lattice(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "LatticePoint"); - RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Points", "Points of the lattice."); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 910a15890cb..1b93f6d1056 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -238,35 +238,35 @@ void RNA_def_main(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - const char *lists[][7]= { - {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", NULL, NULL}, - {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", NULL, NULL}, - {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", NULL, NULL}, - {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", NULL, NULL}, - {"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", NULL, NULL}, - {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", "add_mesh", "remove_mesh"}, - {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", NULL, NULL}, - {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", NULL, NULL}, - {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", NULL, NULL}, - {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", NULL, NULL}, - {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", NULL, NULL}, - {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", NULL, NULL}, - {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", NULL, NULL} , - {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", NULL, NULL}, - {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", NULL, NULL}, - {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", NULL, NULL}, - {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", NULL, NULL}, - {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", NULL, NULL}, - {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", NULL, NULL}, - {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL, NULL}, - {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED).", NULL, NULL}, - {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", NULL, NULL}, - {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", NULL, NULL}, - {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", NULL, NULL}, - {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", NULL, NULL}, - {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", NULL, NULL}, - {"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks.", NULL, NULL}, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL}}; + const char *lists[][5]= { + {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."}, + {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."}, + {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."}, + {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."}, + {"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks."}, + {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."}, // "add_mesh", "remove_mesh" + {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."}, + {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."}, + {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."}, + {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."}, + {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."}, + {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."}, + {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."} , + {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."}, + {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks."}, + {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks."}, + {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."}, + {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."}, + {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."}, + {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks."}, + {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED)."}, + {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."}, + {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks."}, + {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks."}, + {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks."}, + {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks."}, + {"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks."}, + {NULL, NULL, NULL, NULL, NULL}}; int i; srna= RNA_def_struct(brna, "Main", NULL); @@ -283,7 +283,7 @@ void RNA_def_main(BlenderRNA *brna) { prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, lists[i][1]); - RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, lists[i][5], lists[i][6]); + RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index e311cad4568..8372c144a89 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1748,7 +1748,7 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg /* mtex */ prop= RNA_def_property(srna, "textures", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, structname); - RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures."); prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 9217a7a7b98..a4fda162dc5 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -936,7 +936,7 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); RNA_def_property_struct_type(prop, "VertexGroupElement"); RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of."); @@ -1111,7 +1111,7 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshTextureFace"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0); srna= RNA_def_struct(brna, "MeshTextureFace", NULL); RNA_def_struct_sdna(srna, "MTFace"); @@ -1283,7 +1283,7 @@ static void rna_def_mcol(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshColor"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0); srna= RNA_def_struct(brna, "MeshColor", NULL); RNA_def_struct_sdna(srna, "MCol"); @@ -1338,7 +1338,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshFloatProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0); srna= RNA_def_struct(brna, "MeshFloatProperty", NULL); RNA_def_struct_sdna(srna, "MFloatProperty"); @@ -1364,7 +1364,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshIntProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0); srna= RNA_def_struct(brna, "MeshIntProperty", NULL); RNA_def_struct_sdna(srna, "MIntProperty"); @@ -1390,7 +1390,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshStringProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0); srna= RNA_def_struct(brna, "MeshStringProperty", NULL); RNA_def_struct_sdna(srna, "MStringProperty"); @@ -1476,7 +1476,7 @@ static void rna_def_mesh(BlenderRNA *brna) /* UV textures */ prop= RNA_def_property(srna, "uv_textures", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", 0, 0, 0, "rna_Mesh_uv_textures_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", 0, 0, 0, "rna_Mesh_uv_textures_length", 0, 0); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); RNA_def_property_ui_text(prop, "UV Textures", ""); @@ -1496,7 +1496,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", 0, 0, 0, "rna_Mesh_vertex_colors_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", 0, 0, 0, "rna_Mesh_vertex_colors_length", 0, 0); RNA_def_property_struct_type(prop, "MeshColorLayer"); RNA_def_property_ui_text(prop, "Vertex Colors", ""); @@ -1514,19 +1514,19 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0); RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer"); RNA_def_property_ui_text(prop, "Float Property Layers", ""); prop= RNA_def_property(srna, "int_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0); RNA_def_property_struct_type(prop, "MeshIntPropertyLayer"); RNA_def_property_ui_text(prop, "Int Property Layers", ""); prop= RNA_def_property(srna, "string_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0); RNA_def_property_struct_type(prop, "MeshStringPropertyLayer"); RNA_def_property_ui_text(prop, "String Property Layers", ""); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 7bc10c4f470..ac9495764e7 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1233,7 +1233,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop= RNA_def_property(srna, "projectors", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "UVProjector"); - RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Projectors", ""); prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 652d018c345..08e6b17f1c5 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -28,6 +28,7 @@ #include "RNA_access.h" #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -90,6 +91,7 @@ EnumPropertyItem object_type_items[] = { #include "BKE_armature.h" #include "BKE_bullet.h" +#include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" @@ -884,6 +886,31 @@ static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value) } } + +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 static void rna_def_vertex_group(BlenderRNA *brna) @@ -1152,6 +1179,51 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine."); } +static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; +// PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna= RNA_def_struct(brna, "ObjectConstraints", NULL); + RNA_def_struct_sdna(srna, "Object"); + RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints."); + + RNA_def_property_srna(cprop, "ObjectConstraints"); + + + /* Collection active property */ + PropertyRNA *prop_act= RNA_def_property(srna, "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."); + + + /* Constraint collection */ + func= RNA_def_function(srna, "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, "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); +} + static void rna_def_object(BlenderRNA *brna) { StructRNA *srna; @@ -1326,7 +1398,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "MaterialSlot"); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0, 0, 0); /* don't dereference pointer! */ + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0); /* don't dereference pointer! */ RNA_def_property_ui_text(prop, "Materials", "Material slots in the object."); prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); @@ -1453,16 +1525,8 @@ 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); - } +// RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); + rna_def_object_constraints(brna, prop); 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 6435102d8e4..827e0cc60d9 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -33,7 +33,6 @@ #include "RNA_define.h" #include "RNA_types.h" -#include "RNA_enum_types.h" #include "DNA_object_types.h" @@ -51,7 +50,6 @@ #include "BKE_mesh.h" #include "BKE_DerivedMesh.h" -#include "BKE_constraint.h" #include "BKE_customdata.h" #include "BKE_anim.h" #include "BKE_depsgraph.h" @@ -352,30 +350,6 @@ 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) @@ -451,27 +425,6 @@ 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_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index d6239d92911..9e764419f19 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -756,7 +756,7 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); prop= RNA_def_property(srna, "point_cache_list", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); RNA_def_property_struct_type(prop, "PointCache"); RNA_def_property_ui_text(prop, "Point Cache List", "Point cache list"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 7199bdaa2f6..5efc4eb3fc0 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -27,6 +27,7 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -48,6 +49,7 @@ #include "DNA_userdef_types.h" #include "BKE_context.h" +#include "BKE_constraint.h" #include "BKE_depsgraph.h" #include "BKE_idprop.h" @@ -440,6 +442,32 @@ static void rna_PoseChannel_active_constraint_set(PointerRNA *ptr, PointerRNA va } } +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 static void rna_def_bone_group(BlenderRNA *brna) @@ -512,6 +540,51 @@ static EnumPropertyItem prop_solver_items[] = { {ITASC_SOLVER_DLS, "DLS", 0, "DLS", "Damped Least Square with Numerical Filtering"}, {0, NULL, 0, NULL, NULL}}; + +static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna= RNA_def_struct(brna, "PoseChannelConstraints", NULL); + RNA_def_struct_sdna(srna, "bPoseChannel"); + RNA_def_struct_ui_text(srna, "PoseChannel Constraints", "Collection of object constraints."); + + RNA_def_property_srna(cprop, "PoseChannelConstraints"); + + /* Collection active property */ + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Constraint"); + RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_active_constraint_get", "rna_PoseChannel_active_constraint_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Active Constraint", "Active PoseChannel constraint."); + + + /* Constraint collection */ + func= RNA_def_function(srna, "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, "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); +} + static void rna_def_pose_channel(BlenderRNA *brna) { // XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable @@ -539,16 +612,8 @@ static void rna_def_pose_channel(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 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); - } + + rna_def_pose_channel_constraints(brna, prop); /* Name + Selection Status */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c index ae83b728dd6..d044a0f7f51 100644 --- a/source/blender/makesrna/intern/rna_pose_api.c +++ b/source/blender/makesrna/intern/rna_pose_api.c @@ -33,7 +33,6 @@ #include "RNA_define.h" #include "RNA_types.h" -#include "RNA_enum_types.h" #include "DNA_object_types.h" @@ -44,33 +43,6 @@ /* #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 @@ -82,31 +54,8 @@ void RNA_api_pose(StructRNA *srna) 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); - +// FunctionRNA *func; +// PropertyRNA *parm; } diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 3505253b60f..5a80db74c38 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -307,7 +307,7 @@ static void rna_def_render_result(BlenderRNA *brna) prop= RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "RenderLayer"); - RNA_def_property_collection_funcs(prop, "rna_RenderResult_layers_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_RenderResult_layers_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); RNA_define_verify_sdna(1); } @@ -333,7 +333,7 @@ static void rna_def_render_layer(BlenderRNA *brna) prop= RNA_def_property(srna, "passes", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "RenderPass"); - RNA_def_property_collection_funcs(prop, "rna_RenderLayer_passes_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_RenderLayer_passes_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); prop= RNA_def_property(srna, "rect", PROP_FLOAT, PROP_NONE); RNA_def_property_flag(prop, PROP_DYNAMIC); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 31aecbb8a76..29a95c99851 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -715,7 +715,7 @@ static PointerRNA rna_CollectionProperty_fixed_type_get(PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; rna_idproperty_check(&prop, ptr); - return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA*)prop)->type); + return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((CollectionPropertyRNA*)prop)->item_type); } /* Function */ @@ -812,13 +812,13 @@ static void rna_def_struct(BlenderRNA *brna) prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Properties", "Properties in the struct."); prop= RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Function"); - RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Functions", ""); } @@ -950,7 +950,7 @@ static void rna_def_function(BlenderRNA *brna) prop= RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE); /*RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/ RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Parameters", "Parameters for the function."); prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE); @@ -1088,7 +1088,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "EnumPropertyItem"); - RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Items", "Possible values for the property."); srna= RNA_def_struct(brna, "EnumPropertyItem", NULL); @@ -1188,7 +1188,7 @@ void RNA_def_rna(BlenderRNA *brna) prop= RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Struct"); - RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); RNA_def_property_ui_text(prop, "Structs", ""); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4805d6e8156..0f64210420e 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2171,6 +2171,57 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine."); } + +/* scene.objects */ +static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + srna= RNA_def_struct(brna, "SceneObjects", NULL); + RNA_def_struct_sdna(srna, "Object"); + RNA_def_struct_ui_text(srna, "Scene Objects", "Collection of scene objects."); + + RNA_def_property_srna(cprop, "SceneObjects"); + +#if 0 + /* add object */ + func= RNA_def_function(srna, "link", "rna_Scene_objects_link"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add this object to this scene"); + /* return type */ + parm= RNA_def_boolean(func, "success", 0, "Success", ""); + RNA_def_function_return(func, parm); + /* object to add */ + parm= RNA_def_pointer(func, "object", "Object", "", "Object to add."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + /* remove object */ + func= RNA_def_function(srna, "unlink", "rna_Scene_objects_unlink"); + RNA_def_function_ui_description(func, "Remove this object to a scene"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + /* return type */ + parm= RNA_def_boolean(func, "success", 0, "Success", ""); + RNA_def_function_return(func, parm); + /* object to remove */ + parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); +#endif + + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "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, NC_SCENE|ND_OB_ACTIVE, NULL); +} + + void RNA_def_scene(BlenderRNA *brna) { StructRNA *srna; @@ -2231,27 +2282,15 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop_act, PROP_EDITABLE); 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); +// RNA_def_property_collection_active(prop, prop_act); } prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "base", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", ""); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0, 0); - - { /* Collection active property */ - prop_act= RNA_def_property(srna, "objects__active", PROP_POINTER, PROP_NONE); - 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, "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); - - RNA_def_property_collection_active(prop, prop_act); - } + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0); + rna_def_scene_objects(brna, prop); /* Layers */ prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 481abc983c2..e6d57a0be43 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -158,7 +158,7 @@ static void rna_def_paint(BlenderRNA *brna) "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", - "rna_Paint_brushes_length", 0, 0, 0, 0); + "rna_Paint_brushes_length", 0, 0); RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode."); prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 8bbffa4425a..670af4d230c 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -578,7 +578,7 @@ static void rna_def_editor(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "metastack", NULL); RNA_def_property_struct_type(prop, "Sequence"); RNA_def_property_ui_text(prop, "Meta Stack", "Meta strip stack, last is currently edited meta strip."); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0); prop= RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act_seq"); diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 0aa6d8b6e6e..9b4f98aca8e 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -125,11 +125,11 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat } RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context); - + if (mode==PYOP_INVOKE) { item= PyObject_GetAttrString(py_class, "invoke"); args = PyTuple_New(3); - + RNA_pointer_create(NULL, &RNA_Event, event, &ptr_event); // PyTuple_SET_ITEM "steals" object reference, it is @@ -149,9 +149,9 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context)); } PyTuple_SET_ITEM(args, 0, py_class_instance); - + ret = PyObject_Call(item, args, NULL); - + Py_DECREF(args); Py_DECREF(item); Py_DECREF(class_dict); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index a360d028043..865be249fb1 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1315,11 +1315,10 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self) nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name)); if(nameptr) { - if(strstr(nameptr, "__")==NULL) { /* __ for hidden props, used for active object for eg. */ - pystring = PyUnicode_FromString(nameptr); - PyList_Append(ret, pystring); - Py_DECREF(pystring); - } + pystring = PyUnicode_FromString(nameptr); + PyList_Append(ret, pystring); + Py_DECREF(pystring); + if(name != nameptr) MEM_freeN(nameptr); } @@ -1341,11 +1340,9 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self) RNA_PROP_BEGIN(&tptr, itemptr, iterprop) { idname= RNA_function_identifier(itemptr.data); - if(strstr(idname, "__")==NULL) { /* __ for hidden function members, used for collection add/remove for eg. */ - pystring = PyUnicode_FromString(idname); - PyList_Append(ret, pystring); - Py_DECREF(pystring); - } + pystring = PyUnicode_FromString(idname); + PyList_Append(ret, pystring); + Py_DECREF(pystring); } RNA_PROP_END; } @@ -1485,45 +1482,54 @@ static int pyrna_struct_setattro( BPy_StructRNA * self, PyObject *pyname, PyObje return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "StructRNA - Attribute (setattr):"); } -static PyObject *pyrna_prop_get_active( BPy_PropertyRNA * self ) +static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname ) { - PropertyRNA *prop_act; + char *name = _PyUnicode_AsString(pyname); + PyObject *ret; + PropertyRNA *prop; + FunctionRNA *func; - if (RNA_property_type(self->prop) != PROP_COLLECTION) { - PyErr_SetString( PyExc_TypeError, "this BPy_PropertyRNA object is not a collection"); - return NULL; - } + if (RNA_property_type(self->prop) == PROP_COLLECTION) { + PointerRNA r_ptr; + if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) { + if ((prop = RNA_struct_find_property(&r_ptr, name))) { + ret = pyrna_prop_to_py(&r_ptr, prop); + } + else if ((func = RNA_struct_find_function(&r_ptr, name))) { + PyObject *self_collection= pyrna_struct_CreatePyObject(&r_ptr); + ret = pyrna_func_to_py((BPy_DummyPointerRNA *)self_collection, func); + Py_DECREF(self_collection); + } - prop_act= RNA_property_collection_active(self->prop); - if (prop_act==NULL) { - PyErr_SetString( PyExc_TypeError, "collection has no active"); - return NULL; + return ret; + } } - return pyrna_prop_to_py(&self->ptr, prop_act); + /* The error raised here will be displayed */ + return PyObject_GenericGetAttr((PyObject *)self, pyname); } -static int pyrna_prop_set_active( BPy_PropertyRNA * self, PyObject * value ) +//--------------- setattr------------------------------------------- +static int pyrna_prop_setattro( BPy_PropertyRNA * self, PyObject *pyname, PyObject * value ) { - PropertyRNA *prop_act; - - if (RNA_property_type(self->prop) != PROP_COLLECTION) { - PyErr_SetString( PyExc_TypeError, "this BPy_PropertyRNA object is not a collection"); - return -1; - } + char *name = _PyUnicode_AsString(pyname); + PropertyRNA *prop; - prop_act= RNA_property_collection_active(self->prop); - if (prop_act==NULL) { - PyErr_SetString( PyExc_TypeError, "collection has no active"); - return -1; + if (RNA_property_type(self->prop) == PROP_COLLECTION) { + PointerRNA r_ptr; + if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) { + if ((prop = RNA_struct_find_property(&r_ptr, name))) { + /* pyrna_py_to_prop sets its own exceptions */ + return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):"); + } + } } - return pyrna_py_to_prop(&self->ptr, prop_act, NULL, value, "StructRNA - Attribute (setattr):"); + PyErr_Format( PyExc_AttributeError, "BPy_PropertyRNA - Attribute \"%.200s\" not found", name); + return -1; } /* odd case, we need to be able return a python method from a tp_getset */ -static PyObject *pyrna_prop_add(BPy_PropertyRNA *self); -static PyMethodDef pyrna_prop_add_meth[] = {{"add", (PyCFunction)pyrna_prop_add, METH_NOARGS, NULL}}; static PyObject *pyrna_prop_add(BPy_PropertyRNA *self) { PointerRNA r_ptr; @@ -1538,9 +1544,6 @@ static PyObject *pyrna_prop_add(BPy_PropertyRNA *self) } } - -static PyObject *pyrna_prop_remove(BPy_PropertyRNA *self, PyObject *value); -static PyMethodDef pyrna_prop_remove_meth[] = {{"remove", (PyCFunction)pyrna_prop_remove, METH_O, NULL}}; static PyObject *pyrna_prop_remove(BPy_PropertyRNA *self, PyObject *value) { PyObject *ret; @@ -1562,52 +1565,15 @@ static PyObject *pyrna_prop_remove(BPy_PropertyRNA *self, PyObject *value) return ret; } -static PyObject *pyrna_prop_get_add_func( BPy_PropertyRNA * self ) -{ - FunctionRNA *func; - - if (RNA_property_type(self->prop) == PROP_COLLECTION) { - func = RNA_property_collection_add_func(self->prop); - if (func==NULL) { - PyErr_SetString( PyExc_TypeError, "this BPy_PropertyRNA collection has no add() function"); - return NULL; - } - - return pyrna_func_to_py((BPy_DummyPointerRNA *)self, func); - } - else { - return PyCFunction_New(pyrna_prop_add_meth, (PyObject *)self); - } -} - -static PyObject *pyrna_prop_get_remove_func( BPy_PropertyRNA * self ) -{ - FunctionRNA *func; - - if (RNA_property_type(self->prop) == PROP_COLLECTION) { - func = RNA_property_collection_remove_func(self->prop); - if (func==NULL) { - PyErr_SetString( PyExc_TypeError, "this BPy_PropertyRNA collection has no add() function"); - return NULL; - } - - return pyrna_func_to_py((BPy_DummyPointerRNA *)self, func); - } - else { - return PyCFunction_New(pyrna_prop_remove_meth, (PyObject *)self); - } -} - /*****************************************************************************/ /* Python attributes get/set structure: */ /*****************************************************************************/ +#if 0 static PyGetSetDef pyrna_prop_getseters[] = { {"active", (getter)pyrna_prop_get_active, (setter)pyrna_prop_set_active, "", NULL}, - /* rna functions */ - {"add", (getter)pyrna_prop_get_add_func, NULL, "", NULL}, - {"remove", (getter)pyrna_prop_get_remove_func, NULL, "", NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; +#endif static PyObject *pyrna_prop_keys(BPy_PropertyRNA *self) { @@ -2009,10 +1975,8 @@ static struct PyMethodDef pyrna_prop_methods[] = { {"get", (PyCFunction)pyrna_prop_get, METH_VARARGS, NULL}, /* moved into a getset */ -#if 0 {"add", (PyCFunction)pyrna_prop_add, METH_NOARGS, NULL}, {"remove", (PyCFunction)pyrna_prop_remove, METH_O, NULL}, -#endif /* array accessor function */ {"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL}, @@ -2490,8 +2454,8 @@ PyTypeObject pyrna_prop_Type = { NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - ( getattrofunc ) NULL, /* getattrofunc tp_getattro; */ - ( setattrofunc ) NULL, /* setattrofunc tp_setattro; */ + ( getattrofunc ) pyrna_prop_getattro, /* getattrofunc tp_getattro; */ + ( setattrofunc ) pyrna_prop_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -2522,7 +2486,7 @@ PyTypeObject pyrna_prop_Type = { /*** Attribute descriptor and subclassing stuff ***/ pyrna_prop_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - pyrna_prop_getseters, /* struct PyGetSetDef *tp_getset; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ |