diff options
author | Joseph Eagar <joeedh@gmail.com> | 2010-01-13 10:26:11 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2010-01-13 10:26:11 +0300 |
commit | 219b472920998d763916c165816191bd8ae1f4a1 (patch) | |
tree | d942c83359abf7cb1f0362afbbd543e3f72e38ee /source/blender/makesrna | |
parent | ed12e1978fec2eed33439f5e342cd84ef443d04e (diff) | |
parent | 3b1585b1722efcf06ef9aa8f9d673047e68a7b9d (diff) |
merge with trunk/2.5 at r25907
Diffstat (limited to 'source/blender/makesrna')
43 files changed, 1564 insertions, 399 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index fc374ff093a..efd42878087 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -52,6 +52,9 @@ extern StructRNA RNA_ActuatorSensor; extern StructRNA RNA_AlwaysSensor; extern StructRNA RNA_AndController; extern StructRNA RNA_AnimData; +extern StructRNA RNA_AnimViz; +extern StructRNA RNA_AnimVizOnionSkinning; +extern StructRNA RNA_AnimVizMotionPaths; extern StructRNA RNA_AnyType; extern StructRNA RNA_Area; extern StructRNA RNA_AreaLamp; @@ -167,6 +170,7 @@ extern StructRNA RNA_Controller; extern StructRNA RNA_CopyLocationConstraint; extern StructRNA RNA_CopyRotationConstraint; extern StructRNA RNA_CopyScaleConstraint; +extern StructRNA RNA_CopyTransformsConstraint; extern StructRNA RNA_Curve; extern StructRNA RNA_CurveMap; extern StructRNA RNA_CurveMapping; @@ -181,6 +185,7 @@ extern StructRNA RNA_DistortedNoiseTexture; extern StructRNA RNA_DomainFluidSettings; extern StructRNA RNA_Driver; extern StructRNA RNA_DriverTarget; +extern StructRNA RNA_DriverVariable; extern StructRNA RNA_DupliObject; extern StructRNA RNA_EdgeSplitModifier; extern StructRNA RNA_EditBone; @@ -303,6 +308,8 @@ extern StructRNA RNA_MirrorModifier; extern StructRNA RNA_Modifier; extern StructRNA RNA_MouseSensor; extern StructRNA RNA_MovieSequence; +extern StructRNA RNA_MotionPath; +extern StructRNA RNA_MotionPathVert; extern StructRNA RNA_MultiresModifier; extern StructRNA RNA_MusgraveTexture; extern StructRNA RNA_NandController; @@ -319,6 +326,7 @@ extern StructRNA RNA_Object; extern StructRNA RNA_ObjectBase; extern StructRNA RNA_ObstacleFluidSettings; extern StructRNA RNA_Operator; +extern StructRNA RNA_Macro; extern StructRNA RNA_OperatorFileListElement; extern StructRNA RNA_OperatorMousePath; extern StructRNA RNA_OperatorProperties; @@ -852,9 +860,9 @@ char *RNA_pointer_as_string(PointerRNA *ptr); /* Function */ const char *RNA_function_identifier(FunctionRNA *func); -PropertyRNA *RNA_function_return(FunctionRNA *func); const char *RNA_function_ui_description(FunctionRNA *func); int RNA_function_flag(FunctionRNA *func); +int RNA_function_defined(FunctionRNA *func); PropertyRNA *RNA_function_get_parameter(PointerRNA *ptr, FunctionRNA *func, int index); PropertyRNA *RNA_function_find_parameter(PointerRNA *ptr, FunctionRNA *func, const char *identifier); diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 37abe44f128..f340834d93b 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -172,6 +172,7 @@ void RNA_def_property_srna(PropertyRNA *prop, const char *type); FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call); FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call); void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret); +void RNA_def_function_return_mark(FunctionRNA *func, PropertyRNA *ret); void RNA_def_function_flag(FunctionRNA *func, int flag); void RNA_def_function_ui_description(FunctionRNA *func, const char *description); diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 90603f98c7a..5ec2320e2dc 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -175,6 +175,10 @@ typedef enum PropertyFlag { /* need context for update function */ PROP_CONTEXT_UPDATE = 1<<22, + /* Use for arrays or for any data that should not have a referene kept + * most common case is functions that return arrays where the array */ + PROP_THICK_WRAP = 1<<23, + /* internal flags */ PROP_BUILTIN = 1<<7, PROP_EXPORT = 1<<8, @@ -206,6 +210,7 @@ typedef struct CollectionPointerLink { } CollectionPointerLink; typedef enum RawPropertyType { + PROP_RAW_UNSET=-1, PROP_RAW_INT, // XXX - abused for types that are not set, eg. MFace.verts, needs fixing. PROP_RAW_SHORT, PROP_RAW_CHAR, @@ -318,6 +323,17 @@ typedef struct ExtensionRNA { void (*free)(void *data); } ExtensionRNA; +/* fake struct definitions, needed otherwise collections end up owning the C + * structs like 'Object' when defined first */ +#define MainCameras Main +#define MainScenes Main +#define MainArmatures Main +#define MainMaterials Main +#define MainMeshes Main +#define MainLamps Main +#define MainObjects Main +#define MainTexts Main + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile index 74427cb1a14..81bc584e460 100644 --- a/source/blender/makesrna/intern/Makefile +++ b/source/blender/makesrna/intern/Makefile @@ -105,6 +105,10 @@ ifeq ($(OS),windows) endif endif +ifeq ($(OS), darwin) + LDFLAGS += -arch $(MACOSX_ARCHITECTURE) #-isysroot $(MACOSX_SDK) -mmacosx-version-min=$(MACOSX_MIN_VERS) +endif + clean:: @$(RM) $(DIR)/makesrna* $(DIR)/rna* @$(RM) $(DIR)/debug/makesrna* $(DIR)/debug/rna* diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 5bdfe228e89..a03903eb652 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1236,16 +1236,21 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA for(; dparm; dparm= dparm->next) { if(dparm->prop->arraydimension) ptrstr= "*"; - else if(dparm->prop==func->ret) + else if(dparm->prop==func->c_ret) ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "*": ""; - else + else if ((dparm->prop->flag & PROP_RETURN)) { + if ((dparm->prop->flag & PROP_THICK_WRAP) && (dparm->prop->type == PROP_STRING)) + ptrstr= ""; + else + ptrstr= ((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR))? "**": "*"; + } else ptrstr= (dparm->prop->type == PROP_POINTER)? "*": ""; - + fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier); } fprintf(f, "\tchar *_data"); - if(func->ret) fprintf(f, ", *_retdata"); + if(func->c_ret) fprintf(f, ", *_retdata"); fprintf(f, ";\n"); fprintf(f, "\t\n"); @@ -1259,7 +1264,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA dparm= dfunc->cont.properties.first; for(; dparm; dparm= dparm->next) { - if(dparm->prop==func->ret) + if ((dparm->prop->flag & PROP_RETURN)) + ptrstr= ""; + else + ptrstr= "*"; + + if(dparm->prop==func->c_ret) fprintf(f, "\t_retdata= _data;\n"); else if(dparm->prop->arraydimension) fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); @@ -1267,10 +1277,14 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if(dparm->prop->flag & PROP_RNAPTR) fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); else - fprintf(f, "\t%s= *((%s%s**)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); + fprintf(f, "\t%s= %s((%s%s**)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); + } + else { + if ((dparm->prop->flag & PROP_THICK_WRAP) && (dparm->prop->type == PROP_STRING)) + fprintf(f, "\t%s= %s((%s%s)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); + else + fprintf(f, "\t%s= %s((%s%s*)_data);\n", dparm->prop->identifier, ptrstr, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); } - else - fprintf(f, "\t%s= *((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); if(dparm->next) fprintf(f, "\t_data+= %d;\n", rna_parameter_size(dparm->prop)); @@ -1279,7 +1293,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if(dfunc->call) { fprintf(f, "\t\n"); fprintf(f, "\t"); - if(func->ret) fprintf(f, "%s= ", func->ret->identifier); + if(func->c_ret) fprintf(f, "%s= ", func->c_ret->identifier); fprintf(f, "%s(", dfunc->call); first= 1; @@ -1303,7 +1317,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA dparm= dfunc->cont.properties.first; for(; dparm; dparm= dparm->next) { - if(dparm->prop==func->ret) + if(dparm->prop==func->c_ret) continue; if(!first) fprintf(f, ", "); @@ -1314,10 +1328,10 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA fprintf(f, ");\n"); - if(func->ret) { - dparm= rna_find_parameter_def(func->ret); + if(func->c_ret) { + dparm= rna_find_parameter_def(func->c_ret); ptrstr= (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag & PROP_RNAPTR)) || (dparm->prop->arraydimension))? "*": ""; - fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->ret->identifier); + fprintf(f, "\t*((%s%s%s*)_retdata)= %s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, func->c_ret->identifier); } } @@ -1552,13 +1566,14 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA PropertyDefRNA *dparm; StructDefRNA *dsrna; int first; + char *ptrstr; dsrna= rna_find_struct_def(srna); func= dfunc->func; /* return type */ for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) { - if(dparm->prop==func->ret) { + if(dparm->prop==func->c_ret) { if(dparm->prop->arraydimension) fprintf(f, "XXX no array return types yet"); /* XXX not supported */ else if(dparm->prop->type == PROP_POINTER && !(dparm->prop->flag & PROP_RNAPTR)) @@ -1600,18 +1615,25 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA /* defined parameters */ for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) { - if(dparm->prop==func->ret) + if(dparm->prop==func->c_ret) continue; if(!first) fprintf(f, ", "); first= 0; + if((dparm->prop->type == PROP_STRING && dparm->prop->flag & PROP_THICK_WRAP)) + ptrstr= ""; + else if(dparm->prop->flag & PROP_RETURN) + ptrstr= "*"; + else + ptrstr= ""; + if(dparm->prop->arraydimension) fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->totarraylength); else if(dparm->prop->type == PROP_POINTER) - fprintf(f, "%s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); + fprintf(f, "%s%s *%s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), (dparm->prop->flag & PROP_RNAPTR) ? "" : ptrstr, dparm->prop->identifier); else - fprintf(f, "%s%s %s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); + fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), ptrstr, dparm->prop->identifier); } fprintf(f, ");\n"); @@ -1766,7 +1788,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr fprintf(f, "\t%s%s, %d, %s, %s,\n", (prop->flag & PROP_CONTEXT_UPDATE)? "(UpdateFunc)": "", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable), rna_function_string(prop->itemeditable)); if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop); - else fprintf(f, "\t0, 0"); + else fprintf(f, "\t0, -1"); /* our own type - collections/arrays only */ if(prop->srna) fprintf(f, ", &RNA_%s", (char*)prop->srna); @@ -1890,8 +1912,8 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) dfunc= rna_find_function_def(func); if(dfunc->gencall) fprintf(f, "\t%s,\n", dfunc->gencall); else fprintf(f, "\tNULL,\n"); - - if(func->ret) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->ret->identifier); + + if(func->c_ret) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->c_ret->identifier); else fprintf(f, "\tNULL\n"); fprintf(f, "};\n"); @@ -1983,6 +2005,7 @@ RNAProcessItem PROCESS_ITEMS[]= { {"rna_texture.c", NULL, RNA_def_texture}, {"rna_action.c", "rna_action_api.c", RNA_def_action}, {"rna_animation.c", "rna_animation_api.c", RNA_def_animation}, + {"rna_animviz.c", NULL, RNA_def_animviz}, {"rna_actuator.c", NULL, RNA_def_actuator}, {"rna_armature.c", "rna_armature_api.c", RNA_def_armature}, {"rna_boid.c", NULL, RNA_def_boid}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index a250f0a49b4..ac354366c25 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -93,6 +93,18 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value) test_idbutton(id->name+2); } +static int rna_ID_name_editable(PointerRNA *ptr) +{ + ID *id= (ID*)ptr->data; + + if (GS(id->name) == ID_VF) { + if (strcmp(id->name+2, "<builtin>")==0) + return 0; + } + + return 1; +} + short RNA_type_to_ID_code(StructRNA *type) { if(RNA_struct_is_a(type, &RNA_Action)) return ID_AC; @@ -365,6 +377,7 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name."); RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set"); RNA_def_property_string_maxlength(prop, sizeof(((ID*)NULL)->name)-2); + RNA_def_property_editable_func(prop, "rna_ID_name_editable"); RNA_def_property_update(prop, NC_ID|NA_RENAME, NULL); RNA_def_struct_name_property(srna, prop); @@ -380,6 +393,7 @@ static void rna_def_ID(BlenderRNA *brna) prop= RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_DOIT); + RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_ui_text(prop, "Tag", "Tools can use this to tag data, (initial state is undefined)."); prop= RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9cc08b297e5..6932d775da7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -249,7 +249,7 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop) { if(prop->magic == RNA_MAGIC) { int arraylen[RNA_MAX_ARRAY_DIMENSION]; - return (prop->getlength)? prop->getlength(ptr, arraylen): prop->totarraylength; + return (prop->getlength && ptr->data)? prop->getlength(ptr, arraylen): prop->totarraylength; } else { IDProperty *idprop= (IDProperty*)prop; @@ -1060,7 +1060,9 @@ int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) id= ptr->id.data; - return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + /* with this, libdata is not animated by its own library fcurves, FIXME */ +// return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + return (flag & PROP_EDITABLE) ? 1:0; } /* same as RNA_property_editable(), except this checks individual items in an array */ @@ -1079,8 +1081,9 @@ int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) flag= prop->itemeditable(ptr, index); id= ptr->id.data; - - return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + /* with this, libdata is not animated by its own library fcurves, FIXME */ +// return (flag & PROP_EDITABLE) && (!id || !id->lib || (flag & PROP_LIB_EXCEPTION)); + return (flag & PROP_EDITABLE) ? 1:0; } int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) @@ -2021,7 +2024,7 @@ int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) if(key+1 < len) { /* move element to be removed to the back */ memcpy(&tmp, &array[key], sizeof(IDProperty)); - memmove(array+key, array+key+1, sizeof(IDProperty)*(len-key+1)); + memmove(array+key, array+key+1, sizeof(IDProperty)*(len-(key+1))); memcpy(&array[len-1], &tmp, sizeof(IDProperty)); } @@ -2266,8 +2269,9 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro /* try to access as raw array */ if(RNA_property_collection_raw_array(ptr, prop, itemprop, &out)) { - if(in.len != itemlen*out.len) { - BKE_reportf(reports, RPT_ERROR, "Array length mismatch (expected %d, got %d).", out.len*itemlen, in.len); + int arraylen = (itemlen == 0) ? 1 : itemlen; + if(in.len != arraylen*out.len) { + BKE_reportf(reports, RPT_ERROR, "Array length mismatch (expected %d, got %d).", out.len*arraylen, in.len); return 0; } @@ -2277,8 +2281,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro void *outp= out.array; int a, size; - itemlen= (itemlen == 0)? 1: itemlen; - size= RNA_raw_type_sizeof(out.type) * itemlen; + size= RNA_raw_type_sizeof(out.type) * arraylen; for(a=0; a<out.len; a++) { if(set) memcpy(outp, inp, size); @@ -2300,6 +2303,12 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro void *tmparray= NULL; int tmplen= 0; int err= 0, j, a= 0; + int needconv = 1; + + if (((itemtype == PROP_BOOLEAN || itemtype == PROP_INT) && in.type == PROP_RAW_INT) || + (itemtype == PROP_FLOAT && in.type == PROP_RAW_FLOAT)) + /* avoid creating temporary buffer if the data type match */ + needconv = 0; /* no item property pointer, can still be id property, or * property of a type derived from the collection pointer type */ @@ -2387,7 +2396,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro } a++; } - else { + else if (needconv == 1) { /* allocate temporary array if needed */ if(tmparray && tmplen != itemlen) { MEM_freeN(tmparray); @@ -2448,6 +2457,50 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro } } } + else { + if(set) { + switch(itemtype) { + case PROP_BOOLEAN: { + RNA_property_boolean_set_array(&itemptr, iprop, &((int*)in.array)[a]); + a += itemlen; + break; + } + case PROP_INT: { + RNA_property_int_set_array(&itemptr, iprop, &((int*)in.array)[a]); + a += itemlen; + break; + } + case PROP_FLOAT: { + RNA_property_float_set_array(&itemptr, iprop, &((float*)in.array)[a]); + a += itemlen; + break; + } + default: + break; + } + } + else { + switch(itemtype) { + case PROP_BOOLEAN: { + RNA_property_boolean_get_array(&itemptr, iprop, &((int*)in.array)[a]); + a += itemlen; + break; + } + case PROP_INT: { + RNA_property_int_get_array(&itemptr, iprop, &((int*)in.array)[a]); + a += itemlen; + break; + } + case PROP_FLOAT: { + RNA_property_float_get_array(&itemptr, iprop, &((float*)in.array)[a]); + a += itemlen; + break; + } + default: + break; + } + } + } } } } @@ -2462,6 +2515,21 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro RawPropertyType RNA_property_raw_type(PropertyRNA *prop) { + if (prop->rawtype == PROP_RAW_UNSET) { + /* this property has no raw access, yet we try to provide a raw type to help building the array */ + switch (prop->type) { + case PROP_BOOLEAN: + return PROP_RAW_INT; + case PROP_INT: + return PROP_RAW_INT; + case PROP_FLOAT: + return PROP_RAW_FLOAT; + case PROP_ENUM: + return PROP_RAW_INT; + default: + break; + } + } return prop->rawtype; } @@ -3464,11 +3532,6 @@ const char *RNA_function_identifier(FunctionRNA *func) return func->identifier; } -PropertyRNA *RNA_function_return(FunctionRNA *func) -{ - return func->ret; -} - const char *RNA_function_ui_description(FunctionRNA *func) { return func->description; @@ -3479,6 +3542,11 @@ int RNA_function_flag(FunctionRNA *func) return func->flag; } +int RNA_function_defined(FunctionRNA *func) +{ + return func->call != NULL; +} + PropertyRNA *RNA_function_get_parameter(PointerRNA *ptr, FunctionRNA *func, int index) { PropertyRNA *parm; @@ -3924,7 +3992,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt tid= RNA_struct_identifier(ptr->type); fid= RNA_function_identifier(func); - pret= RNA_function_return(func); + pret= func->c_ret; flen= strlen(format); RNA_parameter_list_create(&parms, ptr, func); @@ -3932,14 +4000,17 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt for(i= 0, ofs= 0; iter.valid; RNA_parameter_list_next(&iter), i++) { parm= iter.parm; + flag= RNA_property_flag(parm); if(parm==pret) { retdata= iter.data; continue; } + else if (flag & PROP_RETURN) { + continue; + } pid= RNA_property_identifier(parm); - flag= RNA_property_flag(parm); if (ofs>=flen || format[ofs]=='N') { if (flag & PROP_REQUIRED) { diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 3f6729136d5..b9c5661b771 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -88,16 +88,22 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop= RNA_def_property(srna, "display_summary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY); - RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line."); + RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line. (DopeSheet Editors only)"); RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); prop= RNA_def_property(srna, "display_shapekeys", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS); - RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of Shapekey related Animation data."); + RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of ShapeKey related Animation data."); RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); + prop= RNA_def_property(srna, "display_mesh", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH); + RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of Mesh related Animation data."); + RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); + RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); + prop= RNA_def_property(srna, "display_camera", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM); RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data."); @@ -166,7 +172,7 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop= RNA_def_property(srna, "collapse_summary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED); - RNA_def_property_ui_text(prop, "Collapse Summary", "Collapse summary when shown, so all other channels get hidden. (DopeSheet Window Editors Only)"); + RNA_def_property_ui_text(prop, "Collapse Summary", "Collapse summary when shown, so all other channels get hidden. (DopeSheet Editors Only)"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 0f36ebda70e..22b16c13630 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -647,6 +647,7 @@ static void rna_def_edit_bone(BlenderRNA *brna) //RNA_def_property_float_sdna(prop, NULL, ""); // doesnt access any real data RNA_def_property_array(prop, 16); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_THICK_WRAP); /* no reference to original data */ RNA_def_property_ui_text(prop, "Editbone Matrix", "Read-only matrix calculated from the roll (armature space)."); RNA_def_property_float_funcs(prop, "rna_EditBone_matrix_get", NULL, NULL); // TODO - this could be made writable also diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c index 22bd7313166..f3983a43b4f 100644 --- a/source/blender/makesrna/intern/rna_armature_api.c +++ b/source/blender/makesrna/intern/rna_armature_api.c @@ -58,7 +58,7 @@ void RNA_api_armature_edit_bone(StructRNA *srna) PropertyRNA *parm; func= RNA_def_function(srna, "align_roll", "rna_EditBone_align_roll"); - RNA_def_function_ui_description(func, "Align the bone to a localspace vector."); + RNA_def_function_ui_description(func, "Align the bone to a localspace roll so the Z axis points in the direction of the vector given."); parm= RNA_def_float_vector(func, "vector", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); } diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 7f7126c659a..8f8dd4681ab 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -33,6 +33,7 @@ #include "DNA_texture_types.h" #include "IMB_imbuf.h" +#include "WM_types.h" EnumPropertyItem brush_sculpt_tool_items[] = { {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, @@ -52,29 +53,6 @@ EnumPropertyItem brush_sculpt_tool_items[] = { #include "BKE_texture.h" #include "WM_api.h" -#include "WM_types.h" - -static void rna_Brush_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Brush *brush= (Brush*)ptr->data; - rna_iterator_array_begin(iter, (void*)brush->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL); -} - -static PointerRNA rna_Brush_active_texture_get(PointerRNA *ptr) -{ - Brush *br= (Brush*)ptr->data; - Tex *tex; - - tex= give_current_brush_texture(br); - return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex); -} - -static void rna_Brush_active_texture_set(PointerRNA *ptr, PointerRNA value) -{ - Brush *br= (Brush*)ptr->data; - - set_current_brush_texture(br, value.data); -} static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr) { @@ -291,8 +269,17 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Brush_update"); /* texture */ - rna_def_mtex_common(srna, "rna_Brush_mtex_begin", "rna_Brush_active_texture_get", - "rna_Brush_active_texture_set", "BrushTextureSlot", "rna_Brush_update"); + prop= RNA_def_property(srna, "texture_slot", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "BrushTextureSlot"); + RNA_def_property_pointer_sdna(prop, NULL, "mtex"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Texture Slot", ""); + + prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Texture", ""); + RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_update"); /* clone tool */ prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index f9405dec531..5ec8d438c42 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -43,6 +43,7 @@ EnumPropertyItem constraint_type_items[] ={ {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", ICON_CONSTRAINT_DATA, "Copy Location", ""}, {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", ICON_CONSTRAINT_DATA, "Copy Rotation", ""}, {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", ICON_CONSTRAINT_DATA, "Copy Scale", ""}, + {CONSTRAINT_TYPE_TRANSLIKE, "COPY_TRANSFORMS", ICON_CONSTRAINT_DATA, "Copy Transforms", ""}, {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", ICON_CONSTRAINT_DATA, "Limit Distance", ""}, {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT_DATA, "Limit Location", ""}, {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT_DATA, "Limit Rotation", ""}, @@ -151,6 +152,8 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) return &RNA_DampedTrackConstraint; case CONSTRAINT_TYPE_SPLINEIK: return &RNA_SplineIKConstraint; + case CONSTRAINT_TYPE_TRANSLIKE: + return &RNA_CopyTransformsConstraint; default: return &RNA_UnknownType; } @@ -647,6 +650,69 @@ static void rna_def_constraint_track_to(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } +static void rna_def_constraint_locate_like(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "CopyLocationConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copies the location of the target."); + + prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, "bConstraint", "headtail"); + RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + RNA_def_struct_sdna_from(srna, "bLocateLikeConstraint", "data"); + + prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "tar"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "subtarget"); + RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + prop= RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X); + RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y); + RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z); + RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "invert_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X_INVERT); + RNA_def_property_ui_text(prop, "Invert X", "Invert the X location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "invert_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y_INVERT); + RNA_def_property_ui_text(prop, "Invert Y", "Invert the Y location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z_INVERT); + RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + prop= RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_OFFSET); + RNA_def_property_ui_text(prop, "Offset", "Add original location into copied location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); +} + static void rna_def_constraint_rotate_like(BlenderRNA *brna) { StructRNA *srna; @@ -703,20 +769,14 @@ static void rna_def_constraint_rotate_like(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } -static void rna_def_constraint_locate_like(BlenderRNA *brna) +static void rna_def_constraint_size_like(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "CopyLocationConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copies the location of the target."); - - prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, "bConstraint", "headtail"); - RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - - RNA_def_struct_sdna_from(srna, "bLocateLikeConstraint", "data"); + srna= RNA_def_struct(brna, "CopyScaleConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Copy Scale Constraint", "Copies the scale of the target."); + RNA_def_struct_sdna_from(srna, "bSizeLikeConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); @@ -731,39 +791,50 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X); - RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X location."); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_X); + RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X scale."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y); - RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y location."); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Y); + RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y scale."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z); - RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z location."); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Z); + RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z scale."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "invert_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X_INVERT); - RNA_def_property_ui_text(prop, "Invert X", "Invert the X location."); + prop= RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_OFFSET); + RNA_def_property_ui_text(prop, "Offset", "Add original scale into copied scale."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); +} - prop= RNA_def_property(srna, "invert_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y_INVERT); - RNA_def_property_ui_text(prop, "Invert Y", "Invert the Y location."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); +static void rna_def_constraint_transform_like(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; - prop= RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z_INVERT); - RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z location."); + srna= RNA_def_struct(brna, "CopyTransformsConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Copy Transforms Constraint", "Copies all the transforms of the target."); + RNA_def_struct_sdna_from(srna, "bTransLikeConstraint", "data"); + + prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, "bConstraint", "headtail"); + RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_OFFSET); - RNA_def_property_ui_text(prop, "Offset", "Add original location into copied location."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "tar"); + RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + + prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "subtarget"); + RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); } static void rna_def_constraint_minmax(BlenderRNA *brna) @@ -817,48 +888,6 @@ static void rna_def_constraint_minmax(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } -static void rna_def_constraint_size_like(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna= RNA_def_struct(brna, "CopyScaleConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Copy Scale Constraint", "Copies the scale of the target."); - RNA_def_struct_sdna_from(srna, "bSizeLikeConstraint", "data"); - - prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Target", "Target Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - - prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "subtarget"); - RNA_def_property_ui_text(prop, "Sub-Target", ""); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); - - prop= RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_X); - RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X scale."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - - prop= RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Y); - RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y scale."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - - prop= RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Z); - RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z scale."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - - prop= RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_OFFSET); - RNA_def_property_ui_text(prop, "Offset", "Add original scale into copied scale."); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); -} - static void rna_def_constraint_action(BlenderRNA *brna) { StructRNA *srna; @@ -1869,6 +1898,7 @@ void RNA_def_constraint(BlenderRNA *brna) rna_def_constraint_size_like(brna); rna_def_constraint_locate_like(brna); rna_def_constraint_rotate_like(brna); + rna_def_constraint_transform_like(brna); rna_def_constraint_minmax(brna); rna_def_constraint_track_to(brna); rna_def_constraint_kinematic(brna); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index d3a56661813..98c2963a110 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -73,7 +73,7 @@ static StructRNA *rna_Curve_refine(PointerRNA *ptr) { Curve *cu= (Curve*)ptr->data; short obtype= curve_type(cu); - + if(obtype == OB_FONT) return &RNA_TextCurve; else if(obtype == OB_SURF) return &RNA_SurfaceCurve; else return &RNA_Curve; @@ -634,6 +634,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "vfont"); RNA_def_property_ui_text(prop, "Font", ""); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 9bf5afdac48..ed10c0819fd 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -931,6 +931,8 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier prop->subtype= subtype; prop->name= identifier; prop->description= ""; + /* a priori not raw editable */ + prop->rawtype = -1; if(type != PROP_COLLECTION && type != PROP_POINTER) { prop->flag= PROP_EDITABLE; @@ -2417,9 +2419,16 @@ FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, C return func; } +/* C return value only!, multiple rna returns can be done with RNA_def_function_return_mark */ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret) { - func->ret= ret; + func->c_ret= ret; + + RNA_def_function_return_mark(func, ret); +} + +void RNA_def_function_return_mark(FunctionRNA *func, PropertyRNA *ret) +{ ret->flag|=PROP_RETURN; } @@ -2461,7 +2470,12 @@ int rna_parameter_size(PropertyRNA *parm) case PROP_FLOAT: return sizeof(float); case PROP_STRING: - return sizeof(char *); + /* return valyes dont store a pointer to the original */ + if(parm->flag & PROP_THICK_WRAP) { + StringPropertyRNA *sparm= (StringPropertyRNA*)parm; + return sizeof(char) * sparm->maxlength; + } else + return sizeof(char *); case PROP_POINTER: { #ifdef RNA_RUNTIME if(parm->flag & PROP_RNAPTR) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 62ee19df352..b6b05eb4896 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -116,10 +116,12 @@ static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA * AnimData *adt= BKE_animdata_from_id(ptr->id.data); /* find the driver this belongs to and update it */ - for(fcu=adt->drivers.first; fcu; fcu=fcu->next) { + for (fcu=adt->drivers.first; fcu; fcu=fcu->next) { driver= fcu->driver; - - if(driver && BLI_findindex(&driver->targets, ptr->data) != -1) { + + if (driver) { + // FIXME: need to be able to search targets for required one... + //BLI_findindex(&driver->targets, ptr->data) != -1) RNA_pointer_create(ptr->id.data, &RNA_Driver, driver, &driverptr); rna_ChannelDriver_update_data(bmain, scene, &driverptr); return; @@ -127,6 +129,15 @@ static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA * } } +static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ChannelDriver *driver= ptr->data; + rna_DriverTarget_update_data(bmain, scene, ptr); + + driver->flag |= DRIVER_FLAG_RENAMEVAR; + +} + /* ----------- */ static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr) @@ -185,6 +196,14 @@ static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value) dtar->rna_path= NULL; } +static void rna_DriverVariable_type_set(PointerRNA *ptr, int value) +{ + DriverVar *dvar= (DriverVar *)ptr->data; + + /* call the API function for this */ + driver_change_variable_type(dvar, value); +} + /* ****************************** */ static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value) @@ -220,15 +239,16 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value) fcu->rna_path= NULL; } -DriverTarget *rna_Driver_new_target(ChannelDriver *driver) +DriverVar *rna_Driver_new_variable(ChannelDriver *driver) { - return driver_add_new_target(driver); + /* call the API function for this */ + return driver_add_new_variable(driver); } -void rna_Driver_remove_target(ChannelDriver *driver, DriverTarget *dtar) +void rna_Driver_remove_variable(ChannelDriver *driver, DriverVar *dvar) { /* call the API function for this */ - driver_free_target(driver, dtar); + driver_free_variable(driver, dvar); } @@ -676,14 +696,20 @@ static void rna_def_drivertarget(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "DriverTarget", NULL); - RNA_def_struct_ui_text(srna, "Driver Target", "Variable from some source/target for driver relationship."); + static EnumPropertyItem prop_trans_chan_items[] = { + {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""}, + {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""}, + {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""}, + {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""}, + {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""}, + {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""}, + {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""}, + {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""}, + {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""}, + {0, NULL, 0, NULL, NULL}}; - /* Variable Name */ - prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_ui_text(prop, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)"); - RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); + srna= RNA_def_struct(brna, "DriverTarget", NULL); + RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables."); /* Target Properties - ID-block to Drive */ prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); @@ -698,6 +724,7 @@ static void rna_def_drivertarget(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "idtype"); RNA_def_property_enum_items(prop, id_type_items); RNA_def_property_enum_default(prop, ID_OB); + // XXX need to add an 'editable func' for this, in the case where certain flags are set already... RNA_def_property_enum_funcs(prop, NULL, "rna_DriverTarget_id_type_set", NULL); RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used."); RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); @@ -705,44 +732,93 @@ static void rna_def_drivertarget(BlenderRNA *brna) /* Target Properties - Property to Drive */ prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_DriverTarget_RnaPath_get", "rna_DriverTarget_RnaPath_length", "rna_DriverTarget_RnaPath_set"); - RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from Object) to property used"); + RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used."); RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); - prop= RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific property used (if applicable)"); + prop= RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "pchan_name"); + RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target."); RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); + + prop= RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "transChan"); + RNA_def_property_enum_items(prop, prop_trans_chan_items); + RNA_def_property_ui_text(prop, "Type", "Driver variable type."); + RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); + + prop= RNA_def_property(srna, "use_local_space_transforms", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", DTAR_FLAG_LOCALSPACE); + RNA_def_property_ui_text(prop, "Local Space", "Use transforms in Local Space (as opposed to the worldspace default)."); + RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); +} + +static void rna_def_drivervar(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_type_items[] = { + {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", 0, "Single Property", "Use the value from some RNA property (Default)"}, + {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", 0, "Transform Channel", "Final transformation value of object or bone"}, + {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", 0, "Rotational Difference", "Use the angle between two bones"}, + {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", 0, "Distance", "Distance between two bones or objects"}, + {0, NULL, 0, NULL, NULL}}; + + + srna= RNA_def_struct(brna, "DriverVariable", NULL); + RNA_def_struct_sdna(srna, "DriverVar"); + RNA_def_struct_ui_text(srna, "Driver Variable", "Variable from some source/target for driver relationship."); + + /* Variable Name */ + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_ui_text(prop, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)"); + RNA_def_property_update(prop, 0, "rna_DriverTarget_update_name"); // XXX + + /* Enums */ + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_DriverVariable_type_set", NULL); + RNA_def_property_ui_text(prop, "Type", "Driver variable type."); + RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX + + /* Targets */ + // TODO: for nicer api, only expose the relevant props via subclassing, instead of exposing the collection of targets + prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets"); + RNA_def_property_struct_type(prop, "DriverTarget"); + RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable."); } -/* channeldriver.targets.* */ -static void rna_def_channeldriver_targets(BlenderRNA *brna, PropertyRNA *cprop) +/* channeldriver.variables.* */ +static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; // PropertyRNA *prop; - + FunctionRNA *func; PropertyRNA *parm; - - RNA_def_property_srna(cprop, "ChannelDriverTargets"); - srna= RNA_def_struct(brna, "ChannelDriverTargets", NULL); + + RNA_def_property_srna(cprop, "ChannelDriverVariables"); + srna= RNA_def_struct(brna, "ChannelDriverVariables", NULL); RNA_def_struct_sdna(srna, "ChannelDriver"); - RNA_def_struct_ui_text(srna, "ChannelDriver Targets", "Collection of channel driver Targets."); - - - /* add target */ - func= RNA_def_function(srna, "new", "rna_Driver_new_target"); - RNA_def_function_ui_description(func, "Add a new target for the driver."); + RNA_def_struct_ui_text(srna, "ChannelDriver Variables", "Collection of channel driver Variables."); + + + /* add variable */ + func= RNA_def_function(srna, "new", "rna_Driver_new_variable"); + RNA_def_function_ui_description(func, "Add a new variable for the driver."); /* return type */ - parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Newly created Driver Target."); + parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable."); RNA_def_function_return(func, parm); - /* 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."); + /* remove variable */ + func= RNA_def_function(srna, "remove", "rna_Driver_remove_variable"); + RNA_def_function_ui_description(func, "Remove an existing variable from the driver."); + /* target to remove */ + parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Variable to remove from the driver."); RNA_def_property_flag(parm, PROP_REQUIRED); - } static void rna_def_channeldriver(BlenderRNA *brna) @@ -754,7 +830,8 @@ static void rna_def_channeldriver(BlenderRNA *brna) {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""}, {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""}, {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""}, - {DRIVER_TYPE_ROTDIFF, "ROTDIFF", 0, "Rotational Difference", ""}, + {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""}, + {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Driver", NULL); @@ -764,7 +841,7 @@ static void rna_def_channeldriver(BlenderRNA *brna) /* Enums */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Type", "Driver types."); + RNA_def_property_ui_text(prop, "Type", "Driver type."); RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); /* String values */ @@ -773,11 +850,11 @@ static void rna_def_channeldriver(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr"); /* Collections */ - prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "targets", NULL); - 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); + prop= RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "variables", NULL); + RNA_def_property_struct_type(prop, "DriverVariable"); + RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver."); + rna_def_channeldriver_variables(brna, prop); /* Functions */ RNA_api_drivers(srna); @@ -933,6 +1010,7 @@ void RNA_def_fcurve(BlenderRNA *brna) rna_def_fpoint(brna); rna_def_drivertarget(brna); + rna_def_drivervar(brna); rna_def_channeldriver(brna); rna_def_fmodifier(brna); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 129fad4e98c..30591efc481 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -199,6 +199,10 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_LOCKED); RNA_def_property_ui_text(prop, "Locked", "Layer is protected from further editing and/or frame changes."); + prop= RNA_def_property(srna, "frame_lock", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK); + RNA_def_property_ui_text(prop, "Frame Locked", "Current frame displayed by layer cannot be changed."); + prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE); RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencilLayer_active_set"); @@ -220,6 +224,13 @@ static void rna_def_gpencil_data(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem draw_mode_items[] = { + {GP_DATA_VIEWALIGN, "CURSOR", 0, "Cursor", ""}, + {0, "VIEW", 0, "View", ""}, /* weired, GP_DATA_VIEWALIGN is inverted */ + {GP_DATA_VIEWALIGN|GP_DATA_DEPTH_VIEW, "SURFACE", 0, "Surface", ""}, + {GP_DATA_VIEWALIGN|GP_DATA_DEPTH_STROKE, "STROKE", 0, "Stroke", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "GreasePencil", "ID"); RNA_def_struct_sdna(srna, "bGPdata"); RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook."); @@ -232,9 +243,16 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Layers", "Similar to layers in Photoshop."); /* Flags */ - prop= RNA_def_property(srna, "view_space_draw", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_DATA_VIEWALIGN); - RNA_def_property_ui_text(prop, "Stick to View", "Newly drawn strokes get added in view space (i.e. sketches stick to data when view is manipulated)."); + prop= RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, draw_mode_items); + RNA_def_property_ui_text(prop, "Draw Mode", ""); + + prop= RNA_def_property(srna, "use_stroke_endpoints", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_DEPTH_STROKE_ENDPOINTS); + RNA_def_property_ui_text(prop, "Only Endpoints", "When snapping the stroke to existing lines, only use the first and last parts of the line."); + + } /* --- */ diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index e0d8a6950de..c4d7e772c58 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -153,6 +153,26 @@ static int rna_Image_has_data_get(PointerRNA *ptr) return 0; } +static void rna_Image_size_get(PointerRNA *ptr,int *values) +{ + Image *im= (Image*)ptr->data; + ImBuf *ibuf; + void *lock; + + ibuf = BKE_image_acquire_ibuf(im, NULL , &lock); + if (ibuf) { + values[0]= ibuf->x; + values[1]= ibuf->y; + } + else { + values[0]= 0; + values[1]= 0; + } + + BKE_image_release_ibuf(im, lock); +} + + static int rna_Image_depth_get(PointerRNA *ptr) { Image *im= (Image*)ptr->data; @@ -401,6 +421,10 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Depth", "Image bit depth."); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop= RNA_def_int_vector(srna, "size" , 2 , NULL , 0, 0, "Size" , "Width and height in pixels, zero when image data cant be loaded." , 0 , 0); + RNA_def_property_int_funcs(prop, "rna_Image_size_get" , NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_api_image(srna); } diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 4ac6b98b167..3a978196a29 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -63,6 +63,35 @@ static char *rna_Image_get_export_path(Image *image, char *dest_dir, int rel) return path; } +static void rna_Image_save(Image *image, bContext *C, ReportList *reports, char *path, Scene *scene) +{ + ImBuf *ibuf; + + if (scene == NULL) { + scene = CTX_data_scene(C); + } + + if (scene) { + ImageUser iuser; + void *lock; + + iuser.scene = scene; + iuser.ok = 1; + + ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock); + + if (ibuf == NULL) { + BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image"); + } + + if (!BKE_write_ibuf(NULL, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) { + BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); + } + } else { + BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters"); + } +} + char *rna_Image_get_abs_filename(Image *image, bContext *C) { char *filename= MEM_callocN(FILE_MAX, "Image.get_abs_filename()"); @@ -95,6 +124,13 @@ void RNA_api_image(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_string_file_path(func, "abs_filename", NULL, 0, "", "Image/movie absolute filename."); RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "save", "rna_Image_save"); + RNA_def_function_ui_description(func, "Save image to a specific path."); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + parm= RNA_def_string(func, "path", "", 0, "", "Save path."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to take image parameters from."); } #endif diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 5bb3c82395d..3d18804036a 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -118,6 +118,7 @@ extern BlenderRNA BLENDER_RNA; void RNA_def_ID(struct BlenderRNA *brna); void RNA_def_action(struct BlenderRNA *brna); void RNA_def_animation(struct BlenderRNA *brna); +void RNA_def_animviz(struct BlenderRNA *brna); void RNA_def_armature(struct BlenderRNA *brna); void RNA_def_actuator(struct BlenderRNA *brna); void RNA_def_boid(struct BlenderRNA *brna); @@ -175,6 +176,9 @@ void RNA_def_world(struct BlenderRNA *brna); void rna_def_animdata_common(struct StructRNA *srna); +void rna_def_animviz_common(struct StructRNA *srna); +void rna_def_motionpath_common(struct StructRNA *srna); + void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable); void rna_def_mtex_common(struct StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname, const char *update); void rna_def_render_layer_common(struct StructRNA *srna, int scene); @@ -211,6 +215,7 @@ void RNA_api_armature_edit_bone(StructRNA *srna); void RNA_api_drivers(StructRNA *srna); void RNA_api_image(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); +void RNA_api_macro(struct StructRNA *srna); void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); void RNA_api_keymap(struct StructRNA *srna); @@ -220,11 +225,39 @@ 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_scene(struct StructRNA *srna); +void RNA_api_scene_render(struct StructRNA *srna); void RNA_api_text(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); +/* main collection functions */ +void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop); + /* ID Properties */ extern StringPropertyRNA rna_IDProperty_string; diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 4f05e6132f7..bef568bfa7d 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -118,8 +118,9 @@ struct FunctionRNA { /* callback to execute the function */ CallFunc call; - /* parameter for the return value */ - PropertyRNA *ret; + /* parameter for the return value + * note: this is only the C return value, rna functions can have multiple return values */ + PropertyRNA *c_ret; }; struct PropertyRNA { diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 9e560a50af0..6ff961070b9 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -283,7 +283,13 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter) static char *rna_ShapeKey_path(PointerRNA *ptr) { - return BLI_sprintfN("keys[\"%s\"]", ((KeyBlock*)ptr->data)->name); + KeyBlock *kb= (KeyBlock *)ptr->data; + ID *id= ptr->id.data; + + if ((id) && (GS(id->name) != ID_KE)) + return BLI_sprintfN("shape_keys.keys[\"%s\"]", kb->name); + else + return BLI_sprintfN("keys[\"%s\"]", kb->name); } static void rna_Key_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 82988a06af9..b47a2d5c907 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -235,40 +235,54 @@ static PointerRNA rna_Test_test_get(PointerRNA *ptr) #else +/* local convenience types */ +typedef void (CollectionDefFunc)(struct BlenderRNA *brna, struct PropertyRNA *cprop); + +typedef struct MainCollectionDef { + const char *identifier; + const char *type; + const char *iter_begin; + const char *name; + const char *description; + CollectionDefFunc *func; +} MainCollectionDef; + void RNA_def_main(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + CollectionDefFunc *func; + + MainCollectionDef lists[]= { + {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", RNA_def_main_cameras}, + {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", RNA_def_main_scenes}, + {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", RNA_def_main_objects}, + {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", RNA_def_main_materials}, + {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", RNA_def_main_node_groups}, + {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", RNA_def_main_meshes}, + {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", RNA_def_main_lamps}, + {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", RNA_def_main_libraries}, + {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks.", RNA_def_main_screens}, + {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks.", RNA_def_main_window_managers}, + {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks.", RNA_def_main_images}, + {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", RNA_def_main_lattices}, + {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", RNA_def_main_curves} , + {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", RNA_def_main_metaballs}, + {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", RNA_def_main_vfonts}, + {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", RNA_def_main_textures}, + {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", RNA_def_main_brushes}, + {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", RNA_def_main_worlds}, + {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks.", RNA_def_main_groups}, +/* {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks.", NULL}, */ + {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED).", NULL}, + {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks.", RNA_def_main_texts}, + {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks.", RNA_def_main_sounds}, + {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks.", RNA_def_main_armatures}, + {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks.", RNA_def_main_actions}, + {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks.", RNA_def_main_particles}, + {"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks.", RNA_def_main_gpencil}, + {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); @@ -281,12 +295,17 @@ void RNA_def_main(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file."); - for(i=0; lists[i][0]; i++) + for(i=0; lists[i].name; i++) { - 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); - RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); + prop= RNA_def_property(srna, lists[i].identifier, PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, lists[i].type); + RNA_def_property_collection_funcs(prop, lists[i].iter_begin, "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); + RNA_def_property_ui_text(prop, lists[i].name, lists[i].description); + + /* collection functions */ + func= lists[i].func; + if(func) + func(brna, prop); } RNA_api_main(srna); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 180c088b091..395a56b6e3e 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -33,6 +33,8 @@ #include "RNA_types.h" #include "RNA_enum_types.h" +#include "BKE_utildefines.h" + #ifdef RNA_RUNTIME #include "BKE_main.h" @@ -43,108 +45,173 @@ #include "BKE_material.h" #include "BKE_image.h" #include "BKE_texture.h" +#include "BKE_scene.h" +#include "BKE_text.h" #include "DNA_armature_types.h" +#include "DNA_camera_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_text_types.h" + +#include "ED_screen.h" -static Mesh *rna_Main_add_mesh(Main *bmain, char *name) +Tex *rna_Main_add_texture(Main *bmain, char *name) { - Mesh *me= add_mesh(name); - me->id.us--; - return me; + return add_texture(name); } -static void rna_Main_remove_mesh(Main *bmain, ReportList *reports, Mesh *me) +/* TODO: remove texture? */ + +Image *rna_Main_add_image(Main *bmain, char *filename) { - if(me->id.us == 0) - free_libblock(&bmain->mesh, me); - else - BKE_report(reports, RPT_ERROR, "Mesh must have zero users to be removed."); - - /* XXX python now has invalid pointer? */ + return BKE_add_image_file(filename, 0); } -static void rna_Main_remove_armature(Main *bmain, ReportList *reports, bArmature *arm) +Camera *rna_Main_cameras_new(Main *bmain, char* name) { - if(arm->id.us == 0) - free_libblock(&bmain->armature, arm); + return add_camera(name); +} +void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) +{ + if(camera->id.us == 0) + free_libblock(&bmain->camera, camera); else - BKE_report(reports, RPT_ERROR, "Armature must have zero users to be removed."); + BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d.", camera->id.name+2, camera->id.us); /* XXX python now has invalid pointer? */ } -static bArmature *rna_Main_add_armature(Main *bmain, char *name) +Scene *rna_Main_scenes_new(Main *bmain, char* name) { - bArmature *arm= add_armature(name); - arm->id.us--; - return arm; + return add_scene(name); } - -static Lamp *rna_Main_add_lamp(Main *bmain, char *name) +void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) { - Lamp *la= add_lamp(name); - la->id.us--; - return la; -} + /* dont call free_libblock(...) directly */ + Scene *newscene; -/* -static void rna_Main_remove_lamp(Main *bmain, ReportList *reports, Lamp *la) -{ - if(la->id.us == 0) - free_libblock(&main->lamp, la); - else - BKE_report(reports, RPT_ERROR, "Lamp must have zero users to be removed."); + if(scene->id.prev) + newscene= scene->id.prev; + else if(scene->id.next) + newscene= scene->id.next; + else { + BKE_reportf(reports, RPT_ERROR, "Scene \"%s\" is the last, cant ve removed.", scene->id.name+2); + return; + } + + ED_screen_set_scene(C, newscene); + + unlink_scene(bmain, scene, newscene); } -*/ -static Object* rna_Main_add_object(Main *bmain, int type, char *name) +Object *rna_Main_objects_new(Main *bmain, char* name, int type) { Object *ob= add_only_object(type, name); ob->id.us--; return ob; } +void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) +{ + /* + NOTE: the following example shows when this function should _not_ be called -/* - NOTE: the following example shows when this function should _not_ be called + ob = bpy.data.add_object() + scene.add_object(ob) - ob = bpy.data.add_object() - scene.add_object(ob) + # ob is freed here + scene.remove_object(ob) - # ob is freed here - scene.remove_object(ob) + # don't do this since ob is already freed! + bpy.data.remove_object(ob) + */ + if(object->id.us == 0) + free_libblock(&bmain->object, object); + else + BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, object->id.us); +} - # don't do this since ob is already freed! - bpy.data.remove_object(ob) -*/ -static void rna_Main_remove_object(Main *bmain, ReportList *reports, Object *ob) +struct Material *rna_Main_materials_new(Main *bmain, char* name) { - if(ob->id.us == 0) - free_libblock(&bmain->object, ob); + return add_material(name); +} +void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) +{ + if(material->id.us == 0) + free_libblock(&bmain->mat, material); else - BKE_report(reports, RPT_ERROR, "Object must have zero users to be removed."); + BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d.", material->id.name+2, material->id.us); + + /* XXX python now has invalid pointer? */ } -static Material *rna_Main_add_material(Main *bmain, char *name) +Mesh *rna_Main_meshes_new(Main *bmain, char* name) { - return add_material(name); + Mesh *me= add_mesh(name); + me->id.us--; + return me; } +void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) +{ + if(mesh->id.us == 0) + free_libblock(&bmain->mesh, mesh); + else + BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d.", mesh->id.name+2, mesh->id.us); -/* TODO: remove material? */ + /* XXX python now has invalid pointer? */ +} -struct Tex *rna_Main_add_texture(Main *bmain, char *name) +Lamp *rna_Main_lamps_new(Main *bmain, char* name) { - return add_texture(name); + Lamp *lamp= add_lamp(name); + lamp->id.us--; + return lamp; } +void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) +{ + if(lamp->id.us == 0) + free_libblock(&bmain->lamp, lamp); + else + BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d.", lamp->id.name+2, lamp->id.us); -/* TODO: remove texture? */ + /* XXX python now has invalid pointer? */ +} -struct Image *rna_Main_add_image(Main *bmain, char *filename) +Text *rna_Main_texts_new(Main *bmain, char* name) { - return BKE_add_image_file(filename, 0); + return add_empty_text(name); +} +void rna_Main_texts_remove(Main *bmain, ReportList *reports, Text *text) +{ + unlink_text(bmain, text); + free_libblock(&bmain->text, text); + /* XXX python now has invalid pointer? */ +} +Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* path) +{ + Text *txt= add_text(path, bmain->name); + if(txt==NULL) + BKE_reportf(reports, RPT_ERROR, "Couldn't load text from path \"%s\".", path); + + return txt; +} + +bArmature *rna_Main_armatures_new(Main *bmain, char* name) +{ + bArmature *arm= add_armature(name); + arm->id.us--; + return arm; +} +void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) +{ + if(arm->id.us == 0) + free_libblock(&bmain->armature, arm); + else + BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d.", arm->id.name+2, arm->id.us); + + /* XXX python now has invalid pointer? */ } #else @@ -154,73 +221,297 @@ void RNA_api_main(StructRNA *srna) FunctionRNA *func; PropertyRNA *parm; - func= RNA_def_function(srna, "add_object", "rna_Main_add_object"); - RNA_def_function_ui_description(func, "Add a new object."); - parm= RNA_def_enum(func, "type", object_type_items, 0, "", "Type of Object."); + func= RNA_def_function(srna, "add_texture", "rna_Main_add_texture"); + RNA_def_function_ui_description(func, "Add a new texture."); + parm= RNA_def_string(func, "name", "Tex", 0, "", "New name for the datablock."); /* optional */ + parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "add_image", "rna_Main_add_image"); + RNA_def_function_ui_description(func, "Add a new image."); + parm= RNA_def_string(func, "filename", "", 0, "", "Filename to load image from."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "image", "Image", "", "New image."); + RNA_def_function_return(func, parm); + +} + +void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainCameras"); + srna= RNA_def_struct(brna, "MainCameras", NULL); + RNA_def_struct_ui_text(srna, "Main Cameras", "Collection of cameras."); + + func= RNA_def_function(srna, "new", "rna_Main_cameras_new"); + RNA_def_function_ui_description(func, "Add a new camera to the main database"); + parm= RNA_def_string(func, "name", "Camera", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "camera", "Camera", "", "New camera datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_cameras_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a camera from the current blendfile."); + parm= RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); +} + +void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainScenes"); + srna= RNA_def_struct(brna, "MainScenes", NULL); + RNA_def_struct_ui_text(srna, "Main Scenes", "Collection of scenes."); + + func= RNA_def_function(srna, "new", "rna_Main_scenes_new"); + RNA_def_function_ui_description(func, "Add a new scene to the main database"); + parm= RNA_def_string(func, "name", "Scene", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "scene", "Scene", "", "New scene datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_scenes_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_ui_description(func, "Remove a scene from the current blendfile."); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + +void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainObjects"); + srna= RNA_def_struct(brna, "MainObjects", NULL); + RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects."); + + func= RNA_def_function(srna, "new", "rna_Main_objects_new"); + RNA_def_function_ui_description(func, "Add a new object to the main database"); parm= RNA_def_string(func, "name", "Object", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "object", "Object", "", "New object."); + parm= RNA_def_enum(func, "type", object_type_items, 0, "", "Type of Object."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + /* return type */ + parm= RNA_def_pointer(func, "object", "Object", "", "New object datablock."); RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "remove_object", "rna_Main_remove_object"); + func= RNA_def_function(srna, "remove", "rna_Main_objects_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove an object if it has zero users."); parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_ui_description(func, "Remove a object from the current blendfile."); +} - func= RNA_def_function(srna, "add_mesh", "rna_Main_add_mesh"); - RNA_def_function_ui_description(func, "Add a new mesh."); - parm= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock."); +void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainMaterials"); + srna= RNA_def_struct(brna, "MainMaterials", NULL); + RNA_def_struct_ui_text(srna, "Main Material", "Collection of materials."); + + func= RNA_def_function(srna, "new", "rna_Main_materials_new"); + RNA_def_function_ui_description(func, "Add a new material to the main database"); + parm= RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh."); + /* return type */ + parm= RNA_def_pointer(func, "material", "Material", "", "New material datablock."); RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "remove_mesh", "rna_Main_remove_mesh"); + func= RNA_def_function(srna, "remove", "rna_Main_materials_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove a mesh if it has zero users."); - parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); + RNA_def_function_ui_description(func, "Remove a material from the current blendfile."); + parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); +} +void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) +{ - func= RNA_def_function(srna, "add_armature", "rna_Main_add_armature"); - RNA_def_function_ui_description(func, "Add a new armature."); - parm= RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock."); +} +void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainMeshes"); + srna= RNA_def_struct(brna, "MainMeshes", NULL); + RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes."); + + func= RNA_def_function(srna, "new", "rna_Main_meshes_new"); + RNA_def_function_ui_description(func, "Add a new mesh to the main database"); + parm= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "armature", "Armature", "", "New armature."); + /* return type */ + parm= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh datablock."); RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "remove_armature", "rna_Main_remove_armature"); + func= RNA_def_function(srna, "remove", "rna_Main_meshes_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove an armature if it has zero users."); - parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove."); + RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile."); + parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); +} +void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainLamps"); + srna= RNA_def_struct(brna, "MainLamps", NULL); + RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps."); - func= RNA_def_function(srna, "add_lamp", "rna_Main_add_lamp"); - RNA_def_function_ui_description(func, "Add a new lamp."); + func= RNA_def_function(srna, "new", "rna_Main_lamps_new"); + RNA_def_function_ui_description(func, "Add a new lamp to the main database"); parm= RNA_def_string(func, "name", "Lamp", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "mesh", "Lamp", "", "New lamp."); + /* return type */ + parm= RNA_def_pointer(func, "lamp", "Lamp", "", "New lamp datablock."); RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "add_material", "rna_Main_add_material"); - RNA_def_function_ui_description(func, "Add a new material."); - parm= RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock."); /* optional */ - parm= RNA_def_pointer(func, "material", "Material", "", "New material."); + func= RNA_def_function(srna, "remove", "rna_Main_lamps_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile."); + parm= RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); +} +void RNA_def_main_libraries(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainTexts"); + srna= RNA_def_struct(brna, "MainTexts", NULL); + RNA_def_struct_ui_text(srna, "Main Texts", "Collection of texts."); + + func= RNA_def_function(srna, "new", "rna_Main_texts_new"); + RNA_def_function_ui_description(func, "Add a new text to the main database"); + parm= RNA_def_string(func, "name", "Text", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock."); RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "add_texture", "rna_Main_add_texture"); - RNA_def_function_ui_description(func, "Add a new texture."); - parm= RNA_def_string(func, "name", "Tex", 0, "", "New name for the datablock."); /* optional */ - parm= RNA_def_pointer(func, "texture", "Texture", "", "New texture."); + func= RNA_def_function(srna, "remove", "rna_Main_texts_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a text from the current blendfile."); + parm= RNA_def_pointer(func, "text", "Text", "", "Text to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + /* load func */ + func= RNA_def_function(srna, "load", "rna_Main_texts_load"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Add a new text to the main database from a file"); + parm= RNA_def_string(func, "path", "Path", FILE_MAXDIR + FILE_MAXFILE, "", "path for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock."); RNA_def_function_return(func, parm); +} +void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop) +{ - func= RNA_def_function(srna, "add_image", "rna_Main_add_image"); - RNA_def_function_ui_description(func, "Add a new image."); - parm= RNA_def_string(func, "filename", "", 0, "", "Filename to load image from."); +} +void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainArmatures"); + srna= RNA_def_struct(brna, "MainArmatures", NULL); + RNA_def_struct_ui_text(srna, "Main Armatures", "Collection of armatures."); + + func= RNA_def_function(srna, "new", "rna_Main_armatures_new"); + RNA_def_function_ui_description(func, "Add a new armature to the main database"); + parm= RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "image", "Image", "", "New image."); + /* return type */ + parm= RNA_def_pointer(func, "armature", "Armature", "", "New armature datablock."); RNA_def_function_return(func, parm); + func= RNA_def_function(srna, "remove", "rna_Main_armatures_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a armature from the current blendfile."); + parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); +} +void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) +{ + +} +void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) +{ + } #endif diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index a5c1d8d5f57..b69e5130c0f 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1023,10 +1023,11 @@ static void rna_def_material_volume(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Diffusion", "Diffusion factor, the strength of the blurring effect"); RNA_def_property_update(prop, 0, "rna_Material_update"); - prop= RNA_def_property(srna, "ms_spread", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ms_steps"); - RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "Spread", "Simulation steps, the effective distance over which the light is diffused"); + prop= RNA_def_property(srna, "ms_spread", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "ms_spread"); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3); + RNA_def_property_ui_text(prop, "Spread", "Proportional distance over which the light is diffused"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "ms_intensity", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 539fe20c299..0304cf8f352 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -80,10 +80,17 @@ void rna_Mesh_update_draw(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value) { MVert *mvert= (MVert*)ptr->data; + normal_short_to_float_v3(value, mvert->no); +} - value[0]= mvert->no[0]/32767.0f; - value[1]= mvert->no[1]/32767.0f; - value[2]= mvert->no[2]/32767.0f; +static void rna_MeshVertex_normal_set(PointerRNA *ptr, const float *value) +{ + MVert *mvert= (MVert*)ptr->data; + float no[3]; + + copy_v3_v3(no, value); + normalize_v3(no); + normal_float_to_short_v3(mvert->no, no); } static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr) @@ -1009,9 +1016,8 @@ static void rna_def_mvert(BlenderRNA *brna) prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_float_sdna(prop, NULL, "no"); - RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", NULL, NULL); + RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", "rna_MeshVertex_normal_set", NULL); RNA_def_property_ui_text(prop, "Normal", "Vertex Normal"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); @@ -1297,6 +1303,7 @@ static void rna_def_mtexpoly(BlenderRNA *brna) RNA_def_property_ui_text(prop, "UV Selected", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); +#if 0 prop= RNA_def_property(srna, "uv_pinned", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1); RNA_def_property_array(prop, 4); @@ -1310,6 +1317,12 @@ static void rna_def_mtexpoly(BlenderRNA *brna) RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL); RNA_def_property_ui_text(prop, "UV", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "uv_raw", PROP_FLOAT, PROP_NONE); + RNA_def_property_multi_array(prop, 2, uv_dim); + RNA_def_property_float_sdna(prop, NULL, "uv"); + RNA_def_property_ui_text(prop, "UV", "Fixed size UV coordinates array"); +#endif } static void rna_def_msticky(BlenderRNA *brna) @@ -1735,7 +1748,8 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_FACESEL_HLT, 0); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - + /* pointers */ + rna_def_animdata_common(srna); rna_def_texmat_common(srna, "rna_Mesh_texspace_editable"); RNA_api_mesh(srna); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 32bcf5c1bc8..c274081b119 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -43,6 +43,11 @@ static void rna_Mesh_uv_texture_add(struct Mesh *me, struct bContext *C) ED_mesh_uv_texture_add(C, NULL, NULL, me); } +static void rna_Mesh_vertex_color_add(struct Mesh *me, struct bContext *C) +{ + ED_mesh_color_add(C, NULL, NULL, me); +} + #else void RNA_api_mesh(StructRNA *srna) @@ -68,6 +73,10 @@ void RNA_api_mesh(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh."); + func= RNA_def_function(srna, "add_vertex_color", "rna_Mesh_vertex_color_add"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh."); + func= RNA_def_function(srna, "calc_normals", "ED_mesh_calc_normals"); RNA_def_function_ui_description(func, "Calculate vertex normals."); @@ -79,6 +88,8 @@ void RNA_api_mesh(StructRNA *srna) RNA_def_function_ui_description(func, "Add a new material to Mesh."); parm= RNA_def_pointer(func, "material", "Material", "", "Material to add."); RNA_def_property_flag(parm, PROP_REQUIRED); + + } #endif diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d1e73d6add3..9922f099cd5 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1077,12 +1077,6 @@ static void def_cmp_render_layers(StructRNA *srna) RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_scene_layer_itemf"); RNA_def_property_ui_text(prop, "Layer", ""); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - /* TODO: comments indicate this might be a hack */ - prop = RNA_def_property(srna, "re_render", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); - RNA_def_property_ui_text(prop, "Re-render", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); } static void def_cmp_output_file(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index b87f1058070..fd9d7272b6d 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -932,7 +932,7 @@ static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr) return PointerRNA_NULL; kb= BLI_findlink(&key->block, ob->shapenr-1); - RNA_pointer_create(&key->id, &RNA_ShapeKey, kb, &keyptr); + RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); return keyptr; } @@ -1429,7 +1429,9 @@ static void rna_def_object(BlenderRNA *brna) {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"}, {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector."}, {0, NULL, 0, NULL, NULL}}; - + + static float default_quat[4] = {1,0,0,0}; /* default quaternion values */ + static float default_axisAngle[4] = {0,0,1,0}; /* default axis-angle rotation values */ int matrix_dimsize[]= {4, 4}; srna= RNA_def_struct(brna, "Object", "ID"); @@ -1551,6 +1553,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable"); + RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); @@ -1558,9 +1561,10 @@ static void rna_def_object(BlenderRNA *brna) * having a single one is better for Keyframing and other property-management situations... */ prop= RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE); - RNA_def_property_array(prop, 4); // TODO: maybe we'll need to define the 'default value' getter too... + RNA_def_property_array(prop, 4); RNA_def_property_float_funcs(prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", NULL); RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable"); + RNA_def_property_float_array_default(prop, default_axisAngle); RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); @@ -1603,12 +1607,14 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "dquat"); + RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Delta Rotation (Quaternion)", "Extra added rotation to the rotation of the object (when using Quaternion rotations)."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); #if 0 // XXX not supported well yet... prop= RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE); RNA_def_property_float_sdna(prop, NULL, "dquat"); // FIXME: this is not a single field any more! (drotAxis and drotAngle) + RNA_def_property_float_array_default(prop, default_axisAngle); RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)", "Extra added rotation to the rotation of the object (when using Axis-Angle rotations)."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); #endif @@ -1767,6 +1773,9 @@ static void rna_def_object(BlenderRNA *brna) /* anim */ rna_def_animdata_common(srna); + rna_def_animviz_common(srna); + rna_def_motionpath_common(srna); + /* duplicates */ prop= RNA_def_property(srna, "track_override_parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_POWERTRACK); @@ -1784,18 +1793,18 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); - prop= RNA_def_property(srna, "dupli_frames_no_speed", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); - RNA_def_property_ui_text(prop, "Dupli Frames No Speed", "Set dupliframes to still, regardless of frame."); + prop= RNA_def_property(srna, "use_dupli_frames_speed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); + RNA_def_property_ui_text(prop, "Dupli Frames Speed", "Set dupliframes to use the frame."); // TODO, better descriptio! RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); - prop= RNA_def_property(srna, "dupli_verts_rotation", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_dupli_verts_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT); RNA_def_property_ui_text(prop, "Dupli Verts Rotation", "Rotate dupli according to vertex normal."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "dupli_faces_inherit_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIROT); + prop= RNA_def_property(srna, "use_dupli_faces_scale", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES_SCALE); RNA_def_property_ui_text(prop, "Dupli Faces Inherit Scale", "Scale dupli based on face size."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 63b4549f7c9..8379ae7995d 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -49,6 +49,7 @@ #include "BKE_object.h" #include "BKE_mesh.h" #include "BKE_DerivedMesh.h" +#include "BKE_bvhutils.h" #include "BKE_customdata.h" #include "BKE_anim.h" @@ -309,6 +310,25 @@ static Object *rna_Object_find_armature(Object *ob) return ob_arm; } +static PointerRNA rna_Object_add_shape_key(Object *ob, bContext *C, ReportList *reports, char *name, int from_mix) +{ + Scene *scene= CTX_data_scene(C); + KeyBlock *kb= NULL; + + if((kb=object_insert_shape_key(scene, ob, name, from_mix))) { + PointerRNA keyptr; + + RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return keyptr; + } + else { + BKE_reportf(reports, RPT_ERROR, "Object \"%s\"does not support shapes.", ob->id.name+2); + return PointerRNA_NULL; + } +} + int rna_Object_is_visible(Object *ob, bContext *C) { return !(ob->restrictflag & OB_RESTRICT_VIEW) && ob->lay & CTX_data_scene(C)->lay; @@ -350,6 +370,45 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int } */ +void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3], float r_location[3], float r_normal[3], int *index) +{ + BVHTreeFromMesh treeData; + + if(ob->derivedFinal==NULL) { + BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting.", ob->id.name+2); + return; + } + + /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ + bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6); + + if(treeData.tree==NULL) { + BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for ray casting.", ob->id.name+2); + return; + } + else { + BVHTreeRayHit hit; + float ray_nor[3], dist; + sub_v3_v3v3(ray_nor, ray_end, ray_start); + + dist= hit.dist = normalize_v3(ray_nor); + hit.index = -1; + + if(BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { + if(hit.dist<=dist) { + copy_v3_v3(r_location, hit.co); + copy_v3_v3(r_normal, hit.no); + *index= hit.index; + return; + } + } + } + + zero_v3(r_location); + zero_v3(r_normal); + *index= -1; +} + #else void RNA_api_object(StructRNA *srna) @@ -414,6 +473,39 @@ void RNA_api_object(StructRNA *srna) parm= RNA_def_pointer(func, "ob_arm", "Object", "", "Armature object influencing this object or NULL."); RNA_def_function_return(func, parm); + /* Shape key */ + func= RNA_def_function(srna, "add_shape_key", "rna_Object_add_shape_key"); + RNA_def_function_ui_description(func, "Add shape key to an object."); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + parm= RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keylock."); /* optional */ + parm= RNA_def_boolean(func, "from_mix", 1, "", "Create new shape from existing mix of shapes."); + parm= RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock."); + RNA_def_property_flag(parm, PROP_RNAPTR); + RNA_def_function_return(func, parm); + + /* Ray Cast */ + func= RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast"); + RNA_def_function_ui_description(func, "Cast a ray onto in object space."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + + /* ray start and end */ + parm= RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_REQUIRED); + + /* return location and normal */ + parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The hit location of this ray cast", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_return_mark(func, parm); + parm= RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the ray cast hit location", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_return_mark(func, parm); + + parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0); + RNA_def_function_return_mark(func, parm); + + /* DAG */ func= RNA_def_function(srna, "make_display_list", "rna_Object_make_display_list"); RNA_def_function_ui_description(func, "Update object's display data."); /* XXX describe better */ diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 67c7a9aa078..0eb4f9b9da0 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -810,6 +810,12 @@ static void rna_def_collision(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PDEFLE_KILL_PART); RNA_def_property_ui_text(prop, "Kill Particles", "Kill collided particles"); RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); + + prop= RNA_def_property(srna, "stickness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pdef_stickness"); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_text(prop, "Stickness", "Amount of stickness to surface collision"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); /* Soft Body and Cloth Interaction */ @@ -1381,6 +1387,8 @@ static void rna_def_softbody(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + int matrix_dimsize[]= {3, 3}; + static EnumPropertyItem collision_type_items[] = { {SBC_MODE_MANUAL, "MANUAL", 0, "Manual", "Manual adjust"}, @@ -1586,6 +1594,33 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_MONITOR); RNA_def_property_ui_text(prop, "Print Performance to Console", "Turn on SB diagnose console prints"); + prop= RNA_def_property(srna, "estimate_matrix", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_ESTIMATEIPO); + RNA_def_property_ui_text(prop, "Estimate matrix", "esimate matrix .. split to COM , ROT ,SCALE "); + + + /***********************************************************************************/ + /* these are not exactly settings, but reading calculated results*/ + /* but i did not want to start a new property struct */ + /* so rather rename this from SoftBodySettings to SoftBody */ + /* translation */ + prop= RNA_def_property(srna, "lcom", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "lcom"); + RNA_def_property_ui_text(prop, "Center of mass", "Location of Center of mass."); + + /* matrix */ + prop= RNA_def_property(srna, "lrot", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, NULL, "lrot"); + RNA_def_property_multi_array(prop, 2, matrix_dimsize); + RNA_def_property_ui_text(prop, "Rot Matrix", "Estimated rotation matrix."); + + prop= RNA_def_property(srna, "lscale", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, NULL, "lscale"); + RNA_def_property_multi_array(prop, 2, matrix_dimsize); + RNA_def_property_ui_text(prop, "Scale Matrix", "Estimated scale matrix."); + /***********************************************************************************/ + + /* Flags */ prop= RNA_def_property(srna, "use_goal", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index c7aca9c9738..b37442fab6a 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -58,6 +58,8 @@ #include "MEM_guardedalloc.h" +#include "RNA_access.h" + static void rna_Pose_update(Main *bmain, Scene *scene, PointerRNA *ptr) { // XXX when to use this? ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); @@ -509,6 +511,16 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index) return PROP_EDITABLE; } +/* not essential, but much faster then the default lookup function */ +PointerRNA rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key) +{ + PointerRNA rptr; + bPose *pose= (bPose*)ptr->data; + bPoseChannel *pchan= BLI_findstring(&pose->chanbase, key, offsetof(bPoseChannel, name)); + RNA_pointer_create(ptr->id.data, &RNA_PoseBone, pchan, &rptr); + return rptr; +} + #else static void rna_def_bone_group(BlenderRNA *brna) @@ -638,6 +650,9 @@ static void rna_def_pose_channel(BlenderRNA *brna) {ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"}, {ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector."}, {0, NULL, 0, NULL, NULL}}; + + static float default_quat[4] = {1,0,0,0}; /* default quaternion values */ + static float default_axisAngle[4] = {0,0,1,0}; /* default axis-angle rotation values */ StructRNA *srna; PropertyRNA *prop; @@ -665,7 +680,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "selectflag", BONE_SELECTED); RNA_def_property_ui_text(prop, "Selected", ""); - /* Baked Bone Path cache data s*/ + /* Baked Bone Path cache data */ prop= RNA_def_property(srna, "path_start_frame", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "pathsf"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -678,6 +693,8 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bone Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + rna_def_motionpath_common(srna); + /* Relationships to other bones */ prop= RNA_def_property(srna, "bone", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -711,6 +728,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop= RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "quat"); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); + RNA_def_property_float_array_default(prop, default_quat); RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); @@ -721,6 +739,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_array(prop, 4); // TODO: maybe we'll need to define the 'default value' getter too... RNA_def_property_float_funcs(prop, "rna_PoseChannel_rotation_axis_angle_get", "rna_PoseChannel_rotation_axis_angle_set", NULL); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable"); + RNA_def_property_float_array_default(prop, default_axisAngle); RNA_def_property_ui_text(prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Pose_update"); @@ -895,6 +914,13 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Custom Object", "Object that defines custom draw type for this bone."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + prop= RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "custom_tx"); + RNA_def_property_struct_type(prop, "PoseBone"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Custom Shape Transform", "Bone that defines the display transform of this custom shape."); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); + /* bone groups */ prop= RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "agrp_index"); @@ -1072,7 +1098,7 @@ static void rna_def_pose(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "chanbase", NULL); RNA_def_property_struct_type(prop, "PoseBone"); RNA_def_property_ui_text(prop, "Pose Bones", "Individual pose bones for the armature."); - + RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, "rna_PoseBones_lookup_string"); /* can be removed, only for fast lookup */ /* bone groups */ prop= RNA_def_property(srna, "bone_groups", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "agroups", NULL); @@ -1091,7 +1117,8 @@ static void rna_def_pose(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_Pose_active_bone_group_index_get", "rna_Pose_active_bone_group_index_set", "rna_Pose_active_bone_group_index_range"); RNA_def_property_ui_text(prop, "Active Bone Group Index", "Active index in bone groups array."); RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update"); - + + /* ik solvers */ prop= RNA_def_property(srna, "ik_solver", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "iksolver"); RNA_def_property_enum_funcs(prop, NULL, "rna_Pose_ik_solver_set", NULL); @@ -1104,7 +1131,10 @@ static void rna_def_pose(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Pose_ikparam_get", NULL, "rna_Pose_ikparam_typef"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "IK Param", "Parameters for IK solver."); - + + /* animviz */ + rna_def_animviz_common(srna); + /* RNA_api_pose(srna); */ } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4d8af5fd6bd..63628e0889d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -98,11 +98,13 @@ EnumPropertyItem snap_element_items[] = { #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_depsgraph.h" +#include "BKE_image.h" #include "BKE_mesh.h" #include "BLI_threads.h" @@ -126,21 +128,28 @@ static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object); } -static void rna_Scene_link_object(Scene *sce, ReportList *reports, Object *ob) +static void rna_Scene_link_object(Scene *scene, ReportList *reports, Object *ob) { - Base *base= object_in_scene(ob, sce); - if (base) { - BKE_report(reports, RPT_ERROR, "Object is already in this scene."); + Base *base; + + if (ob->type != OB_EMPTY && ob->data==NULL) { + BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is not an Empty type and has no Object Data set."); return; } - base= scene_add_base(sce, ob); + + if (object_in_scene(ob, scene)) { + BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\".", ob->id.name+2, scene->id.name+2); + return; + } + + base= scene_add_base(scene, ob); ob->id.us++; /* this is similar to what object_add_type and add_object do */ - ob->lay= base->lay= sce->lay; + ob->lay= base->lay= scene->lay; ob->recalc |= OB_RECALC; - DAG_scene_sort(sce); + DAG_scene_sort(scene); } static void rna_Scene_unlink_object(Scene *sce, ReportList *reports, Object *ob) @@ -361,6 +370,21 @@ static void rna_SceneRenderData_file_format_set(PointerRNA *ptr, int value) #endif } +static int rna_SceneRender_file_ext_length(PointerRNA *ptr) +{ + RenderData *rd= (RenderData*)ptr->data; + char ext[8]; + + BKE_add_image_extension(ext, rd->imtype); + return strlen(ext); +} + +static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) +{ + RenderData *rd= (RenderData*)ptr->data; + BKE_add_image_extension(str, rd->imtype); +} + void rna_SceneRenderData_jpeg2k_preset_update(RenderData *rd) { rd->subimtype &= ~(R_JPEG2K_12BIT|R_JPEG2K_16BIT | R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS); @@ -503,6 +527,12 @@ static int rna_SceneRenderData_engine_get(PointerRNA *ptr) return 0; } +static void rna_SceneRenderData_color_management_update(Main *bmain, Scene *unused, PointerRNA *ptr) +{ + /* reset all generated image block buffers to prevent out-of-date conversions */ + BKE_image_free_image_ibufs(); +} + static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value) { Scene *scene= (Scene*)ptr->id.data; @@ -1217,6 +1247,12 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Stereo Mode", "Stereographic techniques"); RNA_def_property_update(prop, NC_SCENE, NULL); + prop= RNA_def_property(srna, "eye_separation", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "eyeseparation"); + RNA_def_property_range(prop, 0.01, 5.0); + RNA_def_property_ui_text(prop, "Eye Separation", "Set the distance between the eyes - the camera focal length/30 should be fine"); + RNA_def_property_update(prop, NC_SCENE, NULL); + /* Dome */ prop= RNA_def_property(srna, "dome_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dome.mode"); @@ -1449,7 +1485,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", ""}, {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", ""}, {0, NULL, 0, NULL, NULL}}; - + + static EnumPropertyItem bake_qyad_split_items[] ={ + {0, "AUTO", 0, "Automatic", "Split quads to give the least distortion while baking"}, + {1, "FIXED", 0, "Fixed", "Split quads pradictably (0,1,2) (0,2,3)"}, + {2, "FIXED_ALT", 0, "Fixed Alternate", "Split quads pradictably (1,2,3) (1,3,0)"}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem bake_aa_items[] ={ {5, "AA_5", 0, "5", ""}, {8, "AA_8", 0, "8", ""}, @@ -2088,9 +2130,9 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "color_management", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT); RNA_def_property_ui_text(prop, "Color Management", "Use color profiles and gamma corrected imaging pipeline"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS|NC_MATERIAL|ND_SHADING, NULL); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS|NC_MATERIAL|ND_SHADING, "rna_SceneRenderData_color_management_update"); - prop= RNA_def_property(srna, "file_extensions", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_file_extension", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXTENSION); RNA_def_property_ui_text(prop, "File Extensions", "Add the file format extensions to the rendered file name (eg: filename + .jpg)"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); @@ -2101,7 +2143,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_SceneRenderData_file_format_set", NULL); RNA_def_property_ui_text(prop, "File Format", "File format to save the rendered images as."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - + + prop= RNA_def_property(srna, "file_extension", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_SceneRender_file_ext_get", "rna_SceneRender_file_ext_length", NULL); + RNA_def_property_ui_text(prop, "Extension", "The file extension used for saving renders."); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop= RNA_def_property(srna, "free_image_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image texture from memory after render, to save memory before compositing."); @@ -2144,13 +2192,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "bake_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_mode"); RNA_def_property_enum_items(prop, bake_mode_items); - RNA_def_property_ui_text(prop, "Bake Mode", ""); + RNA_def_property_ui_text(prop, "Bake Mode", "Choose shading information to bake into the image"); prop= RNA_def_property(srna, "bake_normal_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_normal_space"); RNA_def_property_enum_items(prop, bake_normal_space_items); RNA_def_property_ui_text(prop, "Normal Space", "Choose normal space for baking"); + prop= RNA_def_property(srna, "bake_quad_split", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, bake_qyad_split_items); + RNA_def_property_ui_text(prop, "Quad Split", "Choose the method used to split a quad into 2 triangles for baking"); + prop= RNA_def_property(srna, "bake_aa_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "bake_osa"); RNA_def_property_enum_items(prop, bake_aa_items); @@ -2162,10 +2214,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "bake_normalized", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_NORMALIZE); - RNA_def_property_ui_text(prop, "Normalized", ""); - //"Bake ambient occlusion normalized, without taking into acount material settings" - //"Normalized displacement value to fit the 'Dist' range" - // XXX: Need 1 tooltip here... + RNA_def_property_ui_text(prop, "Normalized", "With displacement normalize to the distance, with ambient occlusion normalize without using material settings."); prop= RNA_def_property(srna, "bake_clear", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bake_flag", R_BAKE_CLEAR); @@ -2194,7 +2243,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "stamp_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_TIME); - RNA_def_property_ui_text(prop, "Stamp Time", "Include the current time in image metadata"); + RNA_def_property_ui_text(prop, "Stamp Time", "Include the render frame as HH:MM:SS.FF in image metadata"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "stamp_date", PROP_BOOLEAN, PROP_NONE); @@ -2306,6 +2355,9 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_SceneRenderData_use_game_engine_get", NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine."); + + /* Scene API */ + RNA_api_scene_render(srna); } diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 4efbed167a6..84dc3e6971e 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -36,12 +36,15 @@ #include "DNA_anim_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BKE_utildefines.h" #ifdef RNA_RUNTIME #include "BKE_animsys.h" #include "BKE_scene.h" +#include "BKE_image.h" #include "BKE_depsgraph.h" +#include "BKE_writeavi.h" #include "ED_object.h" #include "ED_anim_api.h" @@ -84,6 +87,14 @@ static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports, } } +static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) +{ + if(BKE_imtype_is_movie(rd->imtype)) + BKE_makeanimstring(name, rd); + else + BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION); +} + #else void RNA_api_scene(StructRNA *srna) @@ -113,5 +124,18 @@ void RNA_api_scene(StructRNA *srna) RNA_def_boolean(func, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); } +void RNA_api_scene_render(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path"); + RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately."); + parm= RNA_def_int(func, "frame", INT_MIN, INT_MIN, INT_MAX, "", "Frame number to use, if unset the current frame will be used.", MINAFRAME, MAXFRAME); + parm= RNA_def_string(func, "name", "", FILE_MAX, "File Name", "the resulting filename from the scenes render settings."); + RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ + RNA_def_function_return_mark(func, parm); +} + #endif diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 883c77b3faa..5a29eee5cf2 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -23,6 +23,7 @@ */ #include <stdlib.h> +#include <stddef.h> #include "RNA_define.h" #include "RNA_types.h" @@ -37,9 +38,10 @@ EnumPropertyItem region_type_items[] = { {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""}, {RGN_TYPE_HEADER, "HEADER", 0, "Header", ""}, {RGN_TYPE_CHANNELS, "CHANNELS", 0, "Channels", ""}, - {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""}, {RGN_TYPE_TEMPORARY, "TEMPORARY", 0, "Temporary", ""}, {RGN_TYPE_UI, "UI", 0, "UI", ""}, + {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""}, + {RGN_TYPE_TOOL_PROPS, "TOOL_PROPS", 0, "Tool Properties", ""}, {RGN_TYPE_PREVIEW, "PREVIEW", 0, "Preview", ""}, {0, NULL, 0, NULL, NULL}}; @@ -154,8 +156,9 @@ static void rna_def_region(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Region ID", "Unique ID for this region."); - prop= RNA_def_property(srna, "type", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "regiontype"); + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "regiontype"); + RNA_def_property_enum_items(prop, region_type_items); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Region Type", "Type of this region."); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 13c3b15549b..99bee9413cd 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -29,6 +29,7 @@ #include "rna_internal.h" +#include "DNA_ID.h" #include "DNA_scene_types.h" #include "BKE_paint.h" @@ -159,6 +160,38 @@ static void rna_Paint_active_brush_index_range(PointerRNA *ptr, int *min, int *m *max= MAX2(p->brush_count-1, 0); } +static void rna_Paint_active_brush_name_get(PointerRNA *ptr, char *value) +{ + Paint *p= ptr->data; + Brush *br = paint_brush(p); + + BLI_strncpy(value, br->id.name+2, sizeof(br->id.name-2)); +} + + +static int rna_Paint_active_brush_name_length(PointerRNA *ptr) +{ + Paint *p= ptr->data; + Brush *br = paint_brush(p); + return strlen(br->id.name+2); +} + +static void rna_Paint_active_brush_name_set(PointerRNA *ptr, const char *value) +{ + Paint *p= ptr->data; + Brush *br; + int i; + + for(i = 0; i < p->brush_count; ++i) { + br = p->brushes[i]; + + if (strcmp(br->id.name+2, value)==0) { + paint_brush_set(p, br); + return; + } + } +} + #else static void rna_def_paint(BlenderRNA *brna) @@ -182,6 +215,12 @@ static void rna_def_paint(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Paint_active_brush_index_set", "rna_Paint_active_brush_index_range"); RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_update(prop, NC_BRUSH|NA_EDITED, NULL); + + prop= RNA_def_property(srna, "active_brush_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_Paint_active_brush_name_get", "rna_Paint_active_brush_name_length", "rna_Paint_active_brush_name_set"); + RNA_def_property_string_maxlength(prop, sizeof(((ID*)NULL)->name)-2); + RNA_def_property_ui_text(prop, "Active Brush Name", ""); + RNA_def_property_update(prop, NC_BRUSH|NA_EDITED, NULL); /* Fake property to get active brush directly, rather than integer index */ prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); @@ -415,10 +454,6 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Draw Particles", "Draw actual particles."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "mirror_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_X_MIRROR); - RNA_def_property_ui_text(prop, "X-Axis Mirror", "Mirror operations over the X axis while editing."); - prop= RNA_def_property(srna, "add_interpolate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_INTERPOLATE_ADDED); RNA_def_property_ui_text(prop, "Interpolate", "Interpolate new particles from the existing ones."); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 2fd0bf1810a..35c8c7ac345 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1351,7 +1351,7 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed."); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL); // XXX need to be able to flush channel types /* display */ prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); @@ -1481,37 +1481,37 @@ static void rna_def_space_time(BlenderRNA *brna) /* Define Anim Playback Areas */ prop= RNA_def_property(srna, "play_top_left", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_REGION); - RNA_def_property_ui_text(prop, "Top-Left 3D Window", ""); + RNA_def_property_ui_text(prop, "Top-Left 3D Editor", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); prop= RNA_def_property(srna, "play_all_3d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_3D_WIN); - RNA_def_property_ui_text(prop, "All 3D Windows", ""); + RNA_def_property_ui_text(prop, "All 3D View Editors", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); prop= RNA_def_property(srna, "play_anim", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_ANIM_WIN); - RNA_def_property_ui_text(prop, "Animation Windows", ""); + RNA_def_property_ui_text(prop, "Animation Editors", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); prop= RNA_def_property(srna, "play_buttons", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_BUTS_WIN); - RNA_def_property_ui_text(prop, "Properties Windows", ""); + RNA_def_property_ui_text(prop, "Property Editors", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); prop= RNA_def_property(srna, "play_image", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_ALL_IMAGE_WIN); - RNA_def_property_ui_text(prop, "Image Windows", ""); + RNA_def_property_ui_text(prop, "Image Editors", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); prop= RNA_def_property(srna, "play_sequencer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_SEQ); - RNA_def_property_ui_text(prop, "Sequencer Windows", ""); + RNA_def_property_ui_text(prop, "Sequencer Editors", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); prop= RNA_def_property(srna, "play_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_NODES); - RNA_def_property_ui_text(prop, "Node Windows", ""); + RNA_def_property_ui_text(prop, "Node Editors", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update"); /* Other options */ @@ -1572,7 +1572,15 @@ static void rna_def_space_console(BlenderRNA *brna) RNA_def_property_enum_items(prop, console_type_items); RNA_def_property_ui_text(prop, "Type", "Console type."); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); + + prop= RNA_def_property(srna, "selection_start", PROP_INT, PROP_UNSIGNED); /* copied from text editor */ + RNA_def_property_int_sdna(prop, NULL, "sel_start"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); + prop= RNA_def_property(srna, "selection_end", PROP_INT, PROP_UNSIGNED); /* copied from text editor */ + RNA_def_property_int_sdna(prop, NULL, "sel_end"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); + /* reporting display */ prop= RNA_def_property(srna, "show_report_debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_DEBUG); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 19d33465ceb..79a75c89a08 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1598,7 +1598,7 @@ static void rna_def_texture_pointdensity(BlenderRNA *brna) prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); - RNA_def_property_range(prop, 0.01, FLT_MAX); + RNA_def_property_range(prop, 0.001, FLT_MAX); RNA_def_property_ui_text(prop, "Radius", "Radius from the shaded sample to look for points within"); RNA_def_property_update(prop, 0, "rna_Texture_update"); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index cbd524680c1..695eb76cb53 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -573,6 +573,7 @@ static void rna_def_panel(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + PropertyRNA *parm; FunctionRNA *func; srna= RNA_def_struct(brna, "Panel", NULL); @@ -586,18 +587,21 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_function_ui_description(func, "Test if the panel is visible or not."); RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); /* draw */ func= RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, "Draw buttons into the panel UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); func= RNA_def_function(srna, "draw_header", NULL); RNA_def_function_ui_description(func, "Draw buttons into the panel header UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "UILayout"); @@ -641,6 +645,7 @@ static void rna_def_header(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + PropertyRNA *parm; FunctionRNA *func; srna= RNA_def_struct(brna, "Header", NULL); @@ -653,7 +658,8 @@ static void rna_def_header(BlenderRNA *brna) func= RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, "Draw buttons into the header UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); RNA_define_verify_sdna(0); // not in sdna @@ -678,6 +684,7 @@ static void rna_def_menu(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + PropertyRNA *parm; FunctionRNA *func; srna= RNA_def_struct(brna, "Menu", NULL); @@ -691,13 +698,15 @@ static void rna_def_menu(BlenderRNA *brna) RNA_def_function_ui_description(func, "Test if the menu is visible or not."); RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); /* draw */ func= RNA_def_function(srna, "draw", NULL); RNA_def_function_ui_description(func, "Draw buttons into the menu UI layout."); RNA_def_function_flag(func, FUNC_REGISTER); - RNA_def_pointer(func, "context", "Context", "", ""); + parm= RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); RNA_define_verify_sdna(0); // not in sdna diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 67383074497..011235c862f 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -269,6 +269,15 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block."); RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); + func= RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block."); + RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block."); + RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); + RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX); + RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX); + func= RNA_def_function(srna, "template_any_ID", "uiTemplateAnyID"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); @@ -311,6 +320,7 @@ void RNA_api_ui_layout(StructRNA *srna) api_ui_item_rna_common(func); RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display."); RNA_def_boolean(func, "levels", 0, "", "Show black/white levels."); + RNA_def_boolean(func, "brush", 0, "", "Show brush options."); func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp"); api_ui_item_rna_common(func); @@ -325,6 +335,10 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); + func= RNA_def_function(srna, "template_color_wheel", "uiTemplateColorWheel"); + api_ui_item_rna_common(func); + RNA_def_boolean(func, "value_slider", 0, "", "Display the value slider to the right of the color wheel"); + func= RNA_def_function(srna, "template_triColorSet", "uiTemplateTriColorSet"); api_ui_item_rna_common(func); @@ -353,6 +367,7 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_string(func, "active_property", "", 0, "", "Identifier of property in data, for the active element."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX); + parm= RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Maximum number of rows to display.", 0, INT_MAX); parm= RNA_def_enum(func, "type", list_type_items, 0, "Type", "Type of list to use."); func= RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 60c6cd61571..807bbdf16e1 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1444,7 +1444,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem active_theme_group[] = { + static EnumPropertyItem active_theme_area[] = { {0, "USER_INTERFACE", ICON_UI, "User Interface", ""}, {1, "VIEW_3D", ICON_VIEW3D, "3D View", ""}, {2, "TIMELINE", ICON_TIME, "Timeline", ""}, @@ -1472,10 +1472,10 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Name of the theme."); RNA_def_struct_name_property(srna, prop); - prop= RNA_def_property(srna, "active_theme", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "active_theme_group"); - RNA_def_property_enum_items(prop, active_theme_group); - RNA_def_property_ui_text(prop, "Active Theme", ""); + prop= RNA_def_property(srna, "theme_area", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "active_theme_area"); + RNA_def_property_enum_items(prop, active_theme_area); + RNA_def_property_ui_text(prop, "Active Theme Area", ""); prop= RNA_def_property(srna, "user_interface", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -1821,8 +1821,6 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_range(prop, 4, 10); RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display."); RNA_def_property_update(prop, 0, "rna_userdef_update"); - - } static void rna_def_userdef_edit(BlenderRNA *brna) @@ -1851,7 +1849,6 @@ static void rna_def_userdef_edit(BlenderRNA *brna) {USER_ADD_VIEWALIGNED, "VIEW", 0, "View", "Align newly added objects to the world coordinates"}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "UserPreferencesEdit", NULL); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "UserPreferences"); @@ -1937,7 +1934,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_enum_items(prop, new_interpolation_types); RNA_def_property_enum_sdna(prop, NULL, "ipo_new"); RNA_def_property_ui_text(prop, "New Interpolation Type", ""); - + prop= RNA_def_property(srna, "grease_pencil_manhattan_distance", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gp_manhattendist"); RNA_def_property_range(prop, 0, 100); @@ -2085,7 +2082,14 @@ static void rna_def_userdef_system(BlenderRNA *brna) {USER_DRAW_OVERLAP, "OVERLAP", 0, "Overlap", "Redraw all overlapping regions, minimal memory usage but more redraws."}, {USER_DRAW_FULL, "FULL", 0, "Full", "Do a full redraw each time, slow, only use for reference or when all else fails."}, {0, NULL, 0, NULL, NULL}}; - + + static EnumPropertyItem color_picker_types[] = { + {USER_CP_CIRCLE, "CIRCLE", 0, "Circle", "A circular Hue/Saturation color wheel, with Value slider"}, + {USER_CP_SQUARE_SV, "SQUARE_SV", 0, "Square (SV + H)", "A square showing Saturation/Value, with Hue slider"}, + {USER_CP_SQUARE_HS, "SQUARE_HS", 0, "Square (HS + V)", "A square showing Hue/Saturation, with Value slider"}, + {USER_CP_SQUARE_HV, "SQUARE_HV", 0, "Square (HV + S)", "A square showing Hue/Value, with Saturation slider"}, + {0, NULL, 0, NULL, NULL}}; + /* hardcoded here, could become dynamic somehow */ static EnumPropertyItem language_items[] = { {0, "ENGLISH", 0, "English", ""}, @@ -2182,6 +2186,11 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Weight Color Range", "Color range used for weight visualization in weight painting mode."); RNA_def_property_update(prop, 0, "rna_UserDef_weight_color_update"); + prop= RNA_def_property(srna, "color_picker_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, color_picker_types); + RNA_def_property_enum_sdna(prop, NULL, "color_picker_type"); + RNA_def_property_ui_text(prop, "Color Picker Type", "Different styles of displaying the color picker widget"); + prop= RNA_def_property(srna, "enable_all_codecs", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ALLWINCODECS); RNA_def_property_ui_text(prop, "Enable All Codecs", "Enables automatic saving of preview images in the .blend file (Windows only)."); @@ -2205,10 +2214,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_range(prop, 0, 32727); RNA_def_property_ui_text(prop, "Frame Server Port", "Frameserver Port for Framserver-Rendering."); - prop= RNA_def_property(srna, "game_sound", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_SOUND); - RNA_def_property_ui_text(prop, "Game Sound", "Enables sounds to be played in games."); - prop= RNA_def_property(srna, "clip_alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "glalphaclip"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -2222,6 +2227,10 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_VBO); RNA_def_property_ui_text(prop, "VBOs", "Use Vertex Buffer Objects (or Vertex Arrays, if unsupported) for viewport rendering."); + prop= RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflags", USER_DISABLE_AA); + RNA_def_property_ui_text(prop, "Anti-aliasing", "Use anti-aliasing for the 3D view (may impact redraw performance)"); + prop= RNA_def_property(srna, "gl_texture_limit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "glreslimit"); RNA_def_property_enum_items(prop, gl_texture_clamp_items); diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index aa2aaaf6342..db576207eae 100644 --- a/source/blender/makesrna/intern/rna_vfont.c +++ b/source/blender/makesrna/intern/rna_vfont.c @@ -43,7 +43,7 @@ void RNA_def_vfont(BlenderRNA *brna) srna= RNA_def_struct(brna, "VectorFont", "ID"); RNA_def_struct_ui_text(srna, "Vector Font", "Vector font for Text objects."); RNA_def_struct_sdna(srna, "VFont"); - RNA_def_struct_ui_icon(srna, ICON_FONT_DATA); + RNA_def_struct_ui_icon(srna, ICON_FILE_FONT); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 7abba3c004a..a3a2bc35dc1 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -64,6 +64,7 @@ EnumPropertyItem event_value_items[] = { {KM_PRESS, "PRESS", 0, "Press", ""}, {KM_RELEASE, "RELEASE", 0, "Release", ""}, {KM_CLICK, "CLICK", 0, "Click", ""}, + {KM_DBL_CLICK, "DOUBLECLICK", 0, "Double Click", ""}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem event_tweak_type_items[]= { @@ -84,6 +85,9 @@ EnumPropertyItem event_mouse_type_items[]= { {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""}, + {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, + {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, + {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, {0, "", 0, NULL, NULL}, {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""}, {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""}, @@ -111,6 +115,9 @@ EnumPropertyItem event_type_items[] = { {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""}, + {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, + {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, + {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, {0, "", 0, NULL, NULL}, {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""}, {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""}, @@ -692,6 +699,7 @@ static void operator_draw(bContext *C, wmOperator *op) } void operator_wrapper(wmOperatorType *ot, void *userdata); +void macro_wrapper(wmOperatorType *ot, void *userdata); static char _operator_idname[OP_MAX_TYPENAME]; static char _operator_name[OP_MAX_TYPENAME]; @@ -763,12 +771,84 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports, return dummyot.ext.srna; } + +static StructRNA *rna_MacroOperator_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + wmOperatorType dummyot = {0}; + wmOperator dummyop= {0}; + PointerRNA dummyotr; + int have_function[4]; + + /* setup dummy operator & operator type to store static properties in */ + dummyop.type= &dummyot; + dummyot.idname= _operator_idname; /* only assigne the pointer, string is NULL'd */ + dummyot.name= _operator_name; /* only assigne the pointer, string is NULL'd */ + dummyot.description= _operator_descr; /* only assigne the pointer, string is NULL'd */ + RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr); + + /* validate the python class */ + if(validate(&dummyotr, data, have_function) != 0) + return NULL; + + { /* convert foo.bar to FOO_OT_bar + * allocate the description and the idname in 1 go */ + int idlen = strlen(_operator_idname) + 4; + int namelen = strlen(_operator_name) + 1; + int desclen = strlen(_operator_descr) + 1; + char *ch, *ch_arr; + ch_arr= ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */ + WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */ + dummyot.idname= ch; + ch += idlen; + strcpy(ch, _operator_name); + dummyot.name = ch; + ch += namelen; + strcpy(ch, _operator_descr); + dummyot.description = ch; + } + + if(strlen(identifier) >= sizeof(dummyop.idname)) { + BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyop.idname)); + return NULL; + } + + /* check if we have registered this operator type before, and remove it */ + { + wmOperatorType *ot= WM_operatortype_exists(dummyot.idname); + if(ot && ot->ext.srna) + rna_Operator_unregister(C, ot->ext.srna); + } + + /* create a new menu type */ + dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator"); + dummyot.ext.data= data; + dummyot.ext.call= call; + dummyot.ext.free= free; + + dummyot.pyop_poll= (have_function[0])? operator_poll: NULL; + dummyot.ui= (have_function[3])? operator_draw: NULL; + + WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot); + + /* update while blender is running */ + if(C) + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + + return dummyot.ext.srna; +} + static StructRNA* rna_Operator_refine(PointerRNA *opr) { wmOperator *op= (wmOperator*)opr->data; return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Operator; } +static StructRNA* rna_MacroOperator_refine(PointerRNA *opr) +{ + wmOperator *op= (wmOperator*)opr->data; + return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Macro; +} + #else static void rna_def_operator(BlenderRNA *brna) @@ -808,6 +888,11 @@ static void rna_def_operator(BlenderRNA *brna) RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ RNA_def_property_flag(prop, PROP_REGISTER); + prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->description"); + RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + RNA_def_property_flag(prop, PROP_REGISTER); + prop= RNA_def_property(srna, "bl_register", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "type->flag", OPTYPE_REGISTER); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); @@ -832,6 +917,8 @@ static void rna_def_macro_operator(BlenderRNA *brna) srna= RNA_def_struct(brna, "Macro", NULL); RNA_def_struct_ui_text(srna, "Macro Operator", "Storage of a macro operator being executed, or registered after execution."); RNA_def_struct_sdna(srna, "wmOperator"); + RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine"); + RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister"); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -844,6 +931,32 @@ static void rna_def_macro_operator(BlenderRNA *brna) RNA_def_property_struct_type(prop, "OperatorProperties"); RNA_def_property_ui_text(prop, "Properties", ""); RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL); + + /* Registration */ + prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->idname"); + RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */ + RNA_def_property_flag(prop, PROP_REGISTER); + + prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->name"); + RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + RNA_def_property_flag(prop, PROP_REGISTER); + + prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->description"); + RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */ + RNA_def_property_flag(prop, PROP_REGISTER); + + prop= RNA_def_property(srna, "bl_register", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", OPTYPE_REGISTER); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + + prop= RNA_def_property(srna, "bl_undo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", OPTYPE_UNDO); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + + RNA_api_macro(srna); } static void rna_def_operator_type_macro(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 7bf4053f539..d57b76a00e1 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -237,6 +237,35 @@ void RNA_api_operator(StructRNA *srna) RNA_def_pointer(func, "context", "Context", "", ""); } +void RNA_api_macro(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + /* utility, not for registering */ + func= RNA_def_function(srna, "report", "rna_Operator_report"); + parm= RNA_def_enum(func, "type", wm_report_items, 0, "Type", ""); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_ENUM_FLAG); + parm= RNA_def_string(func, "message", "", 0, "Report Message", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + + + /* Registration */ + + /* poll */ + func= RNA_def_function(srna, "poll", NULL); + RNA_def_function_ui_description(func, "Test if the operator can be called or not."); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); + RNA_def_pointer(func, "context", "Context", "", ""); + + /* draw */ + func= RNA_def_function(srna, "draw", NULL); + RNA_def_function_ui_description(func, "Draw function for the operator."); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_pointer(func, "context", "Context", "", ""); +} + void RNA_api_keyconfig(StructRNA *srna) { FunctionRNA *func; |