diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-07-11 13:14:12 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-07-11 13:14:12 +0400 |
commit | 3ad64726eeb358ce4358df7942315578c0472124 (patch) | |
tree | 03e737932655110391dc7d02e4d002729ccdbf30 /source/blender/makesrna | |
parent | 797c6a2295f47f1c3a71f9094c710316cdf2ecf3 (diff) | |
parent | a7287165dbd4d0fbbe446a7bb71fd2b947bcf4f8 (diff) |
Merge from 2.5 -r 21285:21515. Thanks Joshua!
Diffstat (limited to 'source/blender/makesrna')
33 files changed, 2087 insertions, 512 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index d69439e25bc..3631d83310a 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -174,12 +174,14 @@ extern StructRNA RNA_ExplodeModifier; extern StructRNA RNA_ExpressionController; extern StructRNA RNA_Event; extern StructRNA RNA_FCurve; +extern StructRNA RNA_FCurveSample; extern StructRNA RNA_FileSelectParams; extern StructRNA RNA_FModifier; extern StructRNA RNA_FModifierCycles; extern StructRNA RNA_FModifierEnvelope; +extern StructRNA RNA_FModifierEnvelopeControlPoint; +extern StructRNA RNA_FModifierFunctionGenerator; extern StructRNA RNA_FModifierGenerator; -extern StructRNA RNA_FModifierGenerator_Function; extern StructRNA RNA_FModifierGenerator_PolyExpanded; extern StructRNA RNA_FModifierLimits; extern StructRNA RNA_FModifierNoise; @@ -274,6 +276,8 @@ extern StructRNA RNA_MultiresModifier; extern StructRNA RNA_MusgraveTexture; extern StructRNA RNA_NandController; extern StructRNA RNA_NearSensor; +extern StructRNA RNA_NlaTrack; +extern StructRNA RNA_NlaStrip; extern StructRNA RNA_Node; extern StructRNA RNA_NodeTree; extern StructRNA RNA_NoiseTexture; @@ -360,13 +364,16 @@ extern StructRNA RNA_ShrinkwrapModifier; extern StructRNA RNA_SimpleDeformModifier; extern StructRNA RNA_SmoothModifier; extern StructRNA RNA_SoftBodySettings; -extern StructRNA RNA_SoftbodyModifier; +extern StructRNA RNA_SoftBodyModifier; extern StructRNA RNA_Sound; extern StructRNA RNA_SoundSequence; extern StructRNA RNA_Space; extern StructRNA RNA_Space3DView; extern StructRNA RNA_SpaceButtonsWindow; +extern StructRNA RNA_SpaceDopeSheetEditor; +extern StructRNA RNA_SpaceGraphEditor; extern StructRNA RNA_SpaceImageEditor; +extern StructRNA RNA_SpaceNLA; extern StructRNA RNA_SpaceOutliner; extern StructRNA RNA_SpaceSequenceEditor; extern StructRNA RNA_SpaceTextEditor; @@ -381,6 +388,7 @@ extern StructRNA RNA_StucciTexture; extern StructRNA RNA_SubsurfModifier; extern StructRNA RNA_SunLamp; extern StructRNA RNA_SurfaceCurve; +extern StructRNA RNA_SurfaceModifier; extern StructRNA RNA_TexMapping; extern StructRNA RNA_Text; extern StructRNA RNA_TextBox; @@ -495,6 +503,7 @@ int RNA_struct_ui_icon(StructRNA *type); PropertyRNA *RNA_struct_name_property(StructRNA *type); PropertyRNA *RNA_struct_iterator_property(StructRNA *type); +StructRNA *RNA_struct_base(StructRNA *type); int RNA_struct_is_ID(StructRNA *type); int RNA_struct_is_a(StructRNA *type, StructRNA *srna); @@ -546,12 +555,12 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin, void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax); void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision); -int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier); -int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name); +int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier); +int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name); -void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem); -int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value); -int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier); +void RNA_property_enum_items(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free); +int RNA_property_enum_value(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value); +int RNA_property_enum_identifier(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier); StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop); @@ -675,11 +684,11 @@ void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values) int RNA_enum_get(PointerRNA *ptr, const char *name); void RNA_enum_set(PointerRNA *ptr, const char *name, int value); -int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname); +int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, const char *enumname); /* lower level functions that donr use a PointerRNA */ -int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value); -int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier); +int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value); +int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier); void RNA_string_get(PointerRNA *ptr, const char *name, char *value); char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen); diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 85a148be2e2..a3fa97bf4b1 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -81,6 +81,7 @@ PropertyRNA *RNA_def_string_file_path(StructOrFunctionRNA *cont, const char *ide PropertyRNA *RNA_def_string_dir_path(StructOrFunctionRNA *cont, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description); PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description); +void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc); PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); @@ -159,6 +160,13 @@ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret); void RNA_def_function_flag(FunctionRNA *func, int flag); void RNA_def_function_ui_description(FunctionRNA *func, const char *description); +/* Dynamic Enums + * strings are not freed, assumed pointing to static location. */ + +void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item); +void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item); +void RNA_enum_item_end(EnumPropertyItem **items, int *totitem); + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 923191cba78..dc2a2a1a1de 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -149,8 +149,6 @@ typedef struct RawArray { int stride; } RawArray; -/* Iterator Utility */ - typedef struct EnumPropertyItem { int value; const char *identifier; @@ -159,6 +157,8 @@ typedef struct EnumPropertyItem { const char *description; } EnumPropertyItem; +typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, int *free); + typedef struct PropertyRNA PropertyRNA; /* Parameter List */ diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 963e4f9aeff..3400b69ee38 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -62,6 +62,10 @@ IF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) +IF(NOT WITH_ELBEEM) + ADD_DEFINITIONS(-DDISABLE_ELBEEM) +ENDIF(NOT WITH_ELBEEM) + # Build makesrna executable ADD_EXECUTABLE(makesrna ${SRC} ${INC_FILES}) TARGET_LINK_LIBRARIES(makesrna bf_dna) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index fb2d052e241..d7c9ffe9800 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -119,6 +119,11 @@ static void rna_print_c_string(FILE *f, const char *str) static char *escape[] = {"\''", "\"\"", "\??", "\\\\","\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", NULL}; int i, j; + if(!str) { + fprintf(f, "NULL"); + return; + } + fprintf(f, "\""); for(i=0; str[i]; i++) { for(j=0; escape[j]; j++) @@ -262,7 +267,8 @@ static int rna_enum_bitmask(PropertyRNA *prop) if(eprop->item) { for(a=0; a<eprop->totitem; a++) - mask |= eprop->item[a].value; + if(eprop->item[a].identifier[0]) + mask |= eprop->item[a].value; } return mask; @@ -971,7 +977,8 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR fprintf(f, "enum {\n"); for(i=0; i<eprop->totitem; i++) - fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value); + if(eprop->item[i].identifier[0]) + fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value); fprintf(f, "};\n\n"); } @@ -1059,7 +1066,8 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property fprintf(f, "\tenum %s_enum {\n", prop->identifier); for(i=0; i<eprop->totitem; i++) - fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value); + if(eprop->item[i].identifier[0]) + fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value); fprintf(f, "\t};\n"); } @@ -1568,29 +1576,27 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr int i, defaultfound= 0; if(eprop->item) { - fprintf(f, "static EnumPropertyItem rna_%s%s_%s_items[%d] = {", srna->identifier, strnest, prop->identifier, eprop->totitem); + fprintf(f, "static EnumPropertyItem rna_%s%s_%s_items[%d] = {", srna->identifier, strnest, prop->identifier, eprop->totitem+1); for(i=0; i<eprop->totitem; i++) { fprintf(f, "{%d, ", eprop->item[i].value); rna_print_c_string(f, eprop->item[i].identifier); fprintf(f, ", "); fprintf(f, "%d, ", eprop->item[i].icon); rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", "); - rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}"); - if(i != eprop->totitem-1) - fprintf(f, ", "); + rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}, "); - if(eprop->defaultvalue == eprop->item[i].value) - defaultfound= 1; + if(eprop->item[i].identifier[0]) + if(eprop->defaultvalue == eprop->item[i].value) + defaultfound= 1; } - fprintf(f, "};\n\n"); + fprintf(f, "{0, NULL, 0, NULL, NULL}};\n\n"); if(!defaultfound) { fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default is not in items.\n", srna->identifier, errnest, prop->identifier); DefRNA.error= 1; } } - else if(eprop->itemf); else { fprintf(stderr, "rna_generate_structs: %s%s.%s, enum must have items defined.\n", srna->identifier, errnest, prop->identifier); DefRNA.error= 1; @@ -1915,6 +1921,7 @@ RNAProcessItem PROCESS_ITEMS[]= { {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, {"rna_meta.c", NULL, RNA_def_meta}, {"rna_modifier.c", NULL, RNA_def_modifier}, + {"rna_nla.c", NULL, RNA_def_nla}, {"rna_nodetree.c", NULL, RNA_def_nodetree}, {"rna_object.c", "rna_object_api.c", RNA_def_object}, {"rna_object_force.c", NULL, RNA_def_object_force}, diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9ebb778707c..f20df81d6ad 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -392,6 +392,11 @@ PropertyRNA *RNA_struct_iterator_property(StructRNA *type) return type->iteratorproperty; } +StructRNA *RNA_struct_base(StructRNA *type) +{ + return type->base; +} + int RNA_struct_is_ID(StructRNA *type) { return (type->flag & STRUCT_ID) != 0; @@ -635,17 +640,19 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop) return &RNA_UnknownType; } -void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem) +void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free) { EnumPropertyRNA *eprop= (EnumPropertyRNA*)rna_ensure_property(prop); int tot; - if(eprop->itemf) { - *item= eprop->itemf(ptr); - if(totitem) { + *free= 0; + + if(C && eprop->itemf) { + *item= eprop->itemf(C, ptr, free); + + if(totitem) for(tot=0; (*item)[tot].identifier; tot++); - *totitem= tot; - } + *totitem= tot; } else { *item= eprop->item; @@ -654,26 +661,30 @@ void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPrope } } -int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value) +int RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value) { - const EnumPropertyItem *item; + EnumPropertyItem *item; + int free; - RNA_property_enum_items(ptr, prop, &item, NULL); + RNA_property_enum_items(C, ptr, prop, &item, NULL, &free); for(; item->identifier; item++) { - if(strcmp(item->identifier, identifier)==0) { + if(item->identifier[0] && strcmp(item->identifier, identifier)==0) { *value = item->value; return 1; } } + if(free) + MEM_freeN(item); + return 0; } -int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier) +int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier) { for (; item->identifier; item++) { - if(item->value==value) { + if(item->identifier[0] && item->value==value) { *identifier = item->identifier; return 1; } @@ -681,10 +692,10 @@ int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const cha return 0; } -int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name) +int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name) { for (; item->identifier; item++) { - if(item->value==value) { + if(item->identifier[0] && item->value==value) { *name = item->name; return 1; } @@ -692,12 +703,17 @@ int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **na return 0; } -int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier) +int RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier) { - const EnumPropertyItem *item= NULL; + EnumPropertyItem *item= NULL; + int result, free; - RNA_property_enum_items(ptr, prop, &item, NULL); - return RNA_enum_identifier(item, value, identifier); + RNA_property_enum_items(C, ptr, prop, &item, NULL, &free); + result= RNA_enum_identifier(item, value, identifier); + if(free) + MEM_freeN(item); + + return result; } const char *RNA_property_ui_name(PropertyRNA *prop) @@ -2379,18 +2395,22 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value) printf("RNA_enum_set: %s.%s not found.\n", ptr->type->identifier, name); } -int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname) +int RNA_enum_is_equal(bContext *C, PointerRNA *ptr, const char *name, const char *enumname) { PropertyRNA *prop= RNA_struct_find_property(ptr, name); - const EnumPropertyItem *item; + EnumPropertyItem *item; + int free; if(prop) { - RNA_property_enum_items(ptr, prop, &item, NULL); + RNA_property_enum_items(C, ptr, prop, &item, NULL, &free); for(; item->identifier; item++) if(strcmp(item->identifier, enumname) == 0) return (item->value == RNA_property_enum_get(ptr, prop)); + if(free) + MEM_freeN(item); + printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname); return 0; } @@ -2400,7 +2420,7 @@ int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname) } } -int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value) +int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value) { for( ; item->identifier; item++) { if(strcmp(item->identifier, identifier)==0) { @@ -2412,7 +2432,7 @@ int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, return 0; } -int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier) +int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier) { for( ; item->identifier; item++) { if(item->value==value) { @@ -2654,7 +2674,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop) const char *identifier; int val = RNA_property_enum_get(ptr, prop); - if(RNA_property_enum_identifier(ptr, prop, val, &identifier)) { + if(RNA_property_enum_identifier(NULL, ptr, prop, val, &identifier)) { BLI_dynstr_appendf(dynstr, "'%s'", identifier); } else { @@ -3050,23 +3070,46 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop if(prop->flag & PROP_RNAPTR) { *((PointerRNA*)dest)= *((PointerRNA*)src); + break; + } + + if (ptype!=srna && !RNA_struct_is_a(srna, ptype)) { + fprintf(stderr, "%s.%s: wrong type for parameter %s, an object of type %s was expected, passed an object of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna)); + return -1; } - else if (ptype!=srna) { - if (!RNA_struct_is_a(srna, ptype)) { - fprintf(stderr, "%s.%s: wrong type for parameter %s, an object of type %s was expected, passed an object of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(ptype)); - return -1; - } - - *((void**)dest)= *((void**)src); - } + + *((void**)dest)= *((void**)src); break; } case PROP_COLLECTION: { - /* XXX collections are not supported yet */ - fprintf(stderr, "%s.%s: for parameter %s, collections are not supported yet\n", tid, fid, pid); - return -1; + StructRNA *ptype; + ListBase *lb, *clb; + Link *link; + CollectionPointerLink *clink; + + if (ftype!='C') { + fprintf(stderr, "%s.%s: wrong type for parameter %s, a collection was expected\n", tid, fid, pid); + return -1; + } + + lb= (ListBase *)src; + clb= (ListBase *)dest; + ptype= RNA_property_pointer_type(ptr, prop); + + if (ptype!=srna && !RNA_struct_is_a(srna, ptype)) { + fprintf(stderr, "%s.%s: wrong type for parameter %s, a collection of objects of type %s was expected, passed a collection of objects of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna)); + return -1; + } + + for (link= lb->first; link; link= link->next) { + clink= MEM_callocN(sizeof(CollectionPointerLink), "CCollectionPointerLink"); + RNA_pointer_create(NULL, srna, link, &clink->ptr); + BLI_addtail(clb, clink); + } + + break; } default: { @@ -3164,6 +3207,13 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, iter.data, &arg, srna, tid, fid, pid); break; } + case PROP_COLLECTION: + { + StructRNA *srna= va_arg(args, StructRNA*); + ListBase *arg= va_arg(args, ListBase*); + err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, iter.data, &arg, srna, tid, fid, pid); + break; + } default: { /* handle errors */ @@ -3221,6 +3271,13 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, arg, retdata, srna, tid, fid, pid); break; } + case PROP_COLLECTION: + { + StructRNA *srna= va_arg(args, StructRNA*); + ListBase **arg= va_arg(args, ListBase**); + err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, arg, retdata, srna, tid, fid, pid); + break; + } default: { /* handle errors */ @@ -3249,3 +3306,4 @@ int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, Pointer return 0; } + diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 2ed47effec1..3469d716853 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -184,7 +184,7 @@ void rna_def_animdata(BlenderRNA *brna) /* NLA */ prop= RNA_def_property(srna, "nla_tracks", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "nla_tracks", NULL); - RNA_def_property_struct_type(prop, "UnknownType"); // XXX! + RNA_def_property_struct_type(prop, "NlaTrack"); RNA_def_property_ui_text(prop, "NLA Tracks", "NLA Tracks (i.e. Animation Layers)."); /* Action */ diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 8200a21f4ac..56c0ca1b491 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -38,36 +38,47 @@ EnumPropertyItem constraint_type_items[] ={ {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", 0, "Child Of", ""}, {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", 0, "Transformation", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", 0, "Copy Location", ""}, {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", 0, "Copy Rotation", ""}, {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", 0, "Copy Scale", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", 0, "Limit Location", ""}, {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", 0, "Limit Rotation", ""}, {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", 0, "Limit Scale", ""}, {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", 0, "Limit Distance", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", 0, "Track To", ""}, {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", 0, "Locked Track", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_MINMAX, "FLOOR", 0, "Floor", ""}, {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", 0, "Shrinkwrap", ""}, {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", 0, "Follow Path", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", 0, "Clamp To", ""}, {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", 0, "Stretch To", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_KINEMATIC, "IK", 0, "IK", ""}, {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", 0, "Rigid Body Joint", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_ACTION, "ACTION", 0, "Action", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_PYTHON, "SCRIPT", 0, "Script", ""}, - + {0, "", 0, NULL, NULL}, {CONSTRAINT_TYPE_NULL, "NULL", 0, "Null", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem space_pchan_items[] = { + {0, "WORLD", 0, "World Space", ""}, + {2, "POSE", 0, "Pose Space", ""}, + {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""}, + {1, "LOCAL", 0, "Local Space", ""}, + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem space_object_items[] = { + {0, "WORLD", 0, "World Space", ""}, + {1, "LOCAL", 0, "Local (Without Parent) Space", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -166,19 +177,7 @@ static void rna_Constraint_influence_update(bContext *C, PointerRNA *ptr) rna_Constraint_update(C, ptr); } -static EnumPropertyItem space_pchan_items[] = { - {0, "WORLD", 0, "World Space", ""}, - {2, "POSE", 0, "Pose Space", ""}, - {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""}, - {1, "LOCAL", 0, "Local Space", ""}, - {0, NULL, 0, NULL, NULL}}; - -static EnumPropertyItem space_object_items[] = { - {0, "WORLD", 0, "World Space", ""}, - {1, "LOCAL", 0, "Local (Without Parent) Space", ""}, - {0, NULL, 0, NULL, NULL}}; - -static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr) +static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRNA *ptr, int *free) { Object *ob= (Object*)ptr->id.data; bConstraint *con= (bConstraint*)ptr->data; @@ -189,7 +188,7 @@ static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr) return space_object_items; } -static EnumPropertyItem *rna_Constraint_target_space_itemf(PointerRNA *ptr) +static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerRNA *ptr, int *free) { bConstraint *con= (bConstraint*)ptr->data; bConstraintTypeInfo *cti= constraint_get_typeinfo(con); @@ -535,10 +534,8 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna) srna= RNA_def_struct(brna, "CopyLocationConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copies the location of the target."); - RNA_def_struct_sdna(srna, "bConstraint"); - prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_PERCENTAGE); - RNA_def_property_float_sdna(prop, NULL, "headtail"); + 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"); @@ -731,13 +728,13 @@ static void rna_def_constraint_action(BlenderRNA *brna) prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "start"); - RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the Action to use."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "end"); - RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "End Frame", "Last frame of the Action to use."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -1507,11 +1504,13 @@ void RNA_def_constraint(BlenderRNA *brna) prop= RNA_def_property(srna, "owner_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ownspace"); + RNA_def_property_enum_items(prop, space_pchan_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf"); RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in."); prop= RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "tarspace"); + RNA_def_property_enum_items(prop, space_pchan_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf"); RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in."); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index 378498c8e0a..7fa27348002 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -96,6 +96,12 @@ static PointerRNA rna_Context_scene_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_Scene, CTX_data_scene(C)); } +static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr) +{ + bContext *C= (bContext*)ptr->data; + return rna_pointer_inherit_refine(ptr, &RNA_ToolSettings, CTX_data_tool_settings(C)); +} + #else void RNA_def_context(BlenderRNA *brna) @@ -153,6 +159,12 @@ void RNA_def_context(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Scene"); RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL, NULL); + + prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "ToolSettings"); + RNA_def_property_pointer_funcs(prop, "rna_Context_tool_settings_get", NULL, NULL); + } #endif diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 41a47e279e9..91488aa2a49 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -31,6 +31,7 @@ #include "DNA_curve_types.h" #include "DNA_material_types.h" +#include "DNA_scene_types.h" EnumPropertyItem beztriple_handle_type_items[] = { {HD_FREE, "FREE", 0, "Free", ""}, @@ -558,6 +559,11 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_range(prop, 1, 1024, 1, 0); RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering. Zero skips this property."); + + prop= RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "ctime"); + RNA_def_property_ui_text(prop, "Evaluation Time", "Parametric position along the length of the curve that Objects 'following' it should be at."); + /* pointers */ prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "bevobj"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 715f03bb3f1..07515d3ad56 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1112,12 +1112,12 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item switch(prop->type) { case PROP_ENUM: { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; - eprop->item= item; + eprop->item= (EnumPropertyItem*)item; eprop->totitem= 0; for(i=0; item[i].identifier; i++) { eprop->totitem++; - if(item[i].value == eprop->defaultvalue) + if(item[i].identifier[0] && item[i].value == eprop->defaultvalue) defaultfound= 1; } @@ -1280,7 +1280,7 @@ void RNA_def_property_enum_default(PropertyRNA *prop, int value) eprop->defaultvalue= value; for(i=0; i<eprop->totitem; i++) { - if(eprop->item[i].value == eprop->defaultvalue) + if(eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue) defaultfound= 1; } @@ -1960,6 +1960,12 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, co return prop; } +void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc) +{ + EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; + eprop->itemf= itemfunc; +} + PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax) { @@ -2256,3 +2262,37 @@ int rna_parameter_size(PropertyRNA *parm) return sizeof(void *); } +/* Dynamic Enums */ + +void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item) +{ + EnumPropertyItem *newitems; + int tot= *totitem; + + if(tot == 0) { + *items= MEM_callocN(sizeof(EnumPropertyItem)*8, "RNA_enum_items_add"); + } + else if(tot >= 8 && (tot&(tot-1)) == 0){ + /* power of two > 8 */ + newitems= MEM_callocN(sizeof(EnumPropertyItem)*tot*2, "RNA_enum_items_add"); + memcpy(newitems, *items, sizeof(EnumPropertyItem)*tot); + MEM_freeN(*items); + *items= newitems; + } + + (*items)[tot]= *item; + *totitem= tot+1; +} + +void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item) +{ + for(; item->identifier; item++) + RNA_enum_item_add(items, totitem, item); +} + +void RNA_enum_item_end(EnumPropertyItem **items, int *totitem) +{ + static EnumPropertyItem empty = {0, NULL, 0, NULL, NULL}; + RNA_enum_item_add(items, totitem, &empty); +} + diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 806219ec6bf..95a0482557f 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -37,6 +37,7 @@ EnumPropertyItem fmodifier_type_items[] = { {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""}, {FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""}, + {FMODIFIER_TYPE_FN_GENERATOR, "FNGENERATOR", 0, "Built-In Function", ""}, {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", 0, "Envelope", ""}, {FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""}, {FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""}, @@ -47,62 +48,6 @@ EnumPropertyItem fmodifier_type_items[] = { #ifdef RNA_RUNTIME -float FModGenFunc_amplitude_get(PointerRNA *ptr) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - return (data->coefficients) ? (float)data->coefficients[0] : 1.0f; -} - -void FModGenFunc_amplitude_set(PointerRNA *ptr, float value) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - if (data->coefficients) data->coefficients[0]= value; -} - -float FModGenFunc_pre_multiplier_get(PointerRNA *ptr) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - return (data->coefficients) ? (float)data->coefficients[1] : 1.0f; -} - -void FModGenFunc_pre_multiplier_set(PointerRNA *ptr, float value) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - if (data->coefficients) data->coefficients[1]= value; -} - -float FModGenFunc_x_offset_get(PointerRNA *ptr) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - return (data->coefficients) ? (float)data->coefficients[2] : 0.0f; -} - -void FModGenFunc_x_offset_set(PointerRNA *ptr, float value) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - if (data->coefficients) data->coefficients[2]= value; -} - -float FModGenFunc_y_offset_get(PointerRNA *ptr) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - return (data->coefficients) ? (float)data->coefficients[3] : 0.0f; -} - -void FModGenFunc_y_offset_set(PointerRNA *ptr, float value) -{ - FModifier *fcm = (FModifier *)(ptr->data); - FMod_Generator *data= (FMod_Generator*)(fcm->data); - if (data->coefficients) data->coefficients[3]= value; -} - /* --------- */ StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr) @@ -111,20 +56,9 @@ StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr) switch (fcm->type) { case FMODIFIER_TYPE_GENERATOR: - { - FMod_Generator *gen= (FMod_Generator *)fcm->data; - - switch (gen->mode) { - case FCM_GENERATOR_POLYNOMIAL: - return &RNA_FModifierGenerator_PolyExpanded; - //case FCM_GENERATOR_POLYNOMIAL_FACTORISED: - case FCM_GENERATOR_FUNCTION: - return &RNA_FModifierGenerator_Function; - //case FCM_GENERATOR_EXPRESSION: - default: - return &RNA_FModifierGenerator; - } - } + return &RNA_FModifierGenerator; + case FMODIFIER_TYPE_FN_GENERATOR: + return &RNA_FModifierFunctionGenerator; case FMODIFIER_TYPE_ENVELOPE: return &RNA_FModifierEnvelope; case FMODIFIER_TYPE_CYCLES: @@ -215,21 +149,22 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value) #else -static void rna_def_fmodifier_generator_common(StructRNA *srna) + +static void rna_def_fmodifier_generator(BlenderRNA *brna) { + StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_mode_items[] = { {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""}, {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""}, - {FCM_GENERATOR_FUNCTION, "FUNCTION", 0, "Built-In Function", ""}, - {FCM_GENERATOR_EXPRESSION, "EXPRESSION", 0, "Expression", ""}, {0, NULL, 0, NULL, NULL}}; - - /* struct wrapping settings */ - RNA_def_struct_sdna_from(srna, "FMod_Generator", "data"); - /* settings */ + srna= RNA_def_struct(brna, "FModifierGenerator", "FModifier"); + RNA_def_struct_ui_text(srna, "Generator F-Curve Modifier", "Deterministically generates values for the modified F-Curve."); + RNA_def_struct_sdna_from(srna, "FMod_Generator", "data"); + + /* define common props */ prop= RNA_def_property(srna, "additive", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE); RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them."); @@ -238,42 +173,23 @@ static void rna_def_fmodifier_generator_common(StructRNA *srna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_mode_items); RNA_def_property_ui_text(prop, "Mode", "Type of generator to use."); -} - -/* this is a temporary dummy generator-modifier wrapping (to be discarded) */ -static void rna_def_fmodifier_generator(BlenderRNA *brna) -{ - StructRNA *srna; - - srna= RNA_def_struct(brna, "FModifierGenerator", "FModifier"); - RNA_def_struct_ui_text(srna, "Generator F-Curve Modifier", "Deterministically generates values for the modified F-Curve."); - /* define common props */ - rna_def_fmodifier_generator_common(srna); -} - -static void rna_def_fmodifier_generator_polyexpanded(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna= RNA_def_struct(brna, "FModifierGenerator_PolyExpanded", "FModifier"); - RNA_def_struct_ui_text(srna, "Expanded Polynomial Generator", "Generates values for the modified F-Curve using expanded polynomial expresion."); - - /* define common props */ - rna_def_fmodifier_generator_common(srna); /* order of the polynomial */ // XXX this has a special validation func prop= RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (i.e. the number of coefficients - 1)"); + RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (number of coefficients - 1)"); /* coefficients array */ - //prop= RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE); - //RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power)."); + // FIXME: this is quite difficult to try to wrap + //prop= RNA_def_property(srna, "coefficients", PROP_COLLECTION, PROP_NONE); + //RNA_def_property_collection_funcs(prop, "rna_FModifierGenerator_coefficients_begin", "rna_FModifierGenerator_coefficients_next", "rna_FModifierGenerator_coefficients_end", "rna_iterator_array_get", "rna_FModifierGenerator_coefficients_length", 0, 0, 0, 0); + //RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)."); } -static void rna_def_fmodifier_generator_function(BlenderRNA *brna) +/* --------- */ + +static void rna_def_fmodifier_function_generator(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -284,48 +200,95 @@ static void rna_def_fmodifier_generator_function(BlenderRNA *brna) {2, "TAN", 0, "Tangent", ""}, {3, "SQRT", 0, "Square Root", ""}, {4, "LN", 0, "Natural Logarithm", ""}, + {5, "SINC", 0, "Normalised Sine", "sin(x) / x"}, {0, NULL, 0, NULL, NULL}}; - - - srna= RNA_def_struct(brna, "FModifierGenerator_Function", "FModifier"); - RNA_def_struct_ui_text(srna, "Built-In Function Generator", "Generates values for modified F-Curve using Built-In Function."); - - /* common settings */ - rna_def_fmodifier_generator_common(srna); - /* type */ - prop= RNA_def_property(srna, "func_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Type", "Type of Built-In function to use as generator."); + srna= RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier"); + RNA_def_struct_ui_text(srna, "Built-In Function F-Modifier", "Generates values using a Built-In Function."); + RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data"); /* coefficients */ prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "FModGenFunc_amplitude_get", "FModGenFunc_amplitude_set", NULL); - RNA_def_property_ui_text(prop, "Amplitude", "Scale factor for y-values generated by the function."); + RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values."); - prop= RNA_def_property(srna, "pre_multiplier", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "FModGenFunc_pre_multiplier_get", "FModGenFunc_pre_multiplier_set", NULL); - RNA_def_property_ui_text(prop, "PreMultiplier", "Scale factor for x-value inputs to function."); + prop= RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function."); - prop= RNA_def_property(srna, "x_offset", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "FModGenFunc_x_offset_get", "FModGenFunc_x_offset_set", NULL); - RNA_def_property_ui_text(prop, "X Offset", "Offset for x-value inputs to function."); + prop= RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function."); + + prop= RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by."); + + /* flags */ + prop= RNA_def_property(srna, "additive", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE); + RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them."); - prop= RNA_def_property(srna, "y_offset", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "FModGenFunc_y_offset_get", "FModGenFunc_y_offset_set", NULL); - RNA_def_property_ui_text(prop, "Y Offset", "Offset for y-values generated by the function."); + 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", "Type of built-in function to use."); } /* --------- */ +static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "FModifierEnvelopeControlPoint", NULL); + RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier."); + RNA_def_struct_sdna(srna, "FCM_EnvelopeData"); + + /* min/max extents + * - for now, these are allowed to go past each other, so that we can have inverted action + * - technically, the range is limited by the settings in the envelope-modifier data, not here... + */ + prop= RNA_def_property(srna, "minimum", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "min"); + RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point."); + + prop= RNA_def_property(srna, "maximum", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "max"); + RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point."); + + /* Frame */ + prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "time"); + RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on."); + + // TODO: + // - selection flags (not implemented in UI yet though) +} + static void rna_def_fmodifier_envelope(BlenderRNA *brna) { StructRNA *srna; - //PropertyRNA *prop; + PropertyRNA *prop; srna= RNA_def_struct(brna, "FModifierEnvelope", "FModifier"); - RNA_def_struct_ui_text(srna, "Envelope F-Curve Modifier", "Scales the values of the modified F-Curve."); + RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scales the values of the modified F-Curve."); RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data"); + + /* Collections */ + prop= RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "data", "totvert"); + RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint"); + RNA_def_property_ui_text(prop, "Control Points", "Control points defining the shape of the envelope."); + + /* Range Settings */ + prop= RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "midval"); + RNA_def_property_ui_text(prop, "Reference Value", "Value that envelope's influence is centered around / based on."); + + prop= RNA_def_property(srna, "default_minimum", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "min"); + RNA_def_property_ui_text(prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence."); + + prop= RNA_def_property(srna, "default_maximum", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "max"); + RNA_def_property_ui_text(prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence."); } /* --------- */ @@ -343,7 +306,7 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FModifierCycles", "FModifier"); - RNA_def_struct_ui_text(srna, "Cycles F-Curve Modifier", "Repeats the values of the modified F-Curve."); + RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeats the values of the modified F-Curve."); RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data"); /* before */ @@ -372,7 +335,7 @@ static void rna_def_fmodifier_python(BlenderRNA *brna) //PropertyRNA *prop; srna= RNA_def_struct(brna, "FModifierPython", "FModifier"); - RNA_def_struct_ui_text(srna, "Python F-Curve Modifier", "Performs user-defined operation on the modified F-Curve."); + RNA_def_struct_ui_text(srna, "Python F-Modifier", "Performs user-defined operation on the modified F-Curve."); RNA_def_struct_sdna_from(srna, "FMod_Python", "data"); } @@ -384,7 +347,7 @@ static void rna_def_fmodifier_limits(BlenderRNA *brna) PropertyRNA *prop; srna= RNA_def_struct(brna, "FModifierLimits", "FModifier"); - RNA_def_struct_ui_text(srna, "Limits F-Curve Modifier", "Limits the time/value ranges of the modified F-Curve."); + RNA_def_struct_ui_text(srna, "Limits F-Modifier", "Limits the time/value ranges of the modified F-Curve."); RNA_def_struct_sdna_from(srna, "FMod_Limits", "data"); prop= RNA_def_property(srna, "use_minimum_x", PROP_BOOLEAN, PROP_NONE); @@ -435,7 +398,7 @@ static void rna_def_fmodifier_noise(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FModifierNoise", "FModifier"); - RNA_def_struct_ui_text(srna, "Noise F-Curve Modifier", "Gives randomness to the modified F-Curve."); + RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Gives randomness to the modified F-Curve."); RNA_def_struct_sdna_from(srna, "FMod_Noise", "data"); prop= RNA_def_property(srna, "modification", PROP_ENUM, PROP_NONE); @@ -471,7 +434,7 @@ void rna_def_fmodifier(BlenderRNA *brna) /* base struct definition */ srna= RNA_def_struct(brna, "FModifier", NULL); RNA_def_struct_refine_func(srna, "rna_FModifierType_refine"); - RNA_def_struct_ui_text(srna, "FCurve Modifier", "Modifier for values of F-Curve."); + RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve."); #if 0 // XXX not used yet /* name */ @@ -569,6 +532,27 @@ void rna_def_channeldriver(BlenderRNA *brna) /* *********************** */ +static void rna_def_fpoint(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "FCurveSample", NULL); + RNA_def_struct_sdna(srna, "FPoint"); + RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve."); + + /* Boolean values */ + prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); + RNA_def_property_ui_text(prop, "Selected", "Selection status"); + + /* Vector value */ + prop= RNA_def_property(srna, "point", PROP_FLOAT, PROP_VECTOR); + RNA_def_property_array(prop, 2); + RNA_def_property_float_sdna(prop, NULL, "vec"); + RNA_def_property_ui_text(prop, "Point", "Point coordinates"); +} + void rna_def_fcurve(BlenderRNA *brna) { StructRNA *srna; @@ -619,7 +603,7 @@ void rna_def_fcurve(BlenderRNA *brna) /* Collections */ prop= RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fpt", "totvert"); - RNA_def_property_struct_type(prop, "CurvePoint"); // XXX FPoints not BPoints here! FPoints are much smaller! + RNA_def_property_struct_type(prop, "FCurveSample"); RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data"); prop= RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE); @@ -637,6 +621,7 @@ void rna_def_fcurve(BlenderRNA *brna) void RNA_def_fcurve(BlenderRNA *brna) { rna_def_fcurve(brna); + rna_def_fpoint(brna); rna_def_drivertarget(brna); rna_def_channeldriver(brna); @@ -644,9 +629,9 @@ void RNA_def_fcurve(BlenderRNA *brna) rna_def_fmodifier(brna); rna_def_fmodifier_generator(brna); - rna_def_fmodifier_generator_polyexpanded(brna); - rna_def_fmodifier_generator_function(brna); + rna_def_fmodifier_function_generator(brna); rna_def_fmodifier_envelope(brna); + rna_def_fmodifier_envelope_ctrl(brna); rna_def_fmodifier_cycles(brna); rna_def_fmodifier_python(brna); rna_def_fmodifier_limits(brna); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 4e047ff7772..44a50fbae25 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -31,8 +31,23 @@ #include "DNA_object_fluidsim.h" +#include "WM_api.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "DNA_scene_types.h" +#include "DNA_particle_types.h" + +#include "BKE_depsgraph.h" +#include "BKE_fluidsim.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_particle.h" +#include "BKE_pointcache.h" + static StructRNA* rna_FluidSettings_refine(struct PointerRNA *ptr) { FluidsimSettings *fss= (FluidsimSettings*)ptr->data; @@ -57,6 +72,79 @@ static StructRNA* rna_FluidSettings_refine(struct PointerRNA *ptr) } } +static void rna_FluidSettings_update_type(bContext *C, PointerRNA *ptr) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Object *ob= (Object*)ptr->id.data; + FluidsimModifierData *fluidmd; + ParticleSystemModifierData *psmd; + ParticleSystem *psys; + ParticleSettings *part; + + fluidmd= (FluidsimModifierData*)modifiers_findByType(ob, eModifierType_Fluidsim); + fluidmd->fss->flag &= ~OB_FLUIDSIM_REVERSE; // clear flag + + /* remove fluidsim particle system */ + if(fluidmd->fss->type & OB_FLUIDSIM_PARTICLE) { + for(psys=ob->particlesystem.first; psys; psys=psys->next) + if(psys->part->type == PART_FLUID) + break; + + if(ob->type == OB_MESH && !psys) { + /* add particle system */ + part= psys_new_settings("PSys", bmain); + psys= MEM_callocN(sizeof(ParticleSystem), "particle_system"); + + part->type= PART_FLUID; + psys->part= part; + psys->pointcache= BKE_ptcache_add(); + psys->flag |= PSYS_ENABLED; + BLI_addtail(&ob->particlesystem,psys); + + /* add modifier */ + psmd= (ParticleSystemModifierData*)modifier_new(eModifierType_ParticleSystem); + sprintf(psmd->modifier.name, "FluidParticleSystem" ); + psmd->psys= psys; + BLI_addtail(&ob->modifiers, psmd); + } + } + else { + for(psys=ob->particlesystem.first; psys; psys=psys->next) { + if(psys->part->type == PART_FLUID) { + /* clear modifier */ + psmd= psys_get_modifier(ob, psys); + BLI_remlink(&ob->modifiers, psmd); + modifier_free((ModifierData *)psmd); + + /* clear particle system */ + BLI_remlink(&ob->particlesystem, psys); + psys_free(ob, psys); + } + } + } + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); +} + +static void rna_DomainFluidSettings_memory_estimate_get(PointerRNA *ptr, char *value) +{ +#ifdef DISABLE_ELBEEM + value[0]= '\0'; +#else + Object *ob= (Object*)ptr->id.data; + FluidsimSettings *fss= (FluidsimSettings*)ptr->data; + + fluid_estimate_memory(ob, fss, value); +#endif +} + +static int rna_DomainFluidSettings_memory_estimate_length(PointerRNA *ptr) +{ + return 32; +} + #else static void rna_def_fluidsim_slip(StructRNA *srna) @@ -128,6 +216,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "guiDisplayMode"); RNA_def_property_enum_items(prop, quality_items); RNA_def_property_ui_text(prop, "Viewport Display Mode", "How to display the mesh in the viewport."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "render_display_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "renderDisplayMode"); @@ -142,6 +231,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_string_maxlength(prop, 240); RNA_def_property_string_sdna(prop, NULL, "surfdataPath"); RNA_def_property_ui_text(prop, "Path", "Directory (and/or filename prefix) to store baked fluid simulation files in."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); + + prop= RNA_def_property(srna, "memory_estimate", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_DomainFluidSettings_memory_estimate_get", "rna_DomainFluidSettings_memory_estimate_length", NULL); + RNA_def_property_ui_text(prop, "Memory Estimate", "Estimated amount of memory needed for baking the domain."); /* advanced settings */ @@ -336,6 +431,7 @@ static void rna_def_fluidsim_particle(BlenderRNA *brna) RNA_def_property_string_maxlength(prop, 240); RNA_def_property_string_sdna(prop, NULL, "surfdataPath"); RNA_def_property_ui_text(prop, "Path", "Directory (and/or filename prefix) to store and load particles from."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); } static void rna_def_fluidsim_control(BlenderRNA *brna) @@ -393,7 +489,7 @@ void RNA_def_fluidsim(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_fluid_type_items[] = { - {0, "NONE", 0, "None", ""}, + {OB_FLUIDSIM_ENABLE, "NONE", 0, "None", ""}, {OB_FLUIDSIM_DOMAIN, "DOMAIN", 0, "Domain", "Bounding box of this object represents the computational domain of the fluid simulation."}, {OB_FLUIDSIM_FLUID, "FLUID", 0, "Fluid", "Object represents a volume of fluid in the simulation."}, {OB_FLUIDSIM_OBSTACLE, "OBSTACLE", 0, "Obstacle", "Object is a fixed obstacle."}, @@ -409,18 +505,11 @@ void RNA_def_fluidsim(BlenderRNA *brna) RNA_def_struct_refine_func(srna, "rna_FluidSettings_refine"); RNA_def_struct_ui_text(srna, "Fluid Simulation Settings", "Fluid simulation settings for an object taking part in the simulation."); - /* enable and type */ - - prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "type", OB_FLUIDSIM_ENABLE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // needs to create modifier - RNA_def_property_ui_text(prop, "Enabled", "Sets object to participate in fluid simulation."); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_fluid_type_items); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // needs to update variables RNA_def_property_ui_text(prop, "Type", "Type of participation in the fluid simulation."); + RNA_def_property_update(prop, 0, "rna_FluidSettings_update_type"); //prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); //RNA_def_property_ui_text(prop, "Ipo Curves", "Ipo curves used by fluid simulation settings."); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 7bf33760011..219cc9ccd59 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -139,6 +139,7 @@ void RNA_def_material(struct BlenderRNA *brna); void RNA_def_mesh(struct BlenderRNA *brna); void RNA_def_meta(struct BlenderRNA *brna); void RNA_def_modifier(struct BlenderRNA *brna); +void RNA_def_nla(struct BlenderRNA *brna); void RNA_def_nodetree(struct BlenderRNA *brna); void RNA_def_object(struct BlenderRNA *brna); void RNA_def_object_force(struct BlenderRNA *brna); @@ -185,6 +186,9 @@ void rna_object_vgroup_name_set(struct PointerRNA *ptr, const char *value, char void rna_object_uvlayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen); void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen); +void rna_Object_update(struct bContext *C, struct PointerRNA *ptr); +void rna_Object_update_data(struct bContext *C, struct PointerRNA *ptr); + /* API functions */ void RNA_api_main(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 401b430ebc9..b63e347e165 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -68,7 +68,7 @@ typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr); typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value); typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr); typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value); -typedef EnumPropertyItem *(*PropEnumItemFunc)(struct PointerRNA *ptr); +typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, int *free); typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr); typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr); typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value); @@ -225,7 +225,7 @@ typedef struct EnumPropertyRNA { PropEnumSetFunc set; PropEnumItemFunc itemf; - const EnumPropertyItem *item; + EnumPropertyItem *item; int totitem; int defaultvalue; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 71e424bbd69..0a7e989a93a 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -37,6 +37,16 @@ #ifdef RNA_RUNTIME +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_depsgraph.h" +#include "BKE_key.h" +#include "BKE_main.h" + +#include "WM_api.h" +#include "WM_types.h" + static Key *rna_ShapeKey_find_key(ID *id) { switch(GS(id->name)) { @@ -62,6 +72,18 @@ static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, NULL, NULL); } +static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value) +{ + Key *key= rna_ShapeKey_find_key(ptr->id.data); + KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel; + int a; + + if(key) + for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++) + if(kbrel == value.data) + kb->relative= a; +} + static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values) { float *vec= (float*)ptr->data; @@ -220,6 +242,21 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter) return rna_pointer_inherit_refine(&iter->parent, type, rna_iterator_array_get(iter)); } +static void rna_Key_update_data(bContext *C, PointerRNA *ptr) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Key *key= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob_get_key(ob) == key) { + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + } +} + #else static void rna_def_keydata(BlenderRNA *brna) @@ -234,6 +271,7 @@ static void rna_def_keydata(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); srna= RNA_def_struct(brna, "ShapeKeyCurvePoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Curve Point", "Point in a shape key for curves."); @@ -242,10 +280,12 @@ static void rna_def_keydata(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyPoint_co_get", "rna_ShapeKeyPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_ShapeKeyCurvePoint_tilt_get", "rna_ShapeKeyCurvePoint_tilt_set", NULL); RNA_def_property_ui_text(prop, "Tilt", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); srna= RNA_def_struct(brna, "ShapeKeyBezierPoint", NULL); RNA_def_struct_ui_text(srna, "Shape Key Bezier Point", "Point in a shape key for bezier curves."); @@ -254,21 +294,25 @@ static void rna_def_keydata(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_co_get", "rna_ShapeKeyBezierPoint_co_set", NULL); RNA_def_property_ui_text(prop, "Location", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "handle_1_co", PROP_FLOAT, PROP_VECTOR); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_1_co_get", "rna_ShapeKeyBezierPoint_handle_1_co_set", NULL); RNA_def_property_ui_text(prop, "Handle 1 Location", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "handle_2_co", PROP_FLOAT, PROP_VECTOR); RNA_def_property_array(prop, 3); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_handle_2_co_get", "rna_ShapeKeyBezierPoint_handle_2_co_set", NULL); RNA_def_property_ui_text(prop, "Handle 2 Location", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); /* appears to be unused currently prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_ShapeKeyBezierPoint_tilt_get", "rna_ShapeKeyBezierPoint_tilt_set", NULL); - RNA_def_property_ui_text(prop, "Tilt", "");*/ + RNA_def_property_ui_text(prop, "Tilt", ""); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); */ } static void rna_def_keyblock(BlenderRNA *brna) @@ -296,30 +340,37 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_sdna(prop, NULL, "pos"); RNA_def_property_ui_text(prop, "Frame", "Frame for absolute keys."); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); /* for now, this is editable directly, as users can set this even if they're not animating them (to test results) */ prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "curval"); RNA_def_property_ui_text(prop, "Value", "Value of shape key at the current frame."); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_keyblock_type_items); RNA_def_property_ui_text(prop, "Interpolation", "Interpolation type."); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "vgroup"); RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape."); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "ShapeKey"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", "rna_ShapeKey_relative_key_set", NULL); RNA_def_property_ui_text(prop, "Relative Key", "Shape used as a relative key."); - RNA_def_property_pointer_funcs(prop, "rna_ShapeKey_relative_key_get", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYBLOCK_MUTE); RNA_def_property_ui_text(prop, "Mute", "Mute this shape key."); + RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "slidermin"); @@ -366,11 +417,13 @@ static void rna_def_key(BlenderRNA *brna) prop= RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "type", KEY_RELATIVE); RNA_def_property_ui_text(prop, "Relative", "Makes shape keys relative."); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); prop= RNA_def_property(srna, "slurph", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "slurph"); RNA_def_property_range(prop, -500, 500); RNA_def_property_ui_text(prop, "Slurph", "Creates a delay in amount of frames in applying keypositions, first vertex goes first."); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); } void RNA_def_key(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index f67267ce0d0..c685e5b6912 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -36,6 +36,16 @@ #ifdef RNA_RUNTIME +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_depsgraph.h" +#include "BKE_lattice.h" +#include "BKE_main.h" + +#include "WM_api.h" +#include "WM_types.h" + static void rna_LatticePoint_co_get(PointerRNA *ptr, float *values) { Lattice *lt= (Lattice*)ptr->id.data; @@ -67,15 +77,96 @@ static void rna_LatticePoint_groups_begin(CollectionPropertyIterator *iter, Poin static void rna_Lattice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Lattice *lt= (Lattice*)ptr->data; + int tot= lt->pntsu*lt->pntsv*lt->pntsw; - if(lt->def) { - int tot= lt->pntsu*lt->pntsv*lt->pntsw; + if(lt->editlatt && lt->editlatt->def) + rna_iterator_array_begin(iter, (void*)lt->editlatt->def, sizeof(BPoint), tot, NULL); + else if(lt->def) rna_iterator_array_begin(iter, (void*)lt->def, sizeof(BPoint), tot, NULL); - } else rna_iterator_array_begin(iter, NULL, 0, 0, NULL); } +static void rna_Lattice_update_data(bContext *C, PointerRNA *ptr) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Lattice *lt= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == lt) { + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + } +} + +static void rna_Lattice_update_size(bContext *C, PointerRNA *ptr) +{ + Main *bmain= CTX_data_main(C); + Lattice *lt= ptr->id.data; + Object *ob; + int newu, newv, neww; + + /* we don't modify the actual pnts, but go through opnts instead */ + newu= (lt->opntsu > 0)? lt->opntsu: lt->pntsu; + newv= (lt->opntsv > 0)? lt->opntsv: lt->pntsv; + neww= (lt->opntsw > 0)? lt->opntsw: lt->pntsw; + + /* resizelattice needs an object, any object will have the same result */ + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == lt) { + resizelattice(lt, newu, newv, neww, ob); + if(lt->editlatt) + resizelattice(lt->editlatt, newu, newv, neww, ob); + break; + } + } + + /* otherwise without, means old points are not repositioned */ + if(!ob) { + resizelattice(lt, newu, newv, neww, NULL); + if(lt->editlatt) + resizelattice(lt->editlatt, newu, newv, neww, NULL); + } + + rna_Lattice_update_data(C, ptr); +} + +static void rna_Lattice_outside_set(PointerRNA *ptr, int value) +{ + Lattice *lt= ptr->data; + + if(value) lt->flag |= LT_OUTSIDE; + else lt->flag &= ~LT_OUTSIDE; + + outside_lattice(lt); + + if(lt->editlatt) { + if(value) lt->editlatt->flag |= LT_OUTSIDE; + else lt->editlatt->flag &= ~LT_OUTSIDE; + + outside_lattice(lt->editlatt); + } +} + +static void rna_Lattice_points_u_set(PointerRNA *ptr, int value) +{ + ((Lattice*)ptr->data)->opntsu= CLAMPIS(value, 1, 64); +} + +static void rna_Lattice_points_v_set(PointerRNA *ptr, int value) +{ + ((Lattice*)ptr->data)->opntsv= CLAMPIS(value, 1, 64); +} + +static void rna_Lattice_points_w_set(PointerRNA *ptr, int value) +{ + ((Lattice*)ptr->data)->opntsw= CLAMPIS(value, 1, 64); +} + #else static void rna_def_latticepoint(BlenderRNA *brna) @@ -97,6 +188,7 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "vec"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Deformed Location", ""); + RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); @@ -121,37 +213,48 @@ static void rna_def_lattice(BlenderRNA *brna) prop= RNA_def_property(srna, "points_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "pntsu"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_u_set", NULL); + RNA_def_property_range(prop, 1, 64); RNA_def_property_ui_text(prop, "U", "Points in U direction."); + RNA_def_property_update(prop, 0, "rna_Lattice_update_size"); prop= RNA_def_property(srna, "points_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "pntsv"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_v_set", NULL); + RNA_def_property_range(prop, 1, 64); RNA_def_property_ui_text(prop, "V", "Points in V direction."); + RNA_def_property_update(prop, 0, "rna_Lattice_update_size"); prop= RNA_def_property(srna, "points_w", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "pntsw"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_w_set", NULL); + RNA_def_property_range(prop, 1, 64); RNA_def_property_ui_text(prop, "W", "Points in W direction."); + RNA_def_property_update(prop, 0, "rna_Lattice_update_size"); prop= RNA_def_property(srna, "interpolation_type_u", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typeu"); RNA_def_property_enum_items(prop, prop_keyblock_type_items); RNA_def_property_ui_text(prop, "Interpolation Type U", ""); + RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); prop= RNA_def_property(srna, "interpolation_type_v", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typev"); RNA_def_property_enum_items(prop, prop_keyblock_type_items); RNA_def_property_ui_text(prop, "Interpolation Type V", ""); + RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); prop= RNA_def_property(srna, "interpolation_type_w", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "typew"); RNA_def_property_enum_items(prop, prop_keyblock_type_items); RNA_def_property_ui_text(prop, "Interpolation Type W", ""); + RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); prop= RNA_def_property(srna, "outside", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LT_OUTSIDE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Lattice_outside_set"); RNA_def_property_ui_text(prop, "Outside", "Only draw, and take into account, the outer vertices."); + RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "key"); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 2133ff26157..482029563c2 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -34,13 +34,40 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#ifdef RNA_RUNTIME + +#include "DNA_scene_types.h" + +#include "BLI_editVert.h" + #include "BKE_customdata.h" +#include "BKE_depsgraph.h" +#include "BKE_main.h" +#include "BKE_mesh.h" +#include "BKE_utildefines.h" -#ifdef RNA_RUNTIME +#include "WM_api.h" +#include "WM_types.h" #include "BLI_arithb.h" /* CalcNormFloat */ +static void rna_Mesh_update_data(bContext *C, PointerRNA *ptr) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + ID *id= ptr->id.data; + Object *ob; + + for(ob=bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == id) { + /* XXX this will loop over all objects again (slow) */ + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + } +} + static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value) { MVert *mvert= (MVert*)ptr->data; @@ -206,13 +233,19 @@ static void rna_MeshFace_normal_get(PointerRNA *ptr, float *value) } } +static CustomData *rna_mesh_fdata(Mesh *me) +{ + return (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata; +} + static int rna_CustomDataLayer_length(PointerRNA *ptr, int type) { Mesh *me= (Mesh*)ptr->id.data; + CustomData *fdata= rna_mesh_fdata(me); CustomDataLayer *layer; int i, length= 0; - for(layer=me->fdata.layers, i=0; i<me->fdata.totlayer; layer++, i++) + for(layer=fdata->layers, i=0; i<fdata->totlayer; layer++, i++) if(layer->type == type) length++; @@ -222,64 +255,96 @@ static int rna_CustomDataLayer_length(PointerRNA *ptr, int type) static int rna_CustomDataLayer_active_get(PointerRNA *ptr, int type, int render) { Mesh *me= (Mesh*)ptr->id.data; - int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers; + CustomData *fdata= rna_mesh_fdata(me); + int n= ((CustomDataLayer*)ptr->data) - fdata->layers; - if(render) return (n == CustomData_get_render_layer_index(&me->fdata, type)); - else return (n == CustomData_get_active_layer_index(&me->fdata, type)); + if(render) return (n == CustomData_get_render_layer_index(fdata, type)); + else return (n == CustomData_get_active_layer_index(fdata, type)); } static void rna_CustomDataLayer_active_set(PointerRNA *ptr, int value, int type, int render) { Mesh *me= (Mesh*)ptr->id.data; - int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers; + CustomData *fdata= rna_mesh_fdata(me); + int n= ((CustomDataLayer*)ptr->data) - fdata->layers; if(value == 0) return; - if(render) CustomData_set_layer_render_index(&me->fdata, type, n); - else CustomData_set_layer_active_index(&me->fdata, type, n); + if(render) CustomData_set_layer_render_index(fdata, type, n); + else CustomData_set_layer_active_index(fdata, type, n); } -static int rna_uv_layer_check(CollectionPropertyIterator *iter, void *data) +static int rna_uv_texture_check(CollectionPropertyIterator *iter, void *data) { CustomDataLayer *layer= (CustomDataLayer*)data; return (layer->type != CD_MTFACE); } -static void rna_Mesh_uv_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Mesh_uv_textures_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_uv_layer_check); + CustomData *fdata= rna_mesh_fdata(me); + rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_uv_texture_check); } -static int rna_Mesh_uv_layers_length(PointerRNA *ptr) +static int rna_Mesh_uv_textures_length(PointerRNA *ptr) { return rna_CustomDataLayer_length(ptr, CD_MTFACE); } -static PointerRNA rna_Mesh_active_uv_layer_get(PointerRNA *ptr) +static PointerRNA rna_Mesh_active_uv_texture_get(PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - int index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index]; + CustomData *fdata= rna_mesh_fdata(me); + int index= CustomData_get_active_layer_index(fdata, CD_MTFACE); + CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index]; return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl); } -static void rna_Mesh_active_uv_layer_set(PointerRNA *ptr, PointerRNA value) +static void rna_Mesh_active_uv_texture_set(PointerRNA *ptr, PointerRNA value) { Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); CustomDataLayer *cdl; int a; - for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) { + for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) { if(value.data == cdl) { - CustomData_set_layer_active_index(&me->fdata, CD_MTFACE, a); + CustomData_set_layer_active_index(fdata, CD_MTFACE, a); + mesh_update_customdata_pointers(me); return; } } } +static int rna_Mesh_active_uv_texture_index_get(PointerRNA *ptr) +{ + Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); + return CustomData_get_active_layer(fdata, CD_MTFACE); +} + +static void rna_Mesh_active_uv_texture_index_set(PointerRNA *ptr, int value) +{ + Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); + + CustomData_set_layer_active(fdata, CD_MTFACE, value); + mesh_update_customdata_pointers(me); +} + +static void rna_Mesh_active_uv_texture_index_range(PointerRNA *ptr, int *min, int *max) +{ + Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); + + *min= 0; + *max= CustomData_number_of_layers(fdata, CD_MTFACE)-1; + *max= MAX2(0, *max); +} + static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values) { MTFace *mtface= (MTFace*)ptr->data; @@ -377,46 +442,84 @@ static void rna_MeshTextureFaceLayer_active_set(PointerRNA *ptr, int value) rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 0); } -static int rna_vcol_layer_check(CollectionPropertyIterator *iter, void *data) +static void rna_MeshTextureFaceLayer_name_set(PointerRNA *ptr, const char *value) +{ + Mesh *me= (Mesh*)ptr->id.data; + CustomDataLayer *cdl= (CustomDataLayer*)ptr->data; + BLI_strncpy(cdl->name, value, sizeof(cdl->name)); + CustomData_set_layer_unique_name(&me->fdata, cdl - me->fdata.layers); +} + +static int rna_vertex_color_check(CollectionPropertyIterator *iter, void *data) { CustomDataLayer *layer= (CustomDataLayer*)data; return (layer->type != CD_MCOL); } -static void rna_Mesh_vcol_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Mesh_vertex_colors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_vcol_layer_check); + CustomData *fdata= rna_mesh_fdata(me); + rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_vertex_color_check); } -static int rna_Mesh_vcol_layers_length(PointerRNA *ptr) +static int rna_Mesh_vertex_colors_length(PointerRNA *ptr) { return rna_CustomDataLayer_length(ptr, CD_MCOL); } -static PointerRNA rna_Mesh_active_vcol_layer_get(PointerRNA *ptr) +static PointerRNA rna_Mesh_active_vertex_color_get(PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - int index= CustomData_get_active_layer_index(&me->fdata, CD_MCOL); - CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index]; + CustomData *fdata= rna_mesh_fdata(me); + int index= CustomData_get_active_layer_index(fdata, CD_MCOL); + CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index]; return rna_pointer_inherit_refine(ptr, &RNA_MeshColorLayer, cdl); } -static void rna_Mesh_active_vcol_layer_set(PointerRNA *ptr, PointerRNA value) +static void rna_Mesh_active_vertex_color_set(PointerRNA *ptr, PointerRNA value) { Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); CustomDataLayer *cdl; int a; - for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) { + for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) { if(value.data == cdl) { - CustomData_set_layer_active_index(&me->fdata, CD_MCOL, a); + CustomData_set_layer_active_index(fdata, CD_MCOL, a); + mesh_update_customdata_pointers(me); return; } } } +static int rna_Mesh_active_vertex_color_index_get(PointerRNA *ptr) +{ + Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); + return CustomData_get_active_layer(fdata, CD_MCOL); +} + +static void rna_Mesh_active_vertex_color_index_set(PointerRNA *ptr, int value) +{ + Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); + + CustomData_set_layer_active(fdata, CD_MCOL, value); + mesh_update_customdata_pointers(me); +} + +static void rna_Mesh_active_vertex_color_index_range(PointerRNA *ptr, int *min, int *max) +{ + Mesh *me= (Mesh*)ptr->data; + CustomData *fdata= rna_mesh_fdata(me); + + *min= 0; + *max= CustomData_number_of_layers(fdata, CD_MCOL)-1; + *max= MAX2(0, *max); +} + static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->id.data; @@ -450,6 +553,14 @@ static void rna_MeshColorLayer_active_set(PointerRNA *ptr, int value) rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 0); } +static void rna_MeshColorLayer_name_set(PointerRNA *ptr, const char *value) +{ + Mesh *me= (Mesh*)ptr->id.data; + CustomDataLayer *cdl= (CustomDataLayer*)ptr->data; + BLI_strncpy(cdl->name, value, sizeof(cdl->name)); + CustomData_set_layer_unique_name(&me->fdata, cdl - me->fdata.layers); +} + static void rna_MeshFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->id.data; @@ -472,7 +583,8 @@ static int rna_float_layer_check(CollectionPropertyIterator *iter, void *data) static void rna_Mesh_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_float_layer_check); + CustomData *fdata= rna_mesh_fdata(me); + rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_float_layer_check); } static int rna_Mesh_float_layers_length(PointerRNA *ptr) @@ -502,7 +614,8 @@ static int rna_MeshIntPropertyLayer_data_length(PointerRNA *ptr) static void rna_Mesh_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_int_layer_check); + CustomData *fdata= rna_mesh_fdata(me); + rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_int_layer_check); } static int rna_Mesh_int_layers_length(PointerRNA *ptr) @@ -532,7 +645,8 @@ static int rna_MeshStringPropertyLayer_data_length(PointerRNA *ptr) static void rna_Mesh_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; - rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_string_layer_check); + CustomData *fdata= rna_mesh_fdata(me); + rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_string_layer_check); } static int rna_Mesh_string_layers_length(PointerRNA *ptr) @@ -591,17 +705,18 @@ static char *rna_MeshVertex_path(PointerRNA *ptr) static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr) { - return BLI_sprintfN("uv_layers[%s]", ((CustomDataLayer*)ptr->data)->name); + return BLI_sprintfN("uv_textures[%s]", ((CustomDataLayer*)ptr->data)->name); } static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type) { Mesh *me= (Mesh*)ptr->id.data; + CustomData *fdata= rna_mesh_fdata(me); CustomDataLayer *cdl; int a; size_t b; - for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) { + for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) { if(cdl->type == type) { b= ((char*)ptr->data - ((char*)cdl->data))/CustomData_sizeof(type); if(b >= 0 && b < me->totface) @@ -614,17 +729,17 @@ static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type static char *rna_MeshTextureFace_path(PointerRNA *ptr) { - return rna_CustomDataData_path(ptr, "uv_layers", CD_MTFACE); + return rna_CustomDataData_path(ptr, "uv_textures", CD_MTFACE); } static char *rna_MeshColorLayer_path(PointerRNA *ptr) { - return BLI_sprintfN("vcol_layers[%s]", ((CustomDataLayer*)ptr->data)->name); + return BLI_sprintfN("vertex_colors[%s]", ((CustomDataLayer*)ptr->data)->name); } static char *rna_MeshColor_path(PointerRNA *ptr) { - return rna_CustomDataData_path(ptr, "vcol_layers", CD_MCOL); + return rna_CustomDataData_path(ptr, "vertex_colors", CD_MCOL); } static char *rna_MeshSticky_path(PointerRNA *ptr) @@ -832,6 +947,7 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshTextureFaceLayer_name_set"); RNA_def_property_ui_text(prop, "Name", ""); prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); @@ -969,6 +1085,7 @@ static void rna_def_mcol(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshColorLayer_name_set"); RNA_def_property_ui_text(prop, "Name", ""); prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); @@ -1154,33 +1271,45 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_struct_type(prop, "MeshSticky"); RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates."); - /* UV layers */ + /* UV textures */ - prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "uv_textures", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", 0, 0, 0, "rna_Mesh_uv_textures_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); - RNA_def_property_ui_text(prop, "UV Layers", ""); + RNA_def_property_ui_text(prop, "UV Textures", ""); - prop= RNA_def_property(srna, "active_uv_layer", PROP_POINTER, PROP_UNSIGNED); + prop= RNA_def_property(srna, "active_uv_texture", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_layer_get", "rna_Mesh_active_uv_layer_set", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active UV Layer", "Active UV layer."); + RNA_def_property_ui_text(prop, "Active UV Texture", "Active UV texture."); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "active_uv_texture_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_Mesh_active_uv_texture_index_get", "rna_Mesh_active_uv_texture_index_set", "rna_Mesh_active_uv_texture_index_range"); + RNA_def_property_ui_text(prop, "Active UV Texture Index", "Active UV texture index."); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); - /* VCol layers */ + /* Vertex colors */ - prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", 0, 0, 0, "rna_Mesh_vertex_colors_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshColorLayer"); - RNA_def_property_ui_text(prop, "Vertex Color Layers", ""); + RNA_def_property_ui_text(prop, "Vertex Colors", ""); - prop= RNA_def_property(srna, "active_vcol_layer", PROP_POINTER, PROP_UNSIGNED); + prop= RNA_def_property(srna, "active_vertex_color", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "MeshColorLayer"); - RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vcol_layer_get", "rna_Mesh_active_vcol_layer_set", NULL); + RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vertex_color_get", "rna_Mesh_active_vertex_color_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer."); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); + + prop= RNA_def_property(srna, "active_vertex_color_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_Mesh_active_vertex_color_index_get", "rna_Mesh_active_vertex_color_index_set", "rna_Mesh_active_vertex_color_index_range"); + RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index."); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); @@ -1216,6 +1345,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "double_sided", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED); RNA_def_property_ui_text(prop, "Double Sided", "Render/display the mesh with double or single sided lighting"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "texcomesh"); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 9b3ff6e74a0..a789f9065e3 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -66,8 +66,9 @@ EnumPropertyItem modifier_type_items[] ={ {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, {eModifierType_SimpleDeform, "SIMPLE_DEFORM", ICON_MOD_SIMPLEDEFORM, "Simple Deform", ""}, {eModifierType_Smooth, "SMOOTH", ICON_MOD_SMOOTH, "Smooth", ""}, - {eModifierType_Softbody, "SOFTBODY", ICON_MOD_SOFT, "Softbody", ""}, + {eModifierType_Softbody, "SOFTBODY", ICON_MOD_SOFT, "Soft Body", ""}, {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subsurf", ""}, + {eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""}, {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, {eModifierType_Wave, "WAVE", ICON_MOD_WAVE, "Wave", ""}, {0, NULL, 0, NULL, NULL}}; @@ -109,7 +110,7 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr) case eModifierType_Hook: return &RNA_HookModifier; case eModifierType_Softbody: - return &RNA_SoftbodyModifier; + return &RNA_SoftBodyModifier; case eModifierType_Boolean: return &RNA_BooleanModifier; case eModifierType_Array: @@ -148,6 +149,8 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_SimpleDeformModifier; case eModifierType_Multires: return &RNA_MultiresModifier; + case eModifierType_Surface: + return &RNA_SurfaceModifier; default: return &RNA_Modifier; } @@ -348,6 +351,18 @@ static void rna_ArrayModifier_curve_set(PointerRNA *ptr, PointerRNA value) modifier_object_set(&((ArrayModifierData*)ptr->data)->curve_ob, OB_CURVE, value); } +static PointerRNA rna_SoftBodyModifier_settings_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + return rna_pointer_inherit_refine(ptr, &RNA_SoftBodySettings, ob->soft); +} + +static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd); +} + #else static void rna_def_property_subdivision_common(StructRNA *srna, const char type[]) @@ -491,7 +506,7 @@ static void rna_def_modifier_build(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 1, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Start", "Specify the start frame of the effect."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -645,18 +660,18 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "timeoffs"); - RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Time Offset", "Either the starting frame (for positive speed) or ending frame (for negative speed.)"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Lifetime", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "damp"); - RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Damping Time", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -831,11 +846,17 @@ static void rna_def_modifier_hook(BlenderRNA *brna) static void rna_def_modifier_softbody(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; - srna= RNA_def_struct(brna, "SoftbodyModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Softbody Modifier", "Softbody simulation modifier."); + srna= RNA_def_struct(brna, "SoftBodyModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Soft Body Modifier", "Soft body simulation modifier."); RNA_def_struct_sdna(srna, "SoftbodyModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_SOFT); + + prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "SoftBodySettings"); + RNA_def_property_pointer_funcs(prop, "rna_SoftBodyModifier_settings_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Soft Body Settings", ""); } static void rna_def_modifier_boolean(BlenderRNA *brna) @@ -1279,6 +1300,13 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem particleinstance_axis[] = { + {0, "X", 0, "X", ""}, + {1, "Y", 0, "Y", ""}, + {2, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL} + }; + srna= RNA_def_struct(brna, "ParticleInstanceModifier", "Modifier"); RNA_def_struct_ui_text(srna, "ParticleInstance Modifier", "Particle system instancing modifier."); RNA_def_struct_sdna(srna, "ParticleInstanceModifierData"); @@ -1295,6 +1323,12 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) RNA_def_property_range(prop, 1, 10); RNA_def_property_ui_text(prop, "Particle System Number", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "axis"); + RNA_def_property_enum_items(prop, particleinstance_axis); + RNA_def_property_ui_text(prop, "Axis", "Pole axis for rotation"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Parents); @@ -1325,6 +1359,28 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Dead); RNA_def_property_ui_text(prop, "Dead", "Show instances when particles are dead."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "keep_shape", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_KeepShape); + RNA_def_property_ui_text(prop, "Keep Shape", "Don't stretch the object."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "size", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_UseSize); + RNA_def_property_ui_text(prop, "Size", "Use particle size to scale the instances."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "position"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Position", "Position along path."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "random_position", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "random_position"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Random Position", "Randomize position along path."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); } static void rna_def_modifier_explode(BlenderRNA *brna) @@ -1398,6 +1454,11 @@ static void rna_def_modifier_collision(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Collision Modifier", "Collision modifier defining modifier stack position used for collision."); RNA_def_struct_sdna(srna, "CollisionModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_PHYSICS); + + prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "CollisionSettings"); + RNA_def_property_pointer_funcs(prop, "rna_CollisionModifier_settings_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Settings", ""); prop= RNA_def_property(srna, "absorption", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "absorption"); @@ -1672,6 +1733,16 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); } +static void rna_def_modifier_surface(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "SurfaceModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Surface Modifier", "Surface modifier defining modifier stack position used for surface fields."); + RNA_def_struct_sdna(srna, "SurfaceModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_PHYSICS); +} + void RNA_def_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -1701,15 +1772,18 @@ void RNA_def_modifier(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Realtime); RNA_def_property_ui_text(prop, "Realtime", "Realtime display of a modifier."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_ui_icon(prop, ICON_VIEW3D, 0); prop= RNA_def_property(srna, "render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render); RNA_def_property_ui_text(prop, "Render", "Use modifier during rendering."); + RNA_def_property_ui_icon(prop, ICON_SCENE, 0); prop= RNA_def_property(srna, "editmode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Editmode); RNA_def_property_ui_text(prop, "Editmode", "Use modifier while in the edit mode."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0); prop= RNA_def_property(srna, "on_cage", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_OnCage); @@ -1751,6 +1825,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_mask(brna); rna_def_modifier_simpledeform(brna); rna_def_modifier_multires(brna); + rna_def_modifier_surface(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c new file mode 100644 index 00000000000..bc636af6849 --- /dev/null +++ b/source/blender/makesrna/intern/rna_nla.c @@ -0,0 +1,460 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contributor(s): Blender Foundation (2009), Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> + +#include "RNA_define.h" +#include "RNA_types.h" + +#include "rna_internal.h" + +#include "DNA_anim_types.h" +#include "DNA_action_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#ifdef RNA_RUNTIME + +#include <stdio.h> +#include <math.h> + +/* needed for some of the validation stuff... */ +#include "BKE_animsys.h" +#include "BKE_nla.h" + +/* temp constant defined for these funcs only... */ +#define NLASTRIP_MIN_LEN_THRESH 0.1f + +void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value) +{ + NlaStrip *data= (NlaStrip *)ptr->data; + + /* copy the name first */ + BLI_strncpy(data->name, value, sizeof(data->name)); + + /* validate if there's enough info to do so */ + if (ptr->id.data) { + AnimData *adt= BKE_animdata_from_id(ptr->id.data); + BKE_nlastrip_validate_name(adt, data); + } +} + + +static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + + /* clamp value to lie within valid limits + * - cannot start past the end of the strip + some flexibility threshold + * - cannot start before the previous strip (if present) ends + * -> but if it was a transition, we could go up to the start of the strip + some flexibility threshold + * as long as we re-adjust the transition afterwards + * - minimum frame is -MAXFRAME so that we don't get clipping on frame 0 + */ + if (data->prev) { + if (data->prev->type == NLASTRIP_TYPE_TRANSITION) { + CLAMP(value, data->prev->start+NLASTRIP_MIN_LEN_THRESH, data->end-NLASTRIP_MIN_LEN_THRESH); + + /* readjust the transition to stick to the endpoints of the action-clips */ + data->prev->end= value; + } + else { + CLAMP(value, data->prev->end, data->end-NLASTRIP_MIN_LEN_THRESH); + } + } + else { + CLAMP(value, MINAFRAME, data->end); + } + data->start= value; +} + +static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + + /* clamp value to lie within valid limits + * - must not have zero or negative length strip, so cannot start before the first frame + * + some minimum-strip-length threshold + * - cannot end later than the start of the next strip (if present) + * -> but if it was a transition, we could go up to the start of the end - some flexibility threshold + * as long as we re-adjust the transition afterwards + */ + if (data->next) { + if (data->next->type == NLASTRIP_TYPE_TRANSITION) { + CLAMP(value, data->start+NLASTRIP_MIN_LEN_THRESH, data->next->end-NLASTRIP_MIN_LEN_THRESH); + + /* readjust the transition to stick to the endpoints of the action-clips */ + data->next->start= value; + } + else { + CLAMP(value, data->start+NLASTRIP_MIN_LEN_THRESH, data->next->start); + } + } + else { + CLAMP(value, data->start+NLASTRIP_MIN_LEN_THRESH, MAXFRAME); + } + data->end= value; + + + /* calculate the lengths the strip and its action (if applicable) */ + if (data->type == NLASTRIP_TYPE_CLIP) { + float len, actlen; + + len= data->end - data->start; + actlen= data->actend - data->actstart; + if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + + /* now, adjust the 'scale' setting to reflect this (so that this change can be valid) */ + data->scale= len / ((actlen) * data->repeat); + } +} + +static void rna_NlaStrip_scale_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + float actlen, mapping; + + /* set scale value */ + CLAMP(value, 0.0001f, 1000.0f); /* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */ + data->scale= value; + + /* calculate existing factors */ + actlen= data->actend - data->actstart; + if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + mapping= data->scale * data->repeat; + + /* adjust endpoint of strip in response to this */ + if (IS_EQ(mapping, 0.0f) == 0) + data->end = (actlen * mapping) + data->start; + else + printf("NlaStrip Set Scale Error (in RNA): Scale = %0.4f, Repeat = %0.4f \n", data->scale, data->repeat); +} + +static void rna_NlaStrip_repeat_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + float actlen, mapping; + + /* set scale value */ + CLAMP(value, 0.01f, 1000.0f); /* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */ + data->repeat= value; + + /* calculate existing factors */ + actlen= data->actend - data->actstart; + if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + mapping= data->scale * data->repeat; + + /* adjust endpoint of strip in response to this */ + if (IS_EQ(mapping, 0.0f) == 0) + data->end = (actlen * mapping) + data->start; + else + printf("NlaStrip Set Repeat Error (in RNA): Scale = %0.4f, Repeat = %0.4f \n", data->scale, data->repeat); +} + +static void rna_NlaStrip_blend_in_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + float len; + + /* blend-in is limited to the length of the strip, and also cannot overlap with blendout */ + len= (data->end - data->start) - data->blendout; + CLAMP(value, 0, len); + + data->blendin= value; +} + +static void rna_NlaStrip_blend_out_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + float len; + + /* blend-out is limited to the length of the strip */ + len= (data->end - data->start); + CLAMP(value, 0, len); + + /* it also cannot overlap with blendin */ + if ((len - value) < data->blendin) + value= len - data->blendin; + + data->blendout= value; +} + +static void rna_NlaStrip_action_start_frame_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + CLAMP(value, MINAFRAME, data->actend); + data->actstart= value; +} + +static void rna_NlaStrip_action_end_frame_set(PointerRNA *ptr, float value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + CLAMP(value, data->actstart, MAXFRAME); + data->actend= value; +} + +static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, int value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + + if (value) { + /* set the flag, then make sure a curve for this exists */ + data->flag |= NLASTRIP_FLAG_USR_INFLUENCE; + BKE_nlastrip_validate_fcurves(data); + } + else + data->flag &= ~NLASTRIP_FLAG_USR_INFLUENCE; +} + +static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, int value) +{ + NlaStrip *data= (NlaStrip*)ptr->data; + + if (value) { + /* set the flag, then make sure a curve for this exists */ + data->flag |= NLASTRIP_FLAG_USR_TIME; + BKE_nlastrip_validate_fcurves(data); + } + else + data->flag &= ~NLASTRIP_FLAG_USR_TIME; +} + +#else + +void rna_def_nlastrip(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + /* enum defs */ + static EnumPropertyItem prop_type_items[] = { + {NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action."}, + {NLASTRIP_TYPE_TRANSITION, "TRANSITION", 0, "Transition", "NLA Strip 'transitions' between adjacent strips."}, + {NLASTRIP_TYPE_META, "META", 0, "Meta", "NLA Strip acts as a container for adjacent strips."}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_mode_blend_items[] = { + {NLASTRIP_MODE_REPLACE, "REPLACE", 0, "Replace", "Result strip replaces the accumulated results by amount specified by influence."}, + {NLASTRIP_MODE_ADD, "ADD", 0, "Add", "Weighted result of strip is added to the accumlated results."}, + {NLASTRIP_MODE_SUBTRACT, "SUBTRACT", 0, "Subtract", "Weighted result of strip is removed from the accumlated results."}, + {NLASTRIP_MODE_MULTIPLY, "MULITPLY", 0, "Multiply", "Weighted result of strip is multiplied with the accumlated results."}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_mode_extend_items[] = { + {NLASTRIP_EXTEND_NOTHING, "NOTHING", 0, "Nothing", "Strip has no influence past its extents."}, + {NLASTRIP_EXTEND_HOLD, "HOLD", 0, "Hold", "Hold the first frame if no previous strips in track, and always hold last frame."}, + {NLASTRIP_EXTEND_HOLD_FORWARD, "HOLD_FORWARD", 0, "Hold Forward", "Only hold last frame."}, + {0, NULL, 0, NULL, NULL}}; + + /* struct definition */ + srna= RNA_def_struct(brna, "NlaStrip", NULL); + RNA_def_struct_ui_text(srna, "NLA Strip", "A container referencing an existing Action."); + RNA_def_struct_ui_icon(srna, ICON_NLA); // XXX + + /* name property */ + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NlaStrip_name_set"); + RNA_def_struct_name_property(srna, prop); + + /* Enums */ + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, not editable, since this is dangerous + RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of NLA Strip."); + + prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "extendmode"); + RNA_def_property_enum_items(prop, prop_mode_extend_items); + RNA_def_property_ui_text(prop, "Extrapolation", "Action to take for gaps past the strip extents."); + + prop= RNA_def_property(srna, "blending", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "blendmode"); + RNA_def_property_enum_items(prop, prop_mode_blend_items); + RNA_def_property_ui_text(prop, "Blending", "Method used for combining strip's result with accumulated result."); + + /* Strip extents */ + prop= RNA_def_property(srna, "start_frame", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "start"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_start_frame_set", NULL); + RNA_def_property_ui_text(prop, "Start Frame", ""); + + prop= RNA_def_property(srna, "end_frame", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "end"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_end_frame_set", NULL); + RNA_def_property_ui_text(prop, "End Frame", ""); + + /* Blending */ + prop= RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "blendin"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_blend_in_set", NULL); + RNA_def_property_ui_text(prop, "Blend In", "Number of frames at start of strip to fade in influence."); + + prop= RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "blendout"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_blend_out_set", NULL); + RNA_def_property_ui_text(prop, "Blend Out", ""); + + prop= RNA_def_property(srna, "auto_blending", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_AUTO_BLENDS); + RNA_def_property_ui_text(prop, "Auto Blend In/Out", "Number of frames for Blending In/Out is automatically determined from overlapping strips."); + + /* Action */ + prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "act"); + RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip."); + + /* Action extents */ + prop= RNA_def_property(srna, "action_start_frame", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "actstart"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_start_frame_set", NULL); + RNA_def_property_ui_text(prop, "Action Start Frame", ""); + + prop= RNA_def_property(srna, "action_end_frame", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "actend"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_action_end_frame_set", NULL); + RNA_def_property_ui_text(prop, "Action End Frame", ""); + + /* Action Reuse */ + prop= RNA_def_property(srna, "repeat", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "repeat"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_repeat_set", NULL); + RNA_def_property_range(prop, 0.1f, 1000.0f); /* these limits have currently be chosen arbitarily, but could be extended (minimum should still be > 0 though) if needed... */ + RNA_def_property_ui_text(prop, "Repeat", "Number of times to repeat the action range."); + + prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_scale_set", NULL); + RNA_def_property_range(prop, 0.0001f, 1000.0f); /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs due to numeric errors */ + RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action."); + + /* Strip's F-Curves */ + prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "FCurve"); + RNA_def_property_ui_text(prop, "F-Curves", "F-Curves for controlling the strip's influence and timing."); + + /* Strip's F-Modifiers */ + prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "FModifier"); + RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting all the F-Curves in the referenced Action."); + + /* Strip's Sub-Strips (for Meta-Strips) */ + prop= RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "NlaStrip"); + RNA_def_property_ui_text(prop, "NLA Strips", "NLA Strips that this strip acts as a container for (if it is of type Meta)."); + + /* Settings - Values necessary for evaluation */ + prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Influence", "Amount the strip contributes to the current result."); + + prop= RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate."); + + // TODO: should the animated_influence/time settings be animatable themselves? + prop= RNA_def_property(srna, "animated_influence", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_INFLUENCE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_NlaStrip_animated_influence_set"); + RNA_def_property_ui_text(prop, "Animated Influence", "Influence setting is controlled by an F-Curve rather than automatically determined."); + + prop= RNA_def_property(srna, "animated_time", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_USR_TIME); + RNA_def_property_boolean_funcs(prop, NULL, "rna_NlaStrip_animated_time_set"); + RNA_def_property_ui_text(prop, "Animated Strip Time", "Strip time is controlled by an F-Curve rather than automatically determined."); + + /* settings */ + prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can be made editable by hooking it up to the necessary NLA API methods */ + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_ACTIVE); + RNA_def_property_ui_text(prop, "Active", "NLA Strip is active."); + + prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_SELECT); + RNA_def_property_ui_text(prop, "Selected", "NLA Strip is selected."); + + prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_MUTED); + RNA_def_property_ui_text(prop, "Muted", "NLA Strip is not evaluated."); + + prop= RNA_def_property(srna, "reversed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLASTRIP_FLAG_REVERSE); + RNA_def_property_ui_text(prop, "Reversed", "NLA Strip is played back in reverse order (only when timing is automatically determined)."); + + // TODO: + // - sync length +} + +void rna_def_nlatrack(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "NlaTrack", NULL); + RNA_def_struct_ui_text(srna, "NLA Track", "A animation layer containing Actions referenced as NLA strips."); + RNA_def_struct_ui_icon(srna, ICON_NLA); + + /* strips collection */ + prop= RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "NlaStrip"); + RNA_def_property_ui_text(prop, "NLA Strips", "NLA Strips on this NLA-track."); + + /* name property */ + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); + + /* settings */ + prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can be made editable by hooking it up to the necessary NLA API methods */ + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_ACTIVE); + RNA_def_property_ui_text(prop, "Active", "NLA Track is active."); + + prop= RNA_def_property(srna, "solo", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can be made editable by hooking it up to the necessary NLA API methods */ + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SOLO); + RNA_def_property_ui_text(prop, "Solo", "NLA Track is evaluated itself (i.e. active Action and all other NLA Tracks in the same AnimData block are disabled)."); + + prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_SELECTED); + RNA_def_property_ui_text(prop, "Selected", "NLA Track is selected."); + + prop= RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_MUTED); + RNA_def_property_ui_text(prop, "Muted", "NLA Track is not evaluated."); + + prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NLATRACK_PROTECTED); + RNA_def_property_ui_text(prop, "Locked", "NLA Track is locked."); +} + +/* --------- */ + +void RNA_def_nla(BlenderRNA *brna) +{ + rna_def_nlatrack(brna); + rna_def_nlastrip(brna); +} + + +#endif diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index e046f2ff73d..b5b042c9cf3 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_types.h" @@ -42,20 +43,24 @@ #ifdef RNA_RUNTIME +#include "DNA_key_types.h" + #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" +#include "BKE_effect.h" +#include "BKE_key.h" #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_particle.h" -static void rna_Object_update(bContext *C, PointerRNA *ptr) +void rna_Object_update(bContext *C, PointerRNA *ptr) { DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); } -static void rna_Object_update_data(bContext *C, PointerRNA *ptr) +void rna_Object_update_data(bContext *C, PointerRNA *ptr) { DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_DATA); } @@ -131,6 +136,27 @@ static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef)); } +static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + return MAX2(ob->actdef-1, 0); +} + +static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value) +{ + Object *ob= (Object*)ptr->id.data; + ob->actdef= value+1; +} + +static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max) +{ + Object *ob= (Object*)ptr->id.data; + + *min= 0; + *max= BLI_countlist(&ob->defbase)-1; + *max= MAX2(0, *max); +} + void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index) { Object *ob= (Object*)ptr->id.data; @@ -228,11 +254,23 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res BLI_strncpy(result, "", maxlen); } +static int rna_Object_active_material_index_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + return MAX2(ob->actcol-1, 0); +} + +static void rna_Object_active_material_index_set(PointerRNA *ptr, int value) +{ + Object *ob= (Object*)ptr->id.data; + ob->actcol= value+1; +} + static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max) { Object *ob= (Object*)ptr->id.data; - *min= 1; - *max= ob->totcol; + *min= 0; + *max= MAX2(ob->totcol-1, 0); } static PointerRNA rna_Object_active_material_get(PointerRNA *ptr) @@ -244,14 +282,15 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr) static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max) { Object *ob= (Object*)ptr->id.data; - *min= 1; - *max= BLI_countlist(&ob->particlesystem); + *min= 0; + *max= BLI_countlist(&ob->particlesystem)-1; + *max= MAX2(0, *max); } static int rna_Object_active_particle_system_index_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; - return psys_get_current_num(ob) + 1; + return psys_get_current_num(ob); } static void rna_Object_active_particle_system_index_set(struct PointerRNA *ptr, int value) @@ -394,6 +433,78 @@ static PointerRNA rna_DupliObject_object_get(PointerRNA *ptr) } */ +static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max) +{ + Object *ob= (Object*)ptr->id.data; + Key *key= ob_get_key(ob); + + *min= 0; + *max= (key)? BLI_countlist(&key->block)-1: 0; + *max= MAX2(0, *max); +} + +static int rna_Object_active_shape_key_index_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + + return MAX2(ob->shapenr-1, 0); +} + +static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value) +{ + Object *ob= (Object*)ptr->id.data; + + ob->shapenr= value+1; + ob->shapeflag |= OB_SHAPE_TEMPLOCK; +} + +static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + Key *key= ob_get_key(ob); + KeyBlock *kb; + PointerRNA keyptr; + + if(key==NULL) + return PointerRNA_NULL; + + kb= BLI_findlink(&key->block, ob->shapenr-1); + RNA_pointer_create(&key->id, &RNA_ShapeKey, kb, &keyptr); + return keyptr; +} + +static void rna_Object_shape_key_lock_set(PointerRNA *ptr, int value) +{ + Object *ob= (Object*)ptr->id.data; + + if(value) ob->shapeflag |= OB_SHAPE_LOCK; + else ob->shapeflag &= ~OB_SHAPE_LOCK; + + ob->shapeflag &= ~OB_SHAPE_TEMPLOCK; +} + +static PointerRNA rna_Object_field_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + + /* weak */ + if(!ob->pd) + ob->pd= object_add_collision_fields(); + + return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd); +} + +static PointerRNA rna_Object_collision_get(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + + /* weak */ + if(!ob->pd) + ob->pd= object_add_collision_fields(); + + return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd); +} + #else static void rna_def_vertex_group(BlenderRNA *brna) @@ -824,7 +935,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "actcol"); - RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Object_active_material_index_range"); + RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range"); RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot."); /* transform */ @@ -905,8 +1016,15 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "VertexGroup"); - RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", "rna_Object_active_vertex_group_set", NULL); RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); + + prop= RNA_def_property(srna, "active_vertex_group_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "actdef"); + RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range"); + RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); /* empty */ @@ -937,11 +1055,13 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pd"); RNA_def_property_struct_type(prop, "FieldSettings"); + RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", NULL, NULL); RNA_def_property_ui_text(prop, "Field Settings", "Settings for using the objects as a field in physics simulation."); prop= RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pd"); RNA_def_property_struct_type(prop, "CollisionSettings"); + RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", NULL, NULL); RNA_def_property_ui_text(prop, "Collision Settings", "Settings for using the objects as a collider in physics simulation."); prop= RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE); @@ -1066,7 +1186,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sf"); - RNA_def_property_range(prop, -MAXFRAMEF, MAXFRAMEF); + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for IPO's and dupligroup instances."); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); @@ -1160,40 +1280,25 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Pose Mode", "Object with armature data is in pose mode."); - // XXX this stuff should be moved to AnimData... -/* - prop= RNA_def_property(srna, "nla_disable_path", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "nlaflag", OB_DISABLE_PATH); - RNA_def_property_ui_text(prop, "NLA Disable Path", "Disable path temporally, for editing cycles."); - - prop= RNA_def_property(srna, "nla_collapsed", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "nlaflag", OB_NLA_COLLAPSED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "NLA Collapsed", ""); - - prop= RNA_def_property(srna, "nla_override", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "nlaflag", OB_NLA_OVERRIDE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "NLA Override", ""); - - prop= RNA_def_property(srna, "nla_strips", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "nlastrips", NULL); - RNA_def_property_struct_type(prop, "UnknownType"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "NLA Strips", "NLA strips of the object."); -*/ - /* shape keys */ prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_shape_key_lock_set"); RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object."); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); - prop= RNA_def_property(srna, "active_shape_key", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ShapeKey"); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_shape_key_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key."); + + prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "shapenr"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key index."); + RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range"); + RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); RNA_api_object(srna); } diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 4d8c728db12..269437a8fae 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -33,18 +33,25 @@ #include "DNA_object_force.h" #include "DNA_scene_types.h" +#include "WM_api.h" #include "WM_types.h" #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" +#include "DNA_modifier_types.h" +#include "DNA_texture_types.h" + #include "BKE_context.h" +#include "BKE_modifier.h" #include "BKE_pointcache.h" #include "BKE_depsgraph.h" #include "BLI_blenlib.h" +#include "ED_object.h" + static void rna_Cache_change(bContext *C, PointerRNA *ptr) { Scene *scene = CTX_data_scene(C); @@ -100,7 +107,7 @@ static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr) { Object *ob = CTX_data_active_object(C); PointCache *cache = (PointCache*)ptr->data; - PTCacheID *pid = NULL, *pid2; + PTCacheID *pid = NULL, *pid2= NULL; ListBase pidlist; int new_name = 1; char name[80]; @@ -209,21 +216,6 @@ static void rna_SoftBodySettings_new_aero_set(PointerRNA *ptr, int value) else data->softflag &= ~OB_SB_AERO_ANGLE; } -static int rna_SoftBodySettings_enabled_get(PointerRNA *ptr) -{ - Object *data= (Object*)(ptr->data); - return (((data->softflag) & OB_SB_ENABLE) != 0); -} - -#if 0 -static void rna_SoftBodySettings_enabled_set(PointerRNA *ptr, int value) -{ - Object *data= (Object*)(ptr->data); - if(value) data->softflag |= OB_SB_ENABLE; - else data->softflag &= ~OB_SB_ENABLE; -} -#endif - static int rna_SoftBodySettings_face_collision_get(PointerRNA *ptr) { Object *data= (Object*)(ptr->data); @@ -250,6 +242,108 @@ static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, int value) else data->softflag &= ~OB_SB_EDGECOLL; } +static void rna_SoftBodySettings_goal_vgroup_get(PointerRNA *ptr, char *value) +{ + SoftBody *sb= (SoftBody*)ptr->data; + rna_object_vgroup_name_index_get(ptr, value, sb->vertgroup); +} + +static int rna_SoftBodySettings_goal_vgroup_length(PointerRNA *ptr) +{ + SoftBody *sb= (SoftBody*)ptr->data; + return rna_object_vgroup_name_index_length(ptr, sb->vertgroup); +} + +static void rna_SoftBodySettings_goal_vgroup_set(PointerRNA *ptr, const char *value) +{ + SoftBody *sb= (SoftBody*)ptr->data; + rna_object_vgroup_name_index_set(ptr, value, &sb->vertgroup); +} + +static void rna_FieldSettings_update(bContext *C, PointerRNA *ptr) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= (Object*)ptr->id.data; + + if(ob->pd->forcefield != PFIELD_TEXTURE && ob->pd->tex) { + ob->pd->tex->id.us--; + ob->pd->tex= 0; + } + + DAG_object_flush_update(scene, ob, OB_RECALC_OB); + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); +} + +static void rna_FieldSettings_surface_update(bContext *C, PointerRNA *ptr) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= (Object*)ptr->id.data; + PartDeflect *pd= ob->pd; + ModifierData *md= modifiers_findByType(ob, eModifierType_Surface); + + /* add/remove modifier as needed */ + if(!md) { + if(pd && (pd->flag & PFIELD_SURFACE)) + if(ELEM5(pd->forcefield,PFIELD_HARMONIC,PFIELD_FORCE,PFIELD_HARMONIC,PFIELD_CHARGE,PFIELD_LENNARDJ)) + if(ELEM4(ob->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) + ED_object_modifier_add(NULL, scene, ob, eModifierType_Surface); + } + else { + if(!pd || !(pd->flag & PFIELD_SURFACE)) + ED_object_modifier_remove(NULL, scene, ob, md); + } + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); +} + +static void rna_FieldSettings_dependency_update(bContext *C, PointerRNA *ptr) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= (Object*)ptr->id.data; + + /* do this before scene sort, that one checks for CU_PATH */ + /* XXX if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE) { + Curve *cu= ob->data; + cu->flag |= (CU_PATH|CU_3D); + do_curvebuts(B_CU3D); // all curves too + }*/ + + rna_FieldSettings_surface_update(C, ptr); + + DAG_scene_sort(scene); + + if(ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE) + DAG_object_flush_update(scene, ob, OB_RECALC); + else + DAG_object_flush_update(scene, ob, OB_RECALC_OB); + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); +} + +static void rna_CollisionSettings_dependency_update(bContext *C, PointerRNA *ptr) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= (Object*)ptr->id.data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Collision); + + /* add/remove modifier as needed */ + if(ob->pd->deflect && !md) + ED_object_modifier_add(NULL, scene, ob, eModifierType_Collision); + else if(!ob->pd->deflect && md) + ED_object_modifier_remove(NULL, scene, ob, md); + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); +} + +static void rna_CollisionSettings_update(bContext *C, PointerRNA *ptr) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= (Object*)ptr->id.data; + + DAG_object_flush_update(scene, ob, OB_RECALC); + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); +} + #else static void rna_def_pointcache(BlenderRNA *brna) @@ -279,9 +373,11 @@ static void rna_def_pointcache(BlenderRNA *brna) /* flags */ prop= RNA_def_property(srna, "baked", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "baking", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "disk_cache", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_DISK_CACHE); @@ -325,6 +421,7 @@ static void rna_def_collision(BlenderRNA *brna) prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "deflect", 1); RNA_def_property_ui_text(prop, "Enabled", "Enable this objects as a collider for physics systems"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_dependency_update"); /* Particle Interaction */ @@ -332,30 +429,36 @@ static void rna_def_collision(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "pdef_damp"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Damping Factor", "Amount of damping during particle collision"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "random_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_rdamp"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Damping", "Random variation of damping"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "friction_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_frict"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Friction Factor", "Amount of friction during particle collision"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "random_friction", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_rfrict"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Random Friction", "Random variation of friction"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "permeability", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_perm"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Permeability", "Chance that the particle will pass through the mesh"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "kill_particles", PROP_BOOLEAN, PROP_NONE); 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"); /* Soft Body and Cloth Interaction */ @@ -363,21 +466,25 @@ static void rna_def_collision(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "pdef_sbift"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_ui_text(prop, "Inner Thickness", "Inner face thickness"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "outer_thickness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_sboft"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_ui_text(prop, "Outer Thickness", "Outer face thickness"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); prop= RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_sbdamp"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Damping", "Amount of damping during collision"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); /* Does this belong here? prop= RNA_def_property(srna, "collision_stack", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "softflag", OB_SB_COLLFINAL); RNA_def_property_ui_text(prop, "Collision from Stack", "Pick collision object from modifier stack (softbody only)"); + RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); */ } @@ -418,20 +525,23 @@ static void rna_def_field(BlenderRNA *brna) /* Enums */ - prop= RNA_def_property(srna, "field_type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "forcefield"); RNA_def_property_enum_items(prop, field_type_items); - RNA_def_property_ui_text(prop, "Field Type", "Choose Field Type"); + RNA_def_property_ui_text(prop, "Type", "Type of field."); + RNA_def_property_update(prop, 0, "rna_FieldSettings_dependency_update"); prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "falloff"); RNA_def_property_enum_items(prop, falloff_items); - RNA_def_property_ui_text(prop, "Fall-Off", "Fall-Off Shape"); + RNA_def_property_ui_text(prop, "Fall-Off", "Fall-off shape."); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "tex_mode"); RNA_def_property_enum_items(prop, texture_items); RNA_def_property_ui_text(prop, "Texture Mode", "How the texture effect is calculated (RGB & Curl need a RGB texture else Gradient will be used instead)"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); /* Float */ @@ -439,103 +549,125 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "f_strength"); RNA_def_property_range(prop, -1000.0f, 1000.0f); RNA_def_property_ui_text(prop, "Strength", "Strength of force field"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "falloff_power", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "f_power"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Falloff Power", "Falloff power (real gravitational falloff = 2)"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "harmonic_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "f_damp"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Harmonic Damping", "Damping of the harmonic force"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "minimum_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "mindist"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance for the field's fall-off"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "maximum_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "maxdist"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Maximum Distance", "Maximum distance for the field to work"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "radial_minimum", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "minrad"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Minimum Radial Distance", "Minimum radial distance for the field's fall-off"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "radial_maximum", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "maxrad"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Maximum Radial Distance", "Maximum radial distance for the field to work"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "radial_falloff", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "f_power_r"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Radial Falloff Power", "Radial falloff power (real gravitational falloff = 2)"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "texture_nabla", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "tex_nabla"); RNA_def_property_range(prop, 0.0001f, 1.0f); RNA_def_property_ui_text(prop, "Nabla", "Defines size of derivative offset used for calculating gradient and curl"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "noise", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "f_noise"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Noise", "Noise of the wind force"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); RNA_def_property_range(prop, 1, 128); RNA_def_property_ui_text(prop, "Seed", "Seed of the wind noise"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); /* Boolean */ prop= RNA_def_property(srna, "use_min_distance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMIN); RNA_def_property_ui_text(prop, "Use Min", "Use a minimum distance for the field's fall-off"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "use_max_distance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMAX); RNA_def_property_ui_text(prop, "Use Max", "Use a maximum distance for the field to work"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "use_radial_min", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMINR); RNA_def_property_ui_text(prop, "Use Min", "Use a minimum radial distance for the field's fall-off"); // "Use a minimum angle for the field's fall-off" + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "use_radial_max", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMAXR); RNA_def_property_ui_text(prop, "Use Max", "Use a maximum radial distance for the field to work"); // "Use a maximum angle for the field to work" + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "guide_path_add", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_GUIDE_PATH_ADD); RNA_def_property_ui_text(prop, "Additive", "Based on distance/falloff it adds a portion of the entire path"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "planar", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_PLANAR); RNA_def_property_ui_text(prop, "Planar", "Create planar field"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "surface", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_SURFACE); RNA_def_property_ui_text(prop, "Surface", "Use closest point on surface"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_surface_update"); prop= RNA_def_property(srna, "positive_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_POSZ); RNA_def_property_ui_text(prop, "Positive", "Effect only in direction of positive Z axis"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "use_coordinates", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_OBJECT); RNA_def_property_ui_text(prop, "Use Coordinates", "Use object/global coordinates for texture"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "force_2d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_2D); RNA_def_property_ui_text(prop, "2D", "Apply force only in 2d"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "root_coordinates", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_ROOTCO); RNA_def_property_ui_text(prop, "Root Texture Coordinates", "Texture coordinates from root particle locations"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); /* Pointer */ @@ -543,6 +675,7 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "tex"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Texture", "Texture to use as force"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); } static void rna_def_game_softbody(BlenderRNA *brna) @@ -561,9 +694,9 @@ static void rna_def_softbody(BlenderRNA *brna) static EnumPropertyItem collision_type_items[] = { {SBC_MODE_MANUAL, "MANUAL", 0, "Manual", "Manual adjust"}, - {SBC_MODE_AVG, "AVERAGE", 0, "Average", "Average Spring lenght * Ball Size"}, - {SBC_MODE_MIN, "MINIMAL", 0, "Minimal", "Minimal Spring lenght * Ball Size"}, - {SBC_MODE_MAX, "MAXIMAL", 0, "Maximal", "Maximal Spring lenght * Ball Size"}, + {SBC_MODE_AVG, "AVERAGE", 0, "Average", "Average Spring length * Ball Size"}, + {SBC_MODE_MIN, "MINIMAL", 0, "Minimal", "Minimal Spring length * Ball Size"}, + {SBC_MODE_MAX, "MAXIMAL", 0, "Maximal", "Maximal Spring length * Ball Size"}, {SBC_MODE_AVGMINMAX, "MINMAX", 0, "AvMinMax", "(Min+Max)/2 * Ball Size"}, {0, NULL, 0, NULL, NULL}}; @@ -577,52 +710,62 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "mediafrict"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Friction", "General media friction for point movements"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "nodemass"); RNA_def_property_range(prop, 0.0f, 50000.0f); RNA_def_property_ui_text(prop, "Mass", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "grav"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Gravitation", "Apply gravitation to point movement"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "physics_speed"); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Speed", "Tweak timing for physics to control frequency and speed"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); /* Goal */ - /*prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "goal_vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "vertgroup"); - RNA_def_property_ui_text(prop, "Vertex Group", "Use control point weight values");*/ + RNA_def_property_string_funcs(prop, "rna_SoftBodySettings_goal_vgroup_get", "rna_SoftBodySettings_goal_vgroup_length", "rna_SoftBodySettings_goal_vgroup_set"); + RNA_def_property_ui_text(prop, "Goal Vertex Group", "Control point weight values."); prop= RNA_def_property(srna, "goal_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "mingoal"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Goal Minimum", "Goal minimum, vertex group weights are scaled to match this range."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "goal_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "maxgoal"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Goal Maximum", "Goal maximum, vertex group weights are scaled to match this range."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "goal_default", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "defgoal"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Goal Default", "Default Goal (vertex target position) value, when no Vertex Group used."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "goalspring"); RNA_def_property_range(prop, 0.0f, 0.999f); RNA_def_property_ui_text(prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "goalfrict"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Goal Damping", "Goal (vertex target position) friction."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); /* Edge Spring Settings */ @@ -630,36 +773,43 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "inspring"); RNA_def_property_range(prop, 0.0f, 0.999f); RNA_def_property_ui_text(prop, "Pull", "Edge spring stiffness when longer than rest length"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "push", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "inpush"); RNA_def_property_range(prop, 0.0f, 0.999f); RNA_def_property_ui_text(prop, "Push", "Edge spring stiffness when shorter than rest length"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "damp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "infrict"); RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_ui_text(prop, "Damp", "Edge spring friction"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); - prop= RNA_def_property(srna, "spring_lenght", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "spring_length", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "springpreload"); RNA_def_property_range(prop, 0.0f, 200.0f); - RNA_def_property_ui_text(prop, "SL", "Alter spring lenght to shrink/blow up (unit %) 0 to disable"); + RNA_def_property_ui_text(prop, "SL", "Alter spring length to shrink/blow up (unit %) 0 to disable"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "aero", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aeroedge"); RNA_def_property_range(prop, 0.0f, 30000.0f); RNA_def_property_ui_text(prop, "Aero", "Make edges 'sail'"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "plastic", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "plastic"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Plastic", "Permanent deform"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "bending", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "secondspring"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Bending", "Bending Stiffness"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shearstiff"); @@ -672,21 +822,25 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "sbc_mode"); RNA_def_property_enum_items(prop, collision_type_items); RNA_def_property_ui_text(prop, "Collision Type", "Choose Collision Type"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "ball_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "colball"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_ui_text(prop, "Ball Size", "Absolute ball size or factor if not manual adjusted"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "ball_stiff", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ballstiff"); RNA_def_property_range(prop, 0.001f, 100.0f); RNA_def_property_ui_text(prop, "Ball Size", "Ball inflating presure"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "ball_damp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "balldamp"); RNA_def_property_range(prop, 0.001f, 1.0f); RNA_def_property_ui_text(prop, "Ball Size", "Blending to inelastic collision"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); /* Solver */ @@ -694,30 +848,36 @@ static void rna_def_softbody(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "rklimit"); RNA_def_property_range(prop, 0.001f, 10.0f); RNA_def_property_ui_text(prop, "Error Limit", "The Runge-Kutta ODE solver error limit, low value gives more precision, high values speed"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "minstep", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "minloops"); RNA_def_property_range(prop, 0, 30000); RNA_def_property_ui_text(prop, "Min Step", "Minimal # solver steps/frame"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "maxstep", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "maxloops"); RNA_def_property_range(prop, 0, 30000); RNA_def_property_ui_text(prop, "Max Step", "Maximal # solver steps/frame"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "choke", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "choke"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Choke", "'Viscosity' inside collision target"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "fuzzy", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "fuzzyness"); RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Fuzzy", "Fuzzyness while on collision, high values make collsion handling faster but less stable"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "auto_step", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_OLDERR); RNA_def_property_ui_text(prop, "V", "Use velocities for automagic step sizes"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "diagnose", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_MONITOR); @@ -725,38 +885,40 @@ static void rna_def_softbody(BlenderRNA *brna) /* Flags */ - prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_enabled_get", "rna_SoftBodySettings_enabled_set"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Enable", "Sets object to become soft body."); - prop= RNA_def_property(srna, "use_goal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_use_goal_get", "rna_SoftBodySettings_use_goal_set"); RNA_def_property_ui_text(prop, "Use Goal", "Define forces for vertices to stick to animated position."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "use_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_use_edges_get", "rna_SoftBodySettings_use_edges_set"); RNA_def_property_ui_text(prop, "Use Edges", "Use Edges as springs"); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "stiff_quads", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_stiff_quads_get", "rna_SoftBodySettings_stiff_quads_set"); RNA_def_property_ui_text(prop, "Stiff Quads", "Adds diagonal springs on 4-gons."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "edge_collision", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_edge_collision_get", "rna_SoftBodySettings_edge_collision_set"); RNA_def_property_ui_text(prop, "Edge Collision", "Edges collide too."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "face_collision", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_face_collision_get", "rna_SoftBodySettings_face_collision_set"); RNA_def_property_ui_text(prop, "Face Collision", "Faces collide too, SLOOOOOW warning."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "new_aero", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_new_aero_get", "rna_SoftBodySettings_new_aero_set"); RNA_def_property_ui_text(prop, "N", "New aero(uses angle and length)."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); prop= RNA_def_property(srna, "self_collision", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_SoftBodySettings_self_collision_get", "rna_SoftBodySettings_self_collision_set"); RNA_def_property_ui_text(prop, "Self Collision", "Enable naive vertex ball self collision."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data"); } void RNA_def_object_force(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index d60a215b498..98ed12afd5a 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -40,6 +40,57 @@ #include "WM_types.h" #include "WM_api.h" +EnumPropertyItem part_from_items[] = { + {PART_FROM_VERT, "VERT", 0, "Verts", ""}, + {PART_FROM_FACE, "FACE", 0, "Faces", ""}, + {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem part_reactor_from_items[] = { + {PART_FROM_VERT, "VERT", 0, "Verts", ""}, + {PART_FROM_FACE, "FACE", 0, "Faces", ""}, + {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, + {PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem part_draw_as_items[] = { + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, + {PART_DRAW_DOT, "DOT", 0, "Point", ""}, + {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""}, + {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""}, + {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem part_hair_draw_as_items[] = { + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, + {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem part_ren_as_items[] = { + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_HALO, "HALO", 0, "Halo", ""}, + {PART_DRAW_LINE, "LINE", 0, "Line", ""}, + {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, + {PART_DRAW_GR, "GROUP", 0, "Group", ""}, + {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem part_hair_ren_as_items[] = { + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, + {PART_DRAW_GR, "GROUP", 0, "Group", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "BKE_context.h" @@ -151,6 +202,20 @@ static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value) if(psys->part) psys->part->id.us++; } +static void rna_Particle_abspathtime_update(bContext *C, PointerRNA *ptr) +{ + ParticleSettings *settings = (ParticleSettings*)ptr->data; + float delta = settings->end + settings->lifetime - settings->sta; + if(settings->draw & PART_ABS_PATH_TIME) { + settings->path_start = settings->sta + settings->path_start * delta; + settings->path_end = settings->sta + settings->path_end * delta; + } + else { + settings->path_start = (settings->path_start - settings->sta)/delta; + settings->path_end = (settings->path_end - settings->sta)/delta; + } + rna_Particle_redo(C, ptr); +} static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value) { ParticleSettings *settings = (ParticleSettings*)ptr->data; @@ -161,8 +226,8 @@ static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value) if(settings->type==PART_REACTOR && value < 1.0) value = 1.0; - else if (value < -30000.0f) //TODO: replace 30000 with MAXFRAMEF when available in 2.5 - value = -30000.0f; + else if (value < MINAFRAMEF) + value = MINAFRAMEF; settings->sta = value; } @@ -189,7 +254,19 @@ static float rna_PartSetting_linelentail_get(struct PointerRNA *ptr) ParticleSettings *settings = (ParticleSettings*)ptr->data; return settings->draw_line[0]; } +static void rna_PartSetting_pathstartend_range(PointerRNA *ptr, float *min, float *max) +{ + ParticleSettings *settings = (ParticleSettings*)ptr->data; + if(settings->type==PART_HAIR) { + *min = 0.0f; + *max = (settings->draw & PART_ABS_PATH_TIME) ? 100.0f : 1.0; + } + else { + *min = (settings->draw & PART_ABS_PATH_TIME) ? settings->sta : 0.0f; + *max= (settings->draw & PART_ABS_PATH_TIME) ? MAXFRAMEF : 1.0f; + } +} static void rna_PartSetting_linelenhead_set(struct PointerRNA *ptr, float value) { ParticleSettings *settings = (ParticleSettings*)ptr->data; @@ -222,85 +299,34 @@ static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str) strcpy(str, ""); } -static EnumPropertyItem from_items[] = { - {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, - {PART_FROM_FACE, "FACE", 0, "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static EnumPropertyItem reactor_from_items[] = { - {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, - {PART_FROM_FACE, "FACE", 0, "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, - {PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static EnumPropertyItem *rna_Particle_from_itemf(PointerRNA *ptr) +static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, int *free) { ParticleSettings *part = ptr->id.data; if(part->type==PART_REACTOR) - return reactor_from_items; + return part_reactor_from_items; else - return from_items; + return part_from_items; } -static EnumPropertyItem draw_as_items[] = { - {PART_DRAW_NOT, "NONE", 0, "None", ""}, - {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, - {PART_DRAW_DOT, "DOT", 0, "Point", ""}, - {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""}, - {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""}, - {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static EnumPropertyItem hair_draw_as_items[] = { - {PART_DRAW_NOT, "NONE", 0, "None", ""}, - {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, - {PART_DRAW_PATH, "PATH", 0, "Path", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static EnumPropertyItem ren_as_items[] = { - {PART_DRAW_NOT, "NONE", 0, "None", ""}, - {PART_DRAW_HALO, "HALO", 0, "Halo", ""}, - {PART_DRAW_LINE, "LINE", 0, "Line", ""}, - {PART_DRAW_PATH, "PATH", 0, "Path", ""}, - {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, - {PART_DRAW_GR, "GROUP", 0, "Group", ""}, - {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static EnumPropertyItem hair_ren_as_items[] = { - {PART_DRAW_NOT, "NONE", 0, "None", ""}, - {PART_DRAW_PATH, "PATH", 0, "Path", ""}, - {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, - {PART_DRAW_GR, "GROUP", 0, "Group", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static EnumPropertyItem *rna_Particle_draw_as_itemf(PointerRNA *ptr) +static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr, int *free) { ParticleSettings *part = ptr->id.data; if(part->type==PART_HAIR) - return hair_draw_as_items; + return part_hair_draw_as_items; else - return draw_as_items; + return part_draw_as_items; } -static EnumPropertyItem *rna_Particle_ren_as_itemf(PointerRNA *ptr) +static EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *C, PointerRNA *ptr, int *free) { ParticleSettings *part = ptr->id.data; if(part->type==PART_HAIR) - return hair_ren_as_items; + return part_hair_ren_as_items; else - return ren_as_items; + return part_ren_as_items; } @@ -702,15 +728,15 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Abs Length", "Use maximum length for children"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - prop= RNA_def_property(srna, "absolute_time", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ABS_TIME); - RNA_def_property_ui_text(prop, "Absolute Time", "Set all ipos that work on particles to be calculated in absolute/relative time."); - RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); + //prop= RNA_def_property(srna, "absolute_time", PROP_BOOLEAN, PROP_NONE); + //RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ABS_TIME); + //RNA_def_property_ui_text(prop, "Absolute Time", "Set all ipos that work on particles to be calculated in absolute/relative time."); + //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); - prop= RNA_def_property(srna, "global_time", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GLOB_TIME); - RNA_def_property_ui_text(prop, "Global Time", "Set all ipos that work on particles to be calculated in global/object time."); - RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); + //prop= RNA_def_property(srna, "global_time", PROP_BOOLEAN, PROP_NONE); + //RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GLOB_TIME); + //RNA_def_property_ui_text(prop, "Global Time", "Set all ipos that work on particles to be calculated in global/object time."); + //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "boids_2d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_BOIDS_2D); @@ -775,6 +801,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "from"); + RNA_def_property_enum_items(prop, part_reactor_from_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf"); RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); @@ -836,15 +863,10 @@ static void rna_def_particle_settings(BlenderRNA *brna) //RNA_def_property_ui_text(prop, "Health", "Draw boid health"); //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - //prop= RNA_def_property(srna, "timed_path", PROP_BOOLEAN, PROP_NONE); - //RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_TIMED_PATH); - //RNA_def_property_ui_text(prop, "Clip with time", "Clip path based on time"); - //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); - - //prop= RNA_def_property(srna, "draw_cached_path", PROP_BOOLEAN, PROP_NONE); - //RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_CACHED_PATH); - //RNA_def_property_ui_text(prop, "Path", "Draw particle path if the path is baked"); - //RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + prop= RNA_def_property(srna, "abs_path_time", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_ABS_PATH_TIME); + RNA_def_property_ui_text(prop, "Absolute Path Time", "Path timing is in absolute frames"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_abspathtime_update"); prop= RNA_def_property(srna, "billboard_lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_BB_LOCK); @@ -893,12 +915,14 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "draw_as", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "draw_as"); + RNA_def_property_enum_items(prop, part_draw_as_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf"); RNA_def_property_ui_text(prop, "Particle Drawing", "How particles are drawn in viewport"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); prop= RNA_def_property(srna, "ren_as", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ren_as"); + RNA_def_property_enum_items(prop, part_ren_as_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf"); RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); @@ -1066,19 +1090,19 @@ static void rna_def_particle_settings(BlenderRNA *brna) /* general values */ prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sta");//optional if prop names are the same - RNA_def_property_range(prop, -30000.0f, 30000.0f); //TODO: replace 30000 with MAXFRAMEF when available in 2.5 + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_start_set", NULL); RNA_def_property_ui_text(prop, "Start", "Frame # to start emitting particles."); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "end", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, -30000.0f, 30000.0f); //TODO: replace 30000 with MAXFRAMEF when available in 2.5 + RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_end_set", NULL); RNA_def_property_ui_text(prop, "End", "Frame # to stop emitting particles."); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 1.0f, 30000.0f); + RNA_def_property_range(prop, 1.0f, MAXFRAMEF); RNA_def_property_ui_text(prop, "Lifetime", "Specify the life span of the particles"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); @@ -1228,7 +1252,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "acc"); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, -200.0f, 200.0f); - RNA_def_property_ui_text(prop, "Accelaration", "Constant acceleration"); + RNA_def_property_ui_text(prop, "Acceleration", "Constant acceleration"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "drag_factor", PROP_FLOAT, PROP_NONE); @@ -1410,6 +1434,24 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Head", "Length of the line's head"); RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + prop= RNA_def_property(srna, "path_start", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "path_start"); + RNA_def_property_float_funcs(prop, NULL, NULL, "rna_PartSetting_pathstartend_range"); + RNA_def_property_ui_text(prop, "Path Start", "Starting time of drawn path."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + + prop= RNA_def_property(srna, "path_end", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "path_end"); + RNA_def_property_float_funcs(prop, NULL, NULL, "rna_PartSetting_pathstartend_range"); + RNA_def_property_ui_text(prop, "Path End", "End time of drawn path."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + + prop= RNA_def_property(srna, "trail_count", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "trail_count"); + RNA_def_property_range(prop, 1.0f, 100.0f); + RNA_def_property_ui_text(prop, "Trail Count", "Number of trail particles."); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + /* boids */ prop= RNA_def_property(srna, "max_velocity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_vel"); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 14db8ea3377..0b605db20cf 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -516,6 +516,13 @@ static int rna_StringProperty_max_length_get(PointerRNA *ptr) return ((StringPropertyRNA*)prop)->maxlength; } +static int rna_enum_check_separator(CollectionPropertyIterator *iter, void *data) +{ + EnumPropertyItem *item= (EnumPropertyItem*)data; + + return (item->identifier[0] != 0); +} + static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -524,7 +531,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point rna_idproperty_check(&prop, ptr); eprop= (EnumPropertyRNA*)prop; - rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, NULL); + rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, rna_enum_check_separator); } static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value) @@ -547,6 +554,26 @@ static int rna_EnumPropertyItem_name_length(PointerRNA *ptr) return strlen(((EnumPropertyItem*)ptr->data)->name); } +static void rna_EnumPropertyItem_description_get(PointerRNA *ptr, char *value) +{ + EnumPropertyItem *eprop= (EnumPropertyItem*)ptr->data; + + if(eprop->description) + strcpy(value, eprop->description); + else + value[0]= '\0'; +} + +static int rna_EnumPropertyItem_description_length(PointerRNA *ptr) +{ + EnumPropertyItem *eprop= (EnumPropertyItem*)ptr->data; + + if(eprop->description) + return strlen(eprop->description); + else + return 0; +} + static int rna_EnumPropertyItem_value_get(PointerRNA *ptr) { return ((EnumPropertyItem*)ptr->data)->value; @@ -861,6 +888,11 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_name_get", "rna_EnumPropertyItem_name_length", NULL); RNA_def_property_ui_text(prop, "Name", "Human readable name."); + prop= RNA_def_property(srna, "description", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_description_get", "rna_EnumPropertyItem_description_length", NULL); + RNA_def_property_ui_text(prop, "Description", "Description of the item's purpose."); + prop= RNA_def_property(srna, "identifier", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_string_funcs(prop, "rna_EnumPropertyItem_identifier_get", "rna_EnumPropertyItem_identifier_length", NULL); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 1017703c56b..1b85eace163 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -199,6 +199,10 @@ void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_mode_items); RNA_def_property_ui_text(prop, "Proportional Editing Falloff", "Falloff type for proportional editing mode."); + prop= RNA_def_property(srna, "automerge_editing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automerge", 0); + RNA_def_property_ui_text(prop, "AutoMerge Editing", "Automatically merge vertices moved to the same location."); + prop= RNA_def_property(srna, "snap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP); RNA_def_property_ui_text(prop, "Snap", "Snap while Ctrl is held during transform."); @@ -245,6 +249,11 @@ void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, mesh_select_mode_items); RNA_def_property_ui_text(prop, "Mesh Selection Mode", "Mesh selection and display mode."); + prop= RNA_def_property(srna, "vertex_group_weight", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "vgroup_weight"); + RNA_def_property_ui_text(prop, "Vertex Group Weight", "Weight to assign in vertex groups."); + + /* Sculpt */ rna_def_sculpt(brna); } @@ -274,7 +283,13 @@ void rna_def_scene_render_data(BlenderRNA *brna) {R_PLANES24, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, {R_PLANES32, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, {0, NULL, 0, NULL, NULL}}; - + + static EnumPropertyItem display_mode_items[] ={ + {R_OUTPUT_SCREEN, "SCREEN", 0, "Full Screen", "Images are rendered in full Screen"}, + {R_OUTPUT_AREA, "AREA", 0, "Image Editor", "Images are rendered in Image Editor"}, + {R_OUTPUT_WINDOW, "WINDOW", 0, "New Window", "Images are rendered in new Window"}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem octree_resolution_items[] = { {64, "OCTREE_RES_64", 0, "64", ""}, {128, "OCTREE_RES_128", 0, "128", ""}, @@ -832,6 +847,11 @@ void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Back Buffer", "Render backbuffer image"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "displaymode"); + RNA_def_property_enum_items(prop, display_mode_items); + RNA_def_property_ui_text(prop, "Display", "Select where rendered images will be displayed"); + prop= RNA_def_property(srna, "output_path", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "pic"); RNA_def_property_ui_text(prop, "Output Path", "Directory/name to save animations, # characters defines the position and length of frame numbers."); @@ -955,7 +975,7 @@ void RNA_def_scene(BlenderRNA *brna) prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); RNA_def_property_int_sdna(prop, NULL, "r.cfra"); - RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Current Frame", ""); RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_frame_update"); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index a4ba6ec172b..fb836a98a52 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -36,6 +36,7 @@ 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", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 055e67fb135..8ca023dc57c 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -38,9 +38,9 @@ #include "MEM_guardedalloc.h" -#ifdef RNA_RUNTIME +#include "WM_types.h" -#include "MEM_guardedalloc.h" +#ifdef RNA_RUNTIME static int rna_SequenceEditor_name_length(PointerRNA *ptr) { @@ -429,10 +429,12 @@ static void rna_def_sequence(BlenderRNA *brna) prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MUTE); RNA_def_property_ui_text(prop, "Mute", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "frame_locked", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_IPO_FRAME_LOCKED); RNA_def_property_ui_text(prop, "Frame Locked", "Lock the animation curve to the global frame counter."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LOCK); @@ -450,45 +452,53 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "start"); RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_start_frame_set",NULL); // overlap tests and calc_seq_disp + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "startofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "Start Offset", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "end_offset", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "endofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "End offset", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "start_still", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "startstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_text(prop, "Start Still", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "end_still", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "endstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_text(prop, "End Still", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "machine"); RNA_def_property_ui_text(prop, "Channel", "Y position of the sequence strip."); RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_channel_set",NULL); // overlap test + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); /* blending */ prop= RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, blend_mode_items); RNA_def_property_ui_text(prop, "Blend Mode", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "blend_opacity", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Blend Opacity", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - /* funcsions */ + /* functions */ func= RNA_def_function(srna, "getStripElem", "give_stripelem"); RNA_def_function_ui_description(func, "Return the strip element from a given frame or None."); prop= RNA_def_int(func, "frame", 0, INT_MIN, INT_MAX, "Frame", "The frame to get the strip element from", INT_MIN, INT_MAX); @@ -539,58 +549,71 @@ static void rna_def_filter_video(StructRNA *srna) prop= RNA_def_property(srna, "premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MAKE_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "flip_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FLIPX); RNA_def_property_ui_text(prop, "Flip X", "Flip on the X axis."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "flip_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FLIPY); RNA_def_property_ui_text(prop, "Flip Y", "Flip on the Y axis."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "convert_float", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MAKE_FLOAT); RNA_def_property_ui_text(prop, "Convert Float", "Convert input to float data."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "reverse_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_REVERSE_FRAMES); RNA_def_property_ui_text(prop, "Flip Time", "Reverse frame order."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "multiply_colors", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "mul"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Multiply Colors", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "strobe", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 1.0f, 30.0f); RNA_def_property_ui_text(prop, "Strobe", "Only display every nth frame."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "use_color_balance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_COLOR_BALANCE); RNA_def_property_ui_text(prop, "Use Color Balance", "(3-Way color correction) on input."); RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_color_balance_set"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "color_balance", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->color_balance"); RNA_def_property_ui_text(prop, "Color Balance", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "use_translation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_TRANSFORM); RNA_def_property_ui_text(prop, "Use Translation", "Translate image before processing."); RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_translation_set"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "transform", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->transform"); RNA_def_property_ui_text(prop, "Transform", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "use_crop", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_CROP); RNA_def_property_ui_text(prop, "Use Crop", "Crop image before processing."); RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_crop_set"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); prop= RNA_def_property(srna, "crop", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->crop"); RNA_def_property_ui_text(prop, "Crop", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_filter_sound(StructRNA *srna) @@ -960,6 +983,7 @@ static void rna_def_solid_color(BlenderRNA *brna) prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "col"); RNA_def_property_ui_text(prop, "Color", ""); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); } static void rna_def_speed_control(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index ae3b249e51f..9bf3f54e159 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -30,6 +30,7 @@ #include "rna_internal.h" +#include "DNA_action_types.h" #include "DNA_object_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" @@ -89,9 +90,8 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) switch(space->spacetype) { case SPACE_VIEW3D: return &RNA_Space3DView; - /*case SPACE_IPO: + case SPACE_IPO: return &RNA_SpaceGraphEditor; - */ case SPACE_OUTLINER: return &RNA_SpaceOutliner; case SPACE_BUTS: @@ -109,12 +109,12 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) //case SPACE_IMASEL: // return &RNA_SpaceImageBrowser; /*case SPACE_SOUND: - return &RNA_SpaceAudioWindow; + return &RNA_SpaceAudioWindow;*/ case SPACE_ACTION: return &RNA_SpaceDopeSheetEditor; case SPACE_NLA: - return &RNA_SpaceNLAEditor; - case SPACE_SCRIPT: + return &RNA_SpaceNLA; + /*case SPACE_SCRIPT: return &RNA_SpaceScriptsWindow; case SPACE_TIME: return &RNA_SpaceTimeline; @@ -173,7 +173,7 @@ static EnumPropertyItem dc_rgb_items[] = {DC_RGB, DC_LCMS, DC_ZERO}; static EnumPropertyItem dc_alpha_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_LCMS, DC_ZERO}; static EnumPropertyItem dc_z_items[] = {DC_RGB, DC_Z, DC_LCMS, DC_ZERO}; -static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(PointerRNA *ptr) +static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free) { SpaceImage *sima= (SpaceImage*)ptr->data; ImBuf *ibuf= ED_space_image_buffer(sima); @@ -547,23 +547,28 @@ static void rna_def_space_3dview(BlenderRNA *brna) prop= RNA_def_property(srna, "manipulator", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_USE_MANIPULATOR); RNA_def_property_ui_text(prop, "Manipulator", "Use a 3D manipulator widget for controlling transforms."); + RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL); prop= RNA_def_property(srna, "manipulator_translate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "twtype", V3D_MANIP_TRANSLATE); RNA_def_property_ui_text(prop, "Manipulator Translate", "Use the manipulator for movement transformations."); + RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL); prop= RNA_def_property(srna, "manipulator_rotate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "twtype", V3D_MANIP_ROTATE); RNA_def_property_ui_text(prop, "Manipulator Rotate", "Use the manipulator for rotation transformations."); + RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL); prop= RNA_def_property(srna, "manipulator_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "twtype", V3D_MANIP_SCALE); RNA_def_property_ui_text(prop, "Manipulator Scale", "Use the manipulator for scale transformations."); + RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL); prop= RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "twmode"); RNA_def_property_enum_items(prop, transform_orientation_items); RNA_def_property_ui_text(prop, "Transform Orientation", "The alignment of manipulator handles."); + RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL); } @@ -729,13 +734,13 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mainb"); RNA_def_property_enum_items(prop, display_mode_items); RNA_def_property_ui_text(prop, "Display Mode", "The view mode to use for displaying sequencer output."); - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); /* flag's */ prop= RNA_def_property(srna, "draw_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAWFRAMES); RNA_def_property_ui_text(prop, "Draw Frames", "Draw frames rather then seconds."); - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); prop= RNA_def_property(srna, "transform_markers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MARKER_TRANS); @@ -743,18 +748,18 @@ static void rna_def_space_sequencer(BlenderRNA *brna) prop= RNA_def_property(srna, "seperate_color_preview", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAW_COLOR_SEPERATED); - RNA_def_property_ui_text(prop, "Transform Markers", "Seperate color channels in preview."); - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_ui_text(prop, "Seperate Colors", "Seperate color channels in preview."); + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); prop= RNA_def_property(srna, "draw_safe_margin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAW_SAFE_MARGINS); RNA_def_property_ui_text(prop, "Safe Margin", "Draw title safe margins in preview."); - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); prop= RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAW_GPENCIL); RNA_def_property_ui_text(prop, "Use Grease Pencil", "Display and edit the grease pencil freehand annotations overlay."); - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); /* grease pencil */ prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); @@ -766,13 +771,13 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "chanshown"); RNA_def_property_ui_text(prop, "Display Channel", "The channel number shown in the image preview. 0 is the result of all strips combined."); RNA_def_property_range(prop, 0, 32); // MAXSEQ --- todo, move from BKE_sequence.h - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); prop= RNA_def_property(srna, "draw_overexposed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "zebra"); RNA_def_property_ui_text(prop, "Show Overexposed", "Show overexposed areas with zebra stripes."); RNA_def_property_range(prop, 0, 110); - RNA_def_property_update(prop, ND_SEQUENCER|ND_DISPLAY, NULL); // review notifier + RNA_def_property_update(prop, ND_SEQUENCER|NC_WINDOW, NULL); /* not sure we need rna access to these but adding anyway */ @@ -795,8 +800,8 @@ static void rna_def_space_text(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem font_size_items[] = { - {12, "SCREEN_12", 0, "Screen 12", ""}, - {15, "SCREEN_15", 0, "Screen 15", ""}, + {12, "12", 0, "12", ""}, + {15, "15", 0, "15", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceTextEditor", "Space"); @@ -808,7 +813,7 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Text", "Text displayed and edited in this space."); RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceTextEditor_text_set", NULL); - RNA_def_property_update(prop, NC_TEXT|NA_EDITED, NULL); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); /* display */ prop= RNA_def_property(srna, "syntax_highlight", PROP_BOOLEAN, PROP_NONE); @@ -867,6 +872,117 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool."); } +static void rna_def_space_dopesheet(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem mode_items[] = { + {SACTCONT_DOPESHEET, "DOPESHEET", 0, "DopeSheet", ""}, + {SACTCONT_ACTION, "ACTION", 0, "Action Editor", ""}, + {SACTCONT_SHAPEKEY, "SHAPEKEY", 0, "ShapeKey Editor", ""}, // XXX to be depreceated? + {SACTCONT_GPENCIL, "GPENCIL", 0, "Grease Pencil", ""}, + {0, NULL, 0, NULL, NULL}}; + + + srna= RNA_def_struct(brna, "SpaceDopeSheetEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceAction"); + RNA_def_struct_ui_text(srna, "Space DopeSheet Editor", "DopeSheet space data."); + + /* mode */ + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + 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."); + + /* display */ + prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_DRAWTIME); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator + RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames."); + + prop= RNA_def_property(srna, "show_cframe_indicator", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NODRAWCFRANUM); + RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line."); + + prop= RNA_def_property(srna, "show_sliders", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_SLIDERS); + RNA_def_property_ui_text(prop, "Show Sliders", "Show sliders beside F-Curve channels."); + + /* editing */ + prop= RNA_def_property(srna, "automerge_keyframes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NOTRANSKEYCULL); + RNA_def_property_ui_text(prop, "AutoMerge Keyframes", "Show handles of Bezier control points."); + + // TODO... autosnap, dopesheet? +} + +static void rna_def_space_graph(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem mode_items[] = { + {SIPO_MODE_ANIMATION, "FCURVES", 0, "F-Curves", ""}, + {SIPO_MODE_DRIVERS, "DRIVERS", 0, "Drivers", ""}, + {0, NULL, 0, NULL, NULL}}; + + + srna= RNA_def_struct(brna, "SpaceGraphEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceIpo"); + RNA_def_struct_ui_text(srna, "Space Graph Editor", "Graph Editor space data."); + + /* mode */ + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + 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."); + + /* display */ + prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_DRAWTIME); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator + RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames."); + + prop= RNA_def_property(srna, "show_cframe_indicator", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWCFRANUM); + RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line."); + + prop= RNA_def_property(srna, "show_handles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_NOHANDLES); + RNA_def_property_ui_text(prop, "Show Handles", "Show handles of Bezier control points."); + + /* editing */ + prop= RNA_def_property(srna, "automerge_keyframes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NOTRANSKEYCULL); + RNA_def_property_ui_text(prop, "AutoMerge Keyframes", "Show handles of Bezier control points."); + + // TODO... autosnap, dopesheet? +} + +static void rna_def_space_nla(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SpaceNLA", "Space"); + RNA_def_struct_sdna(srna, "SpaceNla"); + RNA_def_struct_ui_text(srna, "Space Nla Editor", "NLA editor space data."); + + /* display */ + prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SNLA_DRAWTIME); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator + RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames."); + + prop= RNA_def_property(srna, "show_cframe_indicator", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SNLA_NODRAWCFRANUM); + RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line."); + + /* editing */ + // TODO... autosnap, dopesheet? +} + static void rna_def_fileselect_params(BlenderRNA *brna) { StructRNA *srna; @@ -888,6 +1004,21 @@ static void rna_def_fileselect_params(BlenderRNA *brna) srna= RNA_def_struct(brna, "FileSelectParams", NULL); RNA_def_struct_ui_text(srna, "File Select Parameters", "File Select Parameters."); + prop= RNA_def_property(srna, "title", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "title"); + RNA_def_property_ui_text(prop, "Title", "Title for the file browser."); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "directory", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "dir"); + RNA_def_property_ui_text(prop, "Directory", "Directory displayed in the file browser."); + RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL); + + prop= RNA_def_property(srna, "file", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "file"); + RNA_def_property_ui_text(prop, "File Name", "Active file in the file browser."); + RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL); + prop= RNA_def_property(srna, "display", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "display"); RNA_def_property_enum_items(prop, file_display_items); @@ -989,6 +1120,9 @@ void RNA_def_space(BlenderRNA *brna) rna_def_background_image(brna); rna_def_space_3dview(brna); rna_def_space_buttons(brna); + rna_def_space_dopesheet(brna); + rna_def_space_graph(brna); + rna_def_space_nla(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index eef221e45a4..b10ca6c5e83 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -170,6 +170,8 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi if(strcmp(pt->idname, dummypt.idname) == 0) { if(pt->py_srna) rna_Panel_unregister(C, pt->py_srna); + else + BLI_freelinkN(&art->paneltypes, pt); break; } } @@ -607,6 +609,10 @@ static void rna_def_panel(BlenderRNA *brna) prop= RNA_def_property(srna, "default_closed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "type->flag", PNL_DEFAULT_CLOSED); RNA_def_property_flag(prop, PROP_REGISTER); + + prop= RNA_def_property(srna, "no_header", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", PNL_NO_HEADER); + RNA_def_property_flag(prop, PROP_REGISTER); } static void rna_def_header(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index b70112eebed..363891e0f24 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -130,11 +130,11 @@ void RNA_api_ui_layout(StructRNA *srna) api_ui_item_common(func); api_ui_item_rna_common(func); - /*func= RNA_def_function(srna, "item_enumR", "uiItemEnumR"); + func= RNA_def_function(srna, "item_enumR", "uiItemEnumR_string"); api_ui_item_common(func); api_ui_item_rna_common(func); parm= RNA_def_string(func, "value", "", 0, "", "Enum property value."); - RNA_def_property_flag(parm, PROP_REQUIRED);*/ + RNA_def_property_flag(parm, PROP_REQUIRED); func= RNA_def_function(srna, "item_pointerR", "uiItemPointerR"); api_ui_item_common(func); @@ -259,6 +259,8 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "template_list", "uiTemplateList"); api_ui_item_rna_common(func); + parm= RNA_def_pointer(func, "active_data", "AnyType", "", "Data from which to take property for the active element."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); 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); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 609082144e1..977c43e6b95 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -128,6 +128,11 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem font_kerning_style[] = { + {0, "UNFITTED", 0, "Unfitted", "Use scaled but un-grid-fitted kerning distances."}, + {1, "DEFAULT", 0, "Default", "Use scaled and grid-fitted kerning distances."}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "ThemeFontStyle", NULL); RNA_def_struct_sdna(srna, "uiFontStyle"); RNA_def_struct_ui_text(srna, "Font Style", "Theme settings for Font."); @@ -137,14 +142,10 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Points", ""); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "kerning", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, -5.0, 5.0); - RNA_def_property_ui_text(prop, "Kerning", "User kerning value in pixels"); - RNA_def_property_update(prop, NC_WINDOW, NULL); - - prop= RNA_def_property(srna, "overlap", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "overlap", 1); - RNA_def_property_ui_text(prop, "Overlap", "Check for overlap characters"); + prop= RNA_def_property(srna, "font_kerning_style", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "kerning"); + RNA_def_property_enum_items(prop, font_kerning_style); + RNA_def_property_ui_text(prop, "Kerning Style", "Which style to use for font kerning."); RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shadow", PROP_INT, PROP_NONE); @@ -184,6 +185,10 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) RNA_def_struct_sdna(srna, "uiStyle"); RNA_def_struct_ui_text(srna, "Style", "Theme settings for style sets."); + prop= RNA_def_property(srna, "panelzoom", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.5, 2.0); + RNA_def_property_ui_text(prop, "Panel Zoom", "Default zoom level for panel areas."); + prop= RNA_def_property(srna, "paneltitle", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "paneltitle"); RNA_def_property_struct_type(prop, "ThemeFontStyle"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index f8ab3a86744..9c9c256e819 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -69,23 +69,23 @@ EnumPropertyItem event_type_items[] = { {YKEY, "Y", 0, "Y", ""}, {ZKEY, "Z", 0, "Z", ""}, - {ZEROKEY, "ZERO", 0, "Zero Key", ""}, - {ONEKEY, "ONE", 0, "One Key", ""}, - {TWOKEY, "TWO", 0, "Two Key", ""}, - {THREEKEY, "THREE", 0, "Three Key", ""}, - {FOURKEY, "FOUR", 0, "Four Key", ""}, - {FIVEKEY, "FIVE", 0, "Five Key", ""}, - {SIXKEY, "SIX", 0, "Six Key", ""}, - {SEVENKEY, "SEVEN", 0, "Seven Key", ""}, - {EIGHTKEY, "EIGHT", 0, "Eight Key", ""}, - {NINEKEY, "NINE", 0, "Nine Key", ""}, + {ZEROKEY, "ZERO", 0, "0", ""}, + {ONEKEY, "ONE", 0, "1", ""}, + {TWOKEY, "TWO", 0, "2", ""}, + {THREEKEY, "THREE", 0, "3", ""}, + {FOURKEY, "FOUR", 0, "4", ""}, + {FIVEKEY, "FIVE", 0, "5", ""}, + {SIXKEY, "SIX", 0, "6", ""}, + {SEVENKEY, "SEVEN", 0, "7", ""}, + {EIGHTKEY, "EIGHT", 0, "8", ""}, + {NINEKEY, "NINE", 0, "9", ""}, {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""}, {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""}, + {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", ""}, {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""}, - {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Rightctrl", ""}, - {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Rightshift", ""}, - {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Leftshift", ""}, + {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", ""}, + {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", ""}, {ESCKEY, "ESC", 0, "Esc", ""}, {TABKEY, "TAB", 0, "Tab", ""}, @@ -94,17 +94,17 @@ EnumPropertyItem event_type_items[] = { {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""}, {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""}, {DELKEY, "DEL", 0, "Delete", ""}, - {SEMICOLONKEY, "SEMI_COLON", 0, "Semicolon", ""}, - {PERIODKEY, "PERIOD", 0, "Period", ""}, - {COMMAKEY, "COMMA", 0, "Comma", ""}, - {QUOTEKEY, "QUOTE", 0, "Quote", ""}, - {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "Accentgrave", ""}, - {MINUSKEY, "MINUS", 0, "Minus", ""}, - {SLASHKEY, "SLASH", 0, "Slash", ""}, - {BACKSLASHKEY, "BACK_SLASH", 0, "Backslash", ""}, - {EQUALKEY, "EQUAL", 0, "Equal", ""}, - {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "Leftbracket", ""}, - {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "Rightbracket", ""}, + {SEMICOLONKEY, "SEMI_COLON", 0, ";", ""}, + {PERIODKEY, "PERIOD", 0, ".", ""}, + {COMMAKEY, "COMMA", 0, ",", ""}, + {QUOTEKEY, "QUOTE", 0, "\"", ""}, + {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "`", ""}, + {MINUSKEY, "MINUS", 0, "-", ""}, + {SLASHKEY, "SLASH", 0, "/", ""}, + {BACKSLASHKEY, "BACK_SLASH", 0, "\\", ""}, + {EQUALKEY, "EQUAL", 0, "=", ""}, + {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "]", ""}, + {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "[", ""}, {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""}, {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""}, {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""}, diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index f5eb81e3cea..67328455a77 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -377,7 +377,7 @@ void RNA_def_world(BlenderRNA *brna) prop= RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "range"); RNA_def_property_range(prop, 0.2, 5.0); - RNA_def_property_ui_text(prop, "Range", "The color rage that will be mapped to 0-1"); + RNA_def_property_ui_text(prop, "Range", "The color range that will be mapped to 0-1."); /* sky type */ prop= RNA_def_property(srna, "blend_sky", PROP_BOOLEAN, PROP_NONE); |