diff options
Diffstat (limited to 'source/blender/makesrna/intern')
57 files changed, 3272 insertions, 944 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index af857b61e26..7a3bb230a78 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -61,7 +61,6 @@ /* Replace if different */ #define TMP_EXT ".tmp" - /* copied from BLI_file_older */ #include <sys/stat.h> static int file_older(const char *file1, const char *file2) @@ -76,6 +75,24 @@ static int file_older(const char *file1, const char *file2) } static const char *makesrna_path = NULL; +/* forward declarations */ +static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, + const char *name_override, int close_prototype); + +/* helpers */ +#define WRITE_COMMA \ + { \ + if (!first) \ + fprintf(f, ", "); \ + first = 0; \ + } (void)0 + +#define WRITE_PARAM(param) \ + { \ + WRITE_COMMA; \ + fprintf(f, param); \ + } + static int replace_if_different(char *tmpfile, const char *dep_files[]) { /* return 0; *//* use for testing had edited rna */ @@ -212,6 +229,8 @@ static const char *rna_safe_id(const char *id) return "default_value"; else if (strcmp(id, "operator") == 0) return "operator_value"; + else if (strcmp(id, "new") == 0) + return "create"; return id; } @@ -322,13 +341,26 @@ static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp)) fprintf(f, " ID *id= ptr->id.data;\n"); } +static void rna_construct_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type) +{ + snprintf(buffer, size, "%s_%s_%s", structname, propname, type); +} + +static void rna_construct_wrapper_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type) +{ + if (type == NULL || type[0] == '\0') + snprintf(buffer, size, "%s_%s", structname, propname); + else + snprintf(buffer, size, "%s_%s_%s", structname, propname, type); +} + static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type) { AllocDefRNA *alloc; char buffer[2048]; char *result; - snprintf(buffer, sizeof(buffer), "%s_%s_%s", structname, propname, type); + rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type); result = MEM_callocN(sizeof(char) * strlen(buffer) + 1, "rna_alloc_function_name"); strcpy(result, buffer); @@ -627,17 +659,17 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr "get_length"); fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n"); fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc); - fprintf(f, " for (i=0; i<len; i++) {\n"); + fprintf(f, " for (i=0; i < len; i++) {\n"); MEM_freeN(lenfunc); } else { fprintf(f, " int i;\n\n"); - fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength); + fprintf(f, " for (i=0; i < %u; i++) {\n", prop->totarraylength); } if (dp->dnaarraylength == 1) { if (prop->type == PROP_BOOLEAN && dp->booleanbit) { - fprintf(f, " values[i] = %s((data->%s & (%d<<i)) != 0);\n", + fprintf(f, " values[i] = %s((data->%s & (%d << i)) != 0);\n", (dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit); } else { @@ -653,7 +685,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, ") != 0);\n"); } else if (rna_color_quantize(prop, dp)) { - fprintf(f, " values[i] = (%s)(data->%s[i]*(1.0f/255.0f));\n", + fprintf(f, " values[i] = (%s)(data->%s[i]*(1.0f / 255.0f));\n", rna_type_type(prop), dp->dnaname); } else if (dp->dnatype) { @@ -878,20 +910,20 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n"); fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc); rna_clamp_value_range(f, prop); - fprintf(f, " for (i=0; i<len; i++) {\n"); + fprintf(f, " for (i=0; i < len; i++) {\n"); MEM_freeN(lenfunc); } else { fprintf(f, " int i;\n\n"); rna_clamp_value_range(f, prop); - fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength); + fprintf(f, " for (i=0; i < %u; i++) {\n", prop->totarraylength); } if (dp->dnaarraylength == 1) { if (prop->type == PROP_BOOLEAN && dp->booleanbit) { fprintf(f, " if (%svalues[i]) data->%s |= (%d<<i);\n", (dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit); - fprintf(f, " else data->%s &= ~(%d<<i);\n", dp->dnaname, dp->booleanbit); + fprintf(f, " else data->%s &= ~(%d << i);\n", dp->dnaname, dp->booleanbit); } else { fprintf(f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : ""); @@ -1015,9 +1047,9 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA else { rna_print_data_get(f, dp); if (dp->dnalengthname) - fprintf(f, " return (data->%s == NULL)? 0: data->%s;\n", dp->dnaname, dp->dnalengthname); + fprintf(f, " return (data->%s == NULL) ? 0 : data->%s;\n", dp->dnaname, dp->dnalengthname); else - fprintf(f, " return (data->%s == NULL)? 0: %d;\n", dp->dnaname, dp->dnalengthfixed); + fprintf(f, " return (data->%s == NULL) ? 0 : %d;\n", dp->dnaname, dp->dnalengthfixed); } fprintf(f, "}\n\n"); } @@ -1102,8 +1134,8 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property return NULL; /* only supported in case of standard next functions */ - if (strcmp(nextfunc, "rna_iterator_array_next") == 0) ; - else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) ; + if (strcmp(nextfunc, "rna_iterator_array_next") == 0) {} + else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {} else return NULL; } @@ -1372,9 +1404,12 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; const char *nextfunc = (const char *)cprop->next; - if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) ; - else if (dp->dnalengthname || dp->dnalengthfixed) + if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) { + /* pass */ + } + else if (dp->dnalengthname || dp->dnalengthfixed) { cprop->length = (void *)rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length); + } /* test if we can allow raw array access, if it is using our standard * array get/next function, we can be sure it is an actual array */ @@ -1437,15 +1472,15 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR { if (!prop->arraydimension) { fprintf(f, "int %sget(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); } else if (prop->arraydimension && prop->totarraylength) { fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength); - /*fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->arraylength); */ + fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->totarraylength); } else { fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func); } break; } @@ -1453,15 +1488,15 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR { if (!prop->arraydimension) { fprintf(f, "float %sget(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func); } else if (prop->arraydimension && prop->totarraylength) { fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength); - /*fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->arraylength); */ + fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->totarraylength); } else { fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);", func); } break; } @@ -1482,7 +1517,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR } fprintf(f, "int %sget(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); break; } @@ -1496,7 +1531,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func); fprintf(f, "int %slength(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func); break; } @@ -1508,19 +1543,38 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR } case PROP_COLLECTION: { + CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func); fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func); fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func); - /*fprintf(f, "int %slength(PointerRNA *ptr);\n", func); */ - /*fprintf(f, "void %slookup_int(PointerRNA *ptr, int key, StructRNA **type);\n", func); */ - /*fprintf(f, "void %slookup_string(PointerRNA *ptr, const char *key, StructRNA **type);\n", func); */ + if (cprop->length) + fprintf(f, "int %slength(PointerRNA *ptr);\n", func); + if (cprop->lookupint) + fprintf(f, "int %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func); + if (cprop->lookupstring) + fprintf(f, "int %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n", func); break; } } + if (prop->getlength) { + char funcname[2048]; + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, prop->identifier, "get_length"); + fprintf(f, "int %s(PointerRNA *ptr, int *arraylen);\n", funcname); + } + fprintf(f, "\n"); } +static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + FunctionRNA *func = dfunc->func; + char funcname[2048]; + + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL); + rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 1); +} + static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp) { PropertyRNA *prop; @@ -1540,26 +1594,50 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property switch (prop->type) { case PROP_BOOLEAN: { - if (!prop->arraydimension) - fprintf(f, "\tinline bool %s(void);", rna_safe_id(prop->identifier)); - else if (prop->totarraylength) - fprintf(f, "\tinline Array<int, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier)); + if (!prop->arraydimension) { + fprintf(f, "\tinline bool %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier)); + } + else if (prop->totarraylength) { + fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength); + } + else if (prop->getlength) { + fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier)); + } break; } case PROP_INT: { - if (!prop->arraydimension) - fprintf(f, "\tinline int %s(void);", rna_safe_id(prop->identifier)); - else if (prop->totarraylength) - fprintf(f, "\tinline Array<int, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier)); + if (!prop->arraydimension) { + fprintf(f, "\tinline int %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier)); + } + else if (prop->totarraylength) { + fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength); + } + else if (prop->getlength) { + fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier)); + } break; } case PROP_FLOAT: { - if (!prop->arraydimension) - fprintf(f, "\tinline float %s(void);", rna_safe_id(prop->identifier)); - else if (prop->totarraylength) - fprintf(f, "\tinline Array<float, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier)); + if (!prop->arraydimension) { + fprintf(f, "\tinline float %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(float value);", rna_safe_id(prop->identifier)); + } + else if (prop->totarraylength) { + fprintf(f, "\tinline Array<float, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(float values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength); + } + else if (prop->getlength) { + fprintf(f, "\tinline DynamicArray<float> %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(float values[]);", rna_safe_id(prop->identifier)); + } break; } case PROP_ENUM: @@ -1578,12 +1656,14 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property fprintf(f, "\t};\n"); } - fprintf(f, "\tinline %s_enum %s(void);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier)); + fprintf(f, "\tinline %s_enum %s(void);\n", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(%s_enum value);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier)); break; } case PROP_STRING: { fprintf(f, "\tinline std::string %s(void);", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(const std::string& value);", rna_safe_id(prop->identifier)); break; } case PROP_POINTER: @@ -1599,13 +1679,19 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property case PROP_COLLECTION: { CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop; + const char *collection_funcs = "DefaultCollectionFunctions"; + + if (!(dp->prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN)) && cprop->property.srna) + collection_funcs = (char*)cprop->property.srna; if (cprop->item_type) - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (const char *)cprop->item_type, srna->identifier, - rna_safe_id(prop->identifier)); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, (const char *)cprop->item_type, srna->identifier, + rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); else - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, - rna_safe_id(prop->identifier)); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, "UnknownType", srna->identifier, + rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); break; } } @@ -1613,6 +1699,96 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property fprintf(f, "\n"); } +static const char *rna_parameter_type_cpp_name(PropertyRNA *prop) +{ + if (prop->type == PROP_POINTER) { + /* for cpp api we need to use RNA structures names for pointers */ + PointerPropertyRNA *pprop = (PointerPropertyRNA *) prop; + + return (const char *) pprop->type; + } + else { + return rna_parameter_type_name(prop); + } +} + +static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, + const char *namespace, int close_prototype) +{ + PropertyDefRNA *dp; + FunctionRNA *func = dfunc->func; + + int first = 1; + const char *retval_type = "void"; + + if (func->c_ret) { + dp = rna_find_parameter_def(func->c_ret); + retval_type = rna_parameter_type_cpp_name(dp->prop); + } + + if (namespace && namespace[0]) + fprintf(f, "\tinline %s %s::%s(", retval_type, namespace, rna_safe_id(func->identifier)); + else + fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier)); + + if (func->flag & FUNC_USE_MAIN) + WRITE_PARAM("void *main"); + + if (func->flag & FUNC_USE_CONTEXT) + WRITE_PARAM("Context C"); + + for (dp = dfunc->cont.properties.first; dp; dp = dp->next) { + int type, flag, pout; + const char *ptrstr; + + if (dp->prop == func->c_ret) + continue; + + type = dp->prop->type; + flag = dp->prop->flag; + pout = (flag & PROP_OUTPUT); + + if (type == PROP_POINTER) + ptrstr = ""; + else if ((type == PROP_POINTER) && (flag & PROP_RNAPTR) && !(flag & PROP_THICK_WRAP)) + ptrstr = "*"; + else if (type == PROP_POINTER || dp->prop->arraydimension) + ptrstr = "*"; + else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) + ptrstr = ""; + else + ptrstr = pout ? "*" : ""; + + WRITE_COMMA; + + if (flag & PROP_DYNAMIC) + fprintf(f, "int %s%s_len, ", (flag & PROP_OUTPUT) ? "*" : "", dp->prop->identifier); + + if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension) + fprintf(f, "%s %s[%u]", rna_parameter_type_cpp_name(dp->prop), + rna_safe_id(dp->prop->identifier), dp->prop->totarraylength); + else + fprintf(f, "%s %s%s", rna_parameter_type_cpp_name(dp->prop), + ptrstr, rna_safe_id(dp->prop->identifier)); + } + + fprintf(f, ")"); + if (close_prototype) + fprintf(f, ";\n"); +} + +static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + FunctionRNA *func = dfunc->func; + + if (!dfunc->call) + return; + + fprintf(f, "\n\t/* %s */\n", func->description); + + rna_def_struct_function_prototype_cpp(f, srna, dfunc, NULL, 1); +} + static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp) { PropertyRNA *prop; @@ -1630,6 +1806,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe else if (prop->totarraylength) fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier)); + else if (prop->getlength) + fprintf(f, "\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier, + rna_safe_id(prop->identifier)); break; } case PROP_INT: @@ -1639,6 +1818,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe else if (prop->totarraylength) fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier)); + else if (prop->getlength) + fprintf(f, "\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier, + rna_safe_id(prop->identifier)); break; } case PROP_FLOAT: @@ -1648,6 +1830,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe else if (prop->totarraylength) fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier)); + else if (prop->getlength) + fprintf(f, "\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier, + rna_safe_id(prop->identifier)); break; } case PROP_ENUM: @@ -1680,10 +1865,13 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop; if (cprop->type) - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (const char *)cprop->type, srna->identifier, - prop->identifier); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, srna->identifier, + prop->identifier, (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); else - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier, + prop->identifier, (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); #endif break; } @@ -1692,6 +1880,181 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe fprintf(f, "\n"); } +static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + PropertyDefRNA *dp; + StructDefRNA *dsrna; + FunctionRNA *func = dfunc->func; + char funcname[2048]; + + int first = 1; + + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL); + + fprintf(f, "%s(", funcname); + + dsrna = rna_find_struct_def(srna); + + if (func->flag & FUNC_USE_SELF_ID) + WRITE_PARAM("(::ID *) ptr.id.data"); + + if ((func->flag & FUNC_NO_SELF) == 0) { + WRITE_COMMA; + if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname); + else fprintf(f, "(::%s *) this->ptr.data", srna->identifier); + } + + if (func->flag & FUNC_USE_MAIN) + WRITE_PARAM("(::Main *) main"); + + if (func->flag & FUNC_USE_CONTEXT) + WRITE_PARAM("(::bContext *) C.ptr.data"); + + if (func->flag & FUNC_USE_REPORTS) + WRITE_PARAM("NULL"); + + dp = dfunc->cont.properties.first; + for (; dp; dp = dp->next) { + if (dp->prop == func->c_ret) + continue; + + WRITE_COMMA; + + if (dp->prop->flag & PROP_DYNAMIC) + fprintf(f, "%s_len, ", dp->prop->identifier); + + if (dp->prop->type == PROP_POINTER) + if ((dp->prop->flag & PROP_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP)) + fprintf(f, "(::%s *) &%s.ptr", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier)); + else + fprintf(f, "(::%s *) %s.ptr.data", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier)); + else + fprintf(f, "%s", rna_safe_id(dp->prop->identifier)); + } + + fprintf(f, ");\n"); +} + +static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + PropertyDefRNA *dp; + PointerPropertyRNA *pprop; + + FunctionRNA *func = dfunc->func; + + if (!dfunc->call) + return; + + rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0); + + fprintf(f, " {\n"); + + if (func->c_ret) { + dp = rna_find_parameter_def(func->c_ret); + + if (dp->prop->type == PROP_POINTER) { + pprop = (PointerPropertyRNA *) dp->prop; + + fprintf(f, "\t\tPointerRNA result;\n"); + + if ((dp->prop->flag & PROP_RNAPTR) == 0) { + StructRNA *ret_srna = rna_find_struct((const char *) pprop->type); + fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop)); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + if (ret_srna->flag & STRUCT_ID) + fprintf(f, "\t\tRNA_id_pointer_create((::ID *) retdata, &result);\n"); + else + fprintf(f, "\t\tRNA_pointer_create((::ID *) ptr.id.data, &RNA_%s, retdata, &result);\n", (const char *) pprop->type); + } + else { + fprintf(f, "\t\tresult = "); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + } + + fprintf(f, "\t\treturn %s(result);\n", (const char *) pprop->type); + } + else { + fprintf(f, "\t\treturn "); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + } + } + else { + fprintf(f, "\t\t"); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + } + + fprintf(f, "\t}\n\n"); +} + +static void rna_def_property_wrapper_funcs(FILE *f, StructDefRNA *dsrna, PropertyDefRNA *dp) +{ + if (dp->prop->getlength) { + char funcname[2048]; + rna_construct_wrapper_function_name(funcname, sizeof(funcname), dsrna->srna->identifier, dp->prop->identifier, "get_length"); + fprintf(f, "int %s(PointerRNA *ptr, int *arraylen)\n", funcname); + fprintf(f, "{\n"); + fprintf(f, "\treturn %s(ptr, arraylen);\n", rna_function_string(dp->prop->getlength)); + fprintf(f, "}\n\n"); + } +} + +static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc) +{ + StructRNA *srna = dsrna->srna; + FunctionRNA *func = dfunc->func; + PropertyDefRNA *dparm; + + int first; + char funcname[2048]; + + if (!dfunc->call) + return; + + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL); + + rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 0); + + fprintf(f, "\n{\n"); + + if (func->c_ret) + fprintf(f, "\treturn %s(", dfunc->call); + else + fprintf(f, "\t%s(", dfunc->call); + + first = 1; + + if (func->flag & FUNC_USE_SELF_ID) + WRITE_PARAM("_selfid"); + + if ((func->flag & FUNC_NO_SELF) == 0) + WRITE_PARAM("_self"); + + if (func->flag & FUNC_USE_MAIN) + WRITE_PARAM("bmain"); + + if (func->flag & FUNC_USE_CONTEXT) + WRITE_PARAM("C"); + + if (func->flag & FUNC_USE_REPORTS) + WRITE_PARAM("reports"); + + dparm = dfunc->cont.properties.first; + for (; dparm; dparm = dparm->next) { + if (dparm->prop == func->c_ret) + continue; + + WRITE_COMMA; + + if (dparm->prop->flag & PROP_DYNAMIC) + fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier); + else + fprintf(f, "%s", rna_safe_id(dparm->prop->identifier)); + } + + fprintf(f, ");\n"); + fprintf(f, "}\n\n"); +} + static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc) { StructRNA *srna; @@ -1741,6 +2104,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA /* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */ else if (type == PROP_POINTER || dparm->prop->arraydimension) ptrstr = "*"; + else if ((type == PROP_POINTER) && (flag & PROP_RNAPTR) && !(flag & PROP_THICK_WRAP)) + ptrstr = "*"; /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack, * but type name for string props is already char*, so leave empty */ else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) @@ -1792,6 +2157,10 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA ptrstr = "**"; valstr = "*"; } + else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) { + ptrstr = "**"; + valstr = "*"; + } else if (type == PROP_POINTER || dparm->prop->arraydimension) { ptrstr = "*"; valstr = ""; @@ -1991,6 +2360,7 @@ static const char *rna_property_subtypename(PropertySubType type) case PROP_COORDS: return "PROP_COORDS"; case PROP_LAYER: return "PROP_LAYER"; case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER"; + case PROP_PASSWORD: return "PROP_PASSWORD"; default: { /* in case we don't have a type preset that includes the subtype */ if (RNA_SUBTYPE_UNIT(type)) { @@ -2107,7 +2477,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, fprintf(f, "\n"); } -static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionDefRNA *dfunc, FILE *f) +static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, const char *name_override, int close_prototype) { FunctionRNA *func; PropertyDefRNA *dparm; @@ -2138,7 +2508,10 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S fprintf(f, "void "); /* function name */ - fprintf(f, "%s(", dfunc->call); + if (name_override == NULL || name_override[0] == '\0') + fprintf(f, "%s(", dfunc->call); + else + fprintf(f, "%s(", name_override); first = 1; @@ -2147,7 +2520,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S fprintf(f, "struct ID *_selfid"); first = 0; } - + if ((func->flag & FUNC_NO_SELF) == 0) { if (!first) fprintf(f, ", "); if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); @@ -2200,17 +2573,19 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension) fprintf(f, "%s%s %s[%u]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), - dparm->prop->identifier, dparm->prop->totarraylength); + rna_safe_id(dparm->prop->identifier), dparm->prop->totarraylength); else fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), - ptrstr, dparm->prop->identifier); + ptrstr, rna_safe_id(dparm->prop->identifier)); } - fprintf(f, ");\n"); + fprintf(f, ")"); + if (close_prototype) + fprintf(f, ";\n"); } -static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f) +static void rna_generate_static_function_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f) { FunctionRNA *func; FunctionDefRNA *dfunc; @@ -2225,7 +2600,50 @@ static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA first = 0; } - rna_generate_static_parameter_prototypes(brna, srna, dfunc, f); + rna_generate_static_parameter_prototypes(f, srna, dfunc, NULL, 1); + } + } + + fprintf(f, "\n"); +} + +static void rna_generate_struct_prototypes(FILE *f) +{ + StructDefRNA *ds; + PropertyDefRNA *dp; + FunctionDefRNA *dfunc; + const char *structures[2048]; + int all_structures = 0; + + /* structures definitions */ + for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) { + if (dfunc->call) { + for (dp = dfunc->cont.properties.first; dp; dp = dp->next) { + if (dp->prop->type == PROP_POINTER) { + int a, found = 0; + const char *struct_name = rna_parameter_type_name(dp->prop); + + for (a = 0; a < all_structures; a++) { + if (strcmp(struct_name, structures[a]) == 0) { + found = 1; + break; + } + } + + if (found == 0) { + fprintf(f, "struct %s;\n", struct_name); + + if (all_structures >= sizeof(structures) / sizeof(structures[0])) { + printf("Array size to store all structures names is too small\n"); + exit(1); + } + + structures[all_structures++] = struct_name; + } + } + } + } } } @@ -2791,8 +3209,13 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { if (!filename || ds->filename == filename) { - for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + for (dp = ds->cont.properties.first; dp; dp = dp->next) + rna_def_property_wrapper_funcs(f, ds, dp); + + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) { + rna_def_function_wrapper_funcs(f, ds, dfunc); rna_def_function_funcs(f, ds, dfunc); + } rna_generate_static_function_prototypes(brna, ds->srna, f); } @@ -2816,6 +3239,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) StructDefRNA *ds; PropertyDefRNA *dp; StructRNA *srna; + FunctionDefRNA *dfunc; fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n"); fprintf(f, "#define __RNA_BLENDER_H__\n\n"); @@ -2853,6 +3277,9 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) for (dp = ds->cont.properties.first; dp; dp = dp->next) rna_def_property_funcs_header(f, ds->srna, dp); + + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + rna_def_function_funcs_header(f, ds->srna, dfunc); } fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n"); @@ -2868,43 +3295,141 @@ static const char *cpp_classes = "" "namespace BL {\n" "\n" "#define BOOLEAN_PROPERTY(sname, identifier) \\\n" -" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; }\n" +" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; } \\\n" +" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n" " inline Array<int,size> sname::identifier(void) \\\n" -" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n" +" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" +" inline void sname::identifier(int values[size]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" +"\n" +"#define BOOLEAN_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n" +" inline DynamicArray<int> sname::identifier(void) { \\\n" +" int arraylen[3]; \\\n" +" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n" +" DynamicArray<int> ar(len); \\\n" +" sname##_##identifier##_get(&ptr, ar.data); \\\n" +" return ar; } \\\n" +" inline void sname::identifier(int values[]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" "\n" "#define INT_PROPERTY(sname, identifier) \\\n" -" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n" +" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n" +" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n" " inline Array<int,size> sname::identifier(void) \\\n" -" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n" +" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" +" inline void sname::identifier(int values[size]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" +"\n" +"#define INT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n" +" inline DynamicArray<int> sname::identifier(void) { \\\n" +" int arraylen[3]; \\\n" +" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n" +" DynamicArray<int> ar(len); \\\n" +" sname##_##identifier##_get(&ptr, ar.data); \\\n" +" return ar; } \\\n" +" inline void sname::identifier(int values[]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" "\n" "#define FLOAT_PROPERTY(sname, identifier) \\\n" -" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n" +" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n" +" inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n" " inline Array<float,size> sname::identifier(void) \\\n" -" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n" +" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" +" inline void sname::identifier(float values[size]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" +"\n" +"#define FLOAT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n" +" inline DynamicArray<float> sname::identifier(void) { \\\n" +" int arraylen[3]; \\\n" +" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n" +" DynamicArray<float> ar(len); \\\n" +" sname##_##identifier##_get(&ptr, ar.data); \\\n" +" return ar; } \\\n" +" inline void sname::identifier(float values[]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" "\n" "#define ENUM_PROPERTY(type, sname, identifier) \\\n" -" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); }\n" +" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); } \\\n" +" inline void sname::identifier(sname::type value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define STRING_PROPERTY(sname, identifier) \\\n" " inline std::string sname::identifier(void) { \\\n" " int len= sname##_##identifier##_length(&ptr); \\\n" " std::string str; str.resize(len); \\\n" " sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n" +" inline void sname::identifier(const std::string& value) { \\\n" +" sname##_##identifier##_set(&ptr, value.c_str()); } \\\n" "\n" "#define POINTER_PROPERTY(type, sname, identifier) \\\n" " inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n" "\n" -"#define COLLECTION_PROPERTY(type, sname, identifier) \\\n" +"#define COLLECTION_PROPERTY_LENGTH_FALSE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n" +" { \\\n" +" CollectionPropertyIterator iter; \\\n" +" int length = 0; \\\n" +" sname##_##identifier##_begin(&iter, ptr); \\\n" +" while (iter.valid) { \\\n" +" sname##_##identifier##_next(&iter); \\\n" +" ++length; \\\n" +" } \\\n" +" sname##_##identifier##_end(&iter); \\\n" +" return length; \\\n" +" } \n" +"#define COLLECTION_PROPERTY_LENGTH_TRUE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n" +" { return sname##_##identifier##_length(ptr); } \n" +"\n" +"#define COLLECTION_PROPERTY_LOOKUP_INT_FALSE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n" +" { \\\n" +" CollectionPropertyIterator iter; \\\n" +" int i = 0, found = 0; \\\n" +" sname##_##identifier##_begin(&iter, ptr); \\\n" +" while (iter.valid) { \\\n" +" if (i == key) { \\\n" +" *r_ptr = iter.ptr; \\\n" +" found = 1; \\\n" +" break; \\\n" +" } \\\n" +" sname##_##identifier##_next(&iter); \\\n" +" ++i; \\\n" +" } \\\n" +" sname##_##identifier##_end(&iter); \\\n" +" if (!found) \\\n" +" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" +" return found; \\\n" +" } \n" +"#define COLLECTION_PROPERTY_LOOKUP_INT_TRUE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n" +" { return sname##_##identifier##_lookup_int(ptr, key, r_ptr); } \n" +"\n" +"#define COLLECTION_PROPERTY_LOOKUP_STRING_FALSE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n" +" { \\\n" +" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" +" return 0; \\\n" +" } \n" +"#define COLLECTION_PROPERTY_LOOKUP_STRING_TRUE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n" +" { return sname##_##identifier##_lookup_string(ptr, key, r_ptr); } \n" +"\n" +"#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, has_lookup_int, has_lookup_string) \\\n" " typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n" " sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n" +" COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n" +" COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n" +" COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n" " Collection<sname, type, sname##_##identifier##_begin, \\\n" -" sname##_##identifier##_next, sname##_##identifier##_end> identifier;\n" +" sname##_##identifier##_next, sname##_##identifier##_end, \\\n" +" sname##_##identifier##_length_wrap, \\\n" +" sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap, collection_funcs> identifier;\n" "\n" "class Pointer {\n" "public:\n" @@ -2923,7 +3448,7 @@ static const char *cpp_classes = "" "public:\n" " T data[Tsize];\n" "\n" -" Array() {}\n" +" Array() {}\n" " Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n" " const Array<T, Tsize>& operator=(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); " "return *this; }\n" @@ -2931,9 +3456,36 @@ static const char *cpp_classes = "" " operator T*() { return data; }\n" "};\n" "\n" +"template<typename T>\n" +"class DynamicArray {\n" +"public:\n" +" T *data;\n" +" int length;\n" +"\n" +" DynamicArray() : data(NULL), length(0) {}\n" +" DynamicArray(int new_length) : data(NULL), length(new_length) { data = (float*)malloc(sizeof(T) * new_length); }\n" +" DynamicArray(const DynamicArray<T>& other) { copy_from(other); }\n" +" const DynamicArray<T>& operator=(const DynamicArray<T>& other) { copy_from(other); return *this; }\n" +"\n" +" ~DynamicArray() { if (data) free(data); }\n" +"\n" +" operator T*() { return data; }\n" +"\n" +"protected:\n" +" void copy_from(const DynamicArray<T>& other) {\n" +" if (data) free(data);\n" +" data = (float*)malloc(sizeof(T) * other.length);\n" +" memcpy(data, other.data, sizeof(T) * other.length);\n" +" length = other.length;\n" +" }\n" +"};\n" +"\n" "typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n" "typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n" "typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n" +"typedef int (*TLengthFunc)(PointerRNA *ptr);\n" +"typedef int (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n" +"typedef int (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n" "\n" "template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n" "class CollectionIterator {\n" @@ -2964,26 +3516,97 @@ static const char *cpp_classes = "" " bool init;\n" "};\n" "\n" -"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n" -"class Collection {\n" +"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n" +" TLengthFunc Tlength, TLookupIntFunc Tlookup_int, TLookupStringFunc Tlookup_string,\n" +" typename Tcollection_funcs>\n" +"class Collection : public Tcollection_funcs {\n" "public:\n" -" Collection(const PointerRNA &p) : ptr(p) {}\n" +" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n" "\n" " void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n" " { iter.begin(ptr); }\n" " CollectionIterator<T, Tbegin, Tnext, Tend> end()\n" " { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n" +"" +" int length()\n" +" { return Tlength(&ptr); }\n" +" T operator[](int key)\n" +" { PointerRNA r_ptr; Tlookup_int(&ptr, key, &r_ptr); return T(r_ptr); }\n" +" T operator[](const std::string &key)\n" +" { PointerRNA r_ptr; Tlookup_string(&ptr, key.c_str(), &r_ptr); return T(r_ptr); }\n" "\n" "private:\n" " PointerRNA ptr;\n" "};\n" +"\n" +"class DefaultCollectionFunctions {\n" +"public:\n" +" DefaultCollectionFunctions(const PointerRNA &p) {}\n" +"};\n" +"\n" "\n"; +static int rna_is_collection_prop(PropertyRNA *prop) +{ + if (!(prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN))) + if (prop->type == PROP_COLLECTION) + return 1; + + return 0; +} + +static int rna_is_collection_functions_struct(const char **collection_structs, const char *struct_name) +{ + int a = 0, found = 0; + + while (collection_structs[a]) { + if (!strcmp(collection_structs[a], struct_name)) { + found = 1; + break; + } + a++; + } + + return found; +} + +static void rna_generate_header_class_cpp(StructDefRNA *ds, FILE *f) +{ + StructRNA *srna = ds->srna; + PropertyDefRNA *dp; + FunctionDefRNA *dfunc; + + fprintf(f, "/**************** %s ****************/\n\n", srna->name); + + fprintf(f, "class %s : public %s {\n", srna->identifier, (srna->base) ? srna->base->identifier : "Pointer"); + fprintf(f, "public:\n"); + fprintf(f, "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)", srna->identifier, + (srna->base) ? srna->base->identifier : "Pointer"); + for (dp = ds->cont.properties.first; dp; dp = dp->next) + if (rna_is_collection_prop(dp->prop)) + fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier); + fprintf(f, "\n\t\t{}\n\n"); + + for (dp = ds->cont.properties.first; dp; dp = dp->next) + rna_def_property_funcs_header_cpp(f, ds->srna, dp); + + fprintf(f, "\n"); + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + rna_def_struct_function_header_cpp(f, srna, dfunc); + + fprintf(f, "};\n\n"); +} + static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) { StructDefRNA *ds; PropertyDefRNA *dp; StructRNA *srna; + FunctionDefRNA *dfunc; + const char *first_collection_func_struct = NULL; + const char *collection_func_structs[256] = {NULL}; + int all_collection_func_structs = 0; + int max_collection_func_structs = sizeof(collection_func_structs) / sizeof(collection_func_structs[0]) - 1; fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n"); fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n"); @@ -3000,38 +3623,86 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) fprintf(f, "/**************** Declarations ****************/\n\n"); - for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) + for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { fprintf(f, "class %s;\n", ds->srna->identifier); + } fprintf(f, "\n"); + /* first get list of all structures used as collection functions, so they'll be declared first */ + for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { + for (dp = ds->cont.properties.first; dp; dp = dp->next) { + if (rna_is_collection_prop(dp->prop)) { + PropertyRNA *prop = dp->prop; + + if (prop->srna) { + /* store name of structure which first uses custom functions for collections */ + if (first_collection_func_struct == NULL) + first_collection_func_struct = ds->srna->identifier; + + if (!rna_is_collection_functions_struct(collection_func_structs, (char*)prop->srna)) { + if (all_collection_func_structs >= max_collection_func_structs) { + printf("Array size to store all collection structures names is too small\n"); + exit(1); + } + + collection_func_structs[all_collection_func_structs++] = (char*)prop->srna; + } + } + } + } + } + + /* declare all structures in such order: + * - first N structures which doesn't use custom functions for collections + * - all structures used for custom functions in collections + * - all the rest structures + * such an order prevents usage of non-declared classes + */ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { srna = ds->srna; - fprintf(f, "/**************** %s ****************/\n\n", srna->name); + if (!strcmp(srna->identifier, first_collection_func_struct)) { + StructDefRNA *ds2; + StructRNA *srna2; - fprintf(f, "class %s : public %s {\n", srna->identifier, (srna->base) ? srna->base->identifier : "Pointer"); - fprintf(f, "public:\n"); - fprintf(f, "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)", srna->identifier, - (srna->base) ? srna->base->identifier : "Pointer"); - for (dp = ds->cont.properties.first; dp; dp = dp->next) - if (!(dp->prop->flag & (PROP_IDPROPERTY | PROP_BUILTIN))) - if (dp->prop->type == PROP_COLLECTION) - fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier); - fprintf(f, "\n\t\t{}\n\n"); + for (ds2 = DefRNA.structs.first; ds2; ds2 = ds2->cont.next) { + srna2 = ds2->srna; - for (dp = ds->cont.properties.first; dp; dp = dp->next) - rna_def_property_funcs_header_cpp(f, ds->srna, dp); - fprintf(f, "};\n\n"); + if (rna_is_collection_functions_struct(collection_func_structs, srna2->identifier)) { + rna_generate_header_class_cpp(ds2, f); + } + } + } + + if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier)) + rna_generate_header_class_cpp(ds, f); } + fprintf(f, "} /* namespace BL */\n"); + fprintf(f, "\n"); fprintf(f, "/**************** Implementation ****************/\n"); + fprintf(f, "\n"); + + fprintf(f, "/* Structure prototypes */\n\n"); + fprintf(f, "extern \"C\" {\n"); + rna_generate_struct_prototypes(f); + fprintf(f, "}\n\n"); + + fprintf(f, "namespace BL {\n"); for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { + srna = ds->srna; + for (dp = ds->cont.properties.first; dp; dp = dp->next) rna_def_property_funcs_impl_cpp(f, ds->srna, dp); fprintf(f, "\n"); + + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + rna_def_struct_function_impl_cpp(f, srna, dfunc); + + fprintf(f, "\n"); } fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n"); @@ -3068,34 +3739,8 @@ static int rna_preprocess(const char *outfile) rna_auto_types(); - - /* create RNA_blender_cpp.h */ - strcpy(deffile, outfile); - strcat(deffile, "RNA_blender_cpp.h" TMP_EXT); - status = (DefRNA.error != 0); - if (status) { - make_bad_file(deffile, __LINE__); - } - else { - file = fopen(deffile, "w"); - - if (!file) { - fprintf(stderr, "Unable to open file: %s\n", deffile); - status = 1; - } - else { - rna_generate_header_cpp(brna, file); - fclose(file); - status = (DefRNA.error != 0); - } - } - - replace_if_different(deffile, NULL); - - rna_sort(brna); - /* create rna_gen_*.c files */ for (i = 0; PROCESS_ITEMS[i].filename; i++) { strcpy(deffile, outfile); @@ -3128,6 +3773,31 @@ static int rna_preprocess(const char *outfile) replace_if_different(deffile, deps); } + /* create RNA_blender_cpp.h */ + strcpy(deffile, outfile); + strcat(deffile, "RNA_blender_cpp.h" TMP_EXT); + + if (status) { + make_bad_file(deffile, __LINE__); + } + else { + file = fopen(deffile, "w"); + + if (!file) { + fprintf(stderr, "Unable to open file: %s\n", deffile); + status = 1; + } + else { + rna_generate_header_cpp(brna, file); + fclose(file); + status = (DefRNA.error != 0); + } + } + + replace_if_different(deffile, NULL); + + rna_sort(brna); + /* create RNA_blender.h */ strcpy(deffile, outfile); strcat(deffile, "RNA_blender.h" TMP_EXT); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 3ff63380491..11ce7345e41 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -243,8 +243,8 @@ StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports, * owns the string pointer which it could potentially free while blender * is running. */ if (BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) { - BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is " - STRINGIFY(MAX_IDPROP_NAME), identifier); + BKE_reportf(reports, RPT_ERROR, "Registering id property class: '%s' is too long, maximum length is %d", + identifier, MAX_IDPROP_NAME); return NULL; } @@ -287,7 +287,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) switch (GS(id->name)) { case ID_OB: if (flag & ~(OB_RECALC_ALL)) { - BKE_report(reports, RPT_ERROR, "'refresh' incompatible with Object ID type"); + BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with Object ID type"); return; } break; @@ -295,7 +295,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) #if 0 case ID_PA: if (flag & ~(OB_RECALC_ALL | PSYS_RECALC)) { - BKE_report(reports, RPT_ERROR, "'refresh' incompatible with ParticleSettings ID type"); + BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with ParticleSettings ID type"); return; } break; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c88944b4584..69332dcd250 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -996,7 +996,7 @@ void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin IDProperty *item; item = IDP_GetPropertyTypeFromGroup(idp_ui, "min", IDP_DOUBLE); - *hardmin = item ? (float)IDP_Double(item) : FLT_MIN; + *hardmin = item ? (float)IDP_Double(item) : -FLT_MAX; item = IDP_GetPropertyTypeFromGroup(idp_ui, "max", IDP_DOUBLE); *hardmax = item ? (float)IDP_Double(item) : FLT_MAX; @@ -3169,7 +3169,7 @@ static int rna_raw_access(ReportList *reports, PointerRNA *ptr, PropertyRNA *pro itemtype = RNA_property_type(iprop); } else { - BKE_reportf(reports, RPT_ERROR, "Property named %s not found", propname); + BKE_reportf(reports, RPT_ERROR, "Property named '%s' not found", propname); err = 1; break; } @@ -3606,7 +3606,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int /* copy string, taking into account escaped ] */ if (bracket) { for (p = *path, i = 0, j = 0; i < len; i++, p++) { - if (*p == '\\' && *(p + 1) == quote) ; + if (*p == '\\' && *(p + 1) == quote) {} else buf[j++] = *p; } @@ -3647,7 +3647,8 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *index) { PropertyRNA *prop; - PointerRNA curptr, nextptr; + PointerRNA curptr; + PointerRNA nextptr; /* keep uninitialized, helps expose bugs in collection accessor functions */ char fixedbuf[256], *token; int type, intkey; @@ -3713,7 +3714,12 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, /* check for "" to see if it is a string */ if (rna_token_strip_quotes(token)) { - RNA_property_collection_lookup_string(&curptr, prop, token + 1, &nextptr); + if (RNA_property_collection_lookup_string(&curptr, prop, token + 1, &nextptr)) { + /* pass */ + } + else { + nextptr.data = NULL; + } } else { /* otherwise do int lookup */ @@ -3721,7 +3727,12 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, if (intkey == 0 && (token[0] != '0' || token[1] != '\0')) { return 0; /* we can be sure the fixedbuf was used in this case */ } - RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr); + if (RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr)) { + /* pass */ + } + else { + nextptr.data = NULL; + } } if (token != fixedbuf) { @@ -3730,13 +3741,14 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, } else { PointerRNA c_ptr; - - /* ensure we quit on invalid values */ - nextptr.data = NULL; if (RNA_property_collection_type_get(&curptr, prop, &c_ptr)) { nextptr = c_ptr; } + else { + /* ensure we quit on invalid values */ + nextptr.data = NULL; + } } if (nextptr.data) { @@ -3999,12 +4011,15 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee BLI_assert(haystack->type == IDP_GROUP); link.up = parent_link; + /* always set both name and index, + * else a stale value might get used */ link.name = NULL; link.index = -1; for (i = 0, iter = haystack->data.group.first; iter; iter = iter->next, i++) { if (needle == iter) { /* found! */ link.name = iter->name; + link.index = -1; path = rna_idp_path_create(&link); break; } @@ -4014,6 +4029,7 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee PointerRNA child_ptr = RNA_pointer_get(ptr, iter->name); if (child_ptr.type) { link.name = iter->name; + link.index = -1; if ((path = rna_idp_path(&child_ptr, iter, needle, &link))) { break; } @@ -4512,6 +4528,17 @@ int RNA_collection_length(PointerRNA *ptr, const char *name) } } +int RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, int use_ghost) +{ + if (prop->flag & PROP_IDPROPERTY) { + IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier); + return ((idprop != NULL) && (use_ghost == FALSE || !(idprop->flag & IDP_FLAG_GHOST))); + } + else { + return 1; + } +} + int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) { if (prop->flag & PROP_IDPROPERTY) { @@ -4523,6 +4550,20 @@ int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) } } +int RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, int use_ghost) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, identifier); + + if (prop) { + return RNA_property_is_set_ex(ptr, prop, use_ghost); + } + else { + /* python raises an error */ + /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ + return 0; + } +} + int RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier) { PropertyRNA *prop = RNA_struct_find_property(ptr, identifier); @@ -5219,7 +5260,7 @@ static int rna_function_format_array_length(const char *format, int ofs, int fle lenbuf[idx] = format[ofs]; if (ofs < flen && format[ofs + 1] == ']') { - /* XXX put better error reporting for ofs>=flen or idx over lenbuf capacity */ + /* XXX put better error reporting for (ofs >= flen) or idx over lenbuf capacity */ lenbuf[idx] = '\0'; return atoi(lenbuf); } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 00a257ab4f9..1f9503f1cc9 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -45,9 +46,13 @@ #ifdef RNA_RUNTIME -#include "ED_keyframing.h" +#include "BLI_math_base.h" + #include "BKE_fcurve.h" +#include "ED_keyframing.h" + + static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter) { ListBaseIterator *internal = iter->internal; @@ -68,29 +73,30 @@ static bActionGroup *rna_Action_groups_new(bAction *act, const char name[]) return action_groups_add_new(act, name); } -static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionGroup *agrp) +static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerRNA *agrp_ptr) { + bActionGroup *agrp = agrp_ptr->data; FCurve *fcu, *fcn; /* try to remove the F-Curve from the action */ - if (!BLI_remlink_safe(&act->groups, agrp)) { - BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name + 2); + if (BLI_remlink_safe(&act->groups, agrp) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "Action group '%s' not found in action '%s'", agrp->name, act->id.name + 2); return; } /* move every one one of the group's F-Curves out into the Action again */ for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcn) { fcn = fcu->next; - + /* remove from group */ action_groups_remove_channel(act, fcu); - + /* tack onto the end */ BLI_addtail(&act->curves, fcu); } - - /* XXX, invalidates PyObject */ + MEM_freeN(agrp); + RNA_POINTER_INVALIDATE(agrp_ptr); } static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path, @@ -112,17 +118,19 @@ static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const ch return verify_fcurve(act, group, NULL, data_path, index, 1); } -static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu) +static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerRNA *fcu_ptr) { + FCurve *fcu = fcu_ptr->data; if (fcu->grp) { if (BLI_findindex(&act->groups, fcu->grp) == -1) { - BKE_reportf(reports, RPT_ERROR, "F-Curve's ActionGroup '%s' not found in action '%s'", + BKE_reportf(reports, RPT_ERROR, "F-Curve's action group '%s' not found in action '%s'", fcu->grp->name, act->id.name + 2); return; } action_groups_remove_channel(act, fcu); free_fcurve(fcu); + RNA_POINTER_INVALIDATE(fcu_ptr); } else { if (BLI_findindex(&act->curves, fcu) == -1) { @@ -132,6 +140,7 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve * BLI_remlink(&act->curves, fcu); free_fcurve(fcu); + RNA_POINTER_INVALIDATE(fcu_ptr); } } @@ -145,15 +154,16 @@ static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[]) return marker; } -static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, TimeMarker *marker) +static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, PointerRNA *marker_ptr) { - if (!BLI_remlink_safe(&act->markers, marker)) { - BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in Action '%s'", marker->name, act->id.name + 2); + TimeMarker *marker = marker_ptr->data; + if (BLI_remlink_safe(&act->markers, marker) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in action '%s'", marker->name, act->id.name + 2); return; } - /* XXX, invalidates PyObject */ MEM_freeN(marker); + RNA_POINTER_INVALIDATE(marker_ptr); } static PointerRNA rna_Action_active_pose_marker_get(PointerRNA *ptr) @@ -185,8 +195,7 @@ static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min, bAction *act = (bAction *)ptr->data; *min = 0; - *max = BLI_countlist(&act->markers) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&act->markers) - 1); } @@ -256,15 +265,14 @@ static void rna_def_dopesheet(BlenderRNA *brna) srna = RNA_def_struct(brna, "DopeSheet", NULL); RNA_def_struct_sdna(srna, "bDopeSheet"); - RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in Animation Editors"); + RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in animation editors"); /* Source of DopeSheet data */ /* XXX: make this obsolete? */ prop = RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); RNA_def_property_ui_text(prop, "Source", - "ID-Block representing source data, currently ID_SCE (for Dopesheet), " - "and ID_SC (for Grease Pencil)"); + "ID-Block representing source data, usually ID_SCE (i.e. Scene)"); /* Show datablock filters */ prop = RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE); @@ -283,22 +291,29 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_INCL_HIDDEN); - RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible"); + RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that are not visible"); RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + /* Debug Filtering Settings */ + prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS); + RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and drivers that are disabled or have errors"); + RNA_def_property_ui_icon(prop, ICON_HELP, 0); /* XXX: this doesn't quite fit */ + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + /* Object Group Filtering Settings */ prop = RNA_def_property(srna, "show_only_group_objects", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP); RNA_def_property_ui_text(prop, "Only Objects in Group", - "Only include channels from Objects in the specified Group"); + "Only include channels from objects in the specified group"); RNA_def_property_ui_icon(prop, ICON_GROUP, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "filter_grp"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Filtering Group", "Group that included Object should be a member of"); + RNA_def_property_ui_text(prop, "Filtering Group", "Group that included object should be a member of"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* FCurve Display Name Search Settings */ @@ -318,21 +333,21 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT); RNA_def_property_ui_text(prop, "Include Missing NLA", - "Include Animation Data blocks with no NLA data (NLA Editor only)"); + "Include animation data blocks with no NLA data (NLA editor only)"); RNA_def_property_ui_icon(prop, ICON_ACTION, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Summary Settings (DopeSheet editors only) */ prop = RNA_def_property(srna, "show_summary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY); - RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet Editors only)"); + RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet editors only)"); RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_expanded_summary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED); RNA_def_property_ui_text(prop, "Collapse Summary", - "Collapse summary when shown, so all other channels get hidden (DopeSheet Editors Only)"); + "Collapse summary when shown, so all other channels get hidden (DopeSheet editors only)"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -340,97 +355,97 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_transforms", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOOBJ); RNA_def_property_ui_text(prop, "Display Transforms", - "Include visualization of Object-level Animation data (mostly Transforms)"); + "Include visualization of object-level animation data (mostly transforms)"); RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); /* XXX? */ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS); - RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of ShapeKey related Animation data"); + RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of shape key related animation data"); RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH); - RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of Mesh related Animation data"); + RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of mesh related animation data"); RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT); - RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of Lattice related Animation data"); + RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of lattice related animation data"); RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM); - RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data"); + RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of camera related animation data"); RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMAT); - RNA_def_property_ui_text(prop, "Display Material", "Include visualization of Material related Animation data"); + RNA_def_property_ui_text(prop, "Display Material", "Include visualization of material related animation data"); RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM); - RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of Lamp related Animation data"); + RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data"); RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOTEX); - RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of Texture related Animation data"); + RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of texture related animation data"); RNA_def_property_ui_icon(prop, ICON_TEXTURE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_curves", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCUR); - RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of Curve related Animation data"); + RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of curve related animation data"); RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_worlds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOWOR); - RNA_def_property_ui_text(prop, "Display World", "Include visualization of World related Animation data"); + RNA_def_property_ui_text(prop, "Display World", "Include visualization of world related animation data"); RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_scenes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSCE); - RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of Scene related Animation data"); + RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of scene related animation data"); RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOPART); - RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of Particle related Animation data"); + RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of particle related animation data"); RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA); - RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of Metaball related Animation data"); + RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of metaball related animation data"); RNA_def_property_ui_icon(prop, ICON_META_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM); - RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of Armature related Animation data"); + RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of armature related animation data"); RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NONTREE); - RNA_def_property_ui_text(prop, "Display Node", "Include visualization of Node related Animation data"); + RNA_def_property_ui_text(prop, "Display Node", "Include visualization of node related animation data"); RNA_def_property_ui_icon(prop, ICON_NODETREE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSPK); - RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of Speaker related Animation data"); + RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of speaker related animation data"); RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } @@ -467,17 +482,17 @@ static void rna_def_action_group(BlenderRNA *brna) prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED); - RNA_def_property_ui_text(prop, "Select", "Action Group is selected"); + RNA_def_property_ui_text(prop, "Select", "Action group is selected"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED); - RNA_def_property_ui_text(prop, "Lock", "Action Group is locked"); + RNA_def_property_ui_text(prop, "Lock", "Action group is locked"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED); - RNA_def_property_ui_text(prop, "Expanded", "Action Group is expanded"); + RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* color set */ @@ -510,7 +525,8 @@ static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove action group"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "action_group", "ActionGroup", "", "Action group to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop) @@ -541,7 +557,8 @@ static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove action group"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop) @@ -569,14 +586,15 @@ static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a timeline marker"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "TimelineMarker"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, "rna_Action_active_pose_marker_get", "rna_Action_active_pose_marker_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this Action"); + RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this action"); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "active_marker"); @@ -599,7 +617,7 @@ static void rna_def_action(BlenderRNA *brna) prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "curves", NULL); RNA_def_property_struct_type(prop, "FCurve"); - RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action"); + RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the action"); rna_def_action_fcurves(brna, prop); prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); @@ -611,7 +629,7 @@ static void rna_def_action(BlenderRNA *brna) prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "markers", NULL); RNA_def_property_struct_type(prop, "TimelineMarker"); - RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses"); + RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this action, for labeling poses"); rna_def_action_pose_markers(brna, prop); /* properties */ @@ -626,8 +644,8 @@ static void rna_def_action(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "idroot"); RNA_def_property_enum_items(prop, id_type_items); RNA_def_property_ui_text(prop, "ID Root Type", - "Type of ID-block that action can be used on - " - "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING"); + "Type of ID block that action can be used on - " + "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING"); /* API calls */ RNA_api_action(srna); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index d50cb663b97..7229dddf6d6 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -54,6 +54,8 @@ EnumPropertyItem keyingset_path_grouping_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math_base.h" + #include "BKE_animsys.h" #include "BKE_fcurve.h" #include "BKE_nla.h" @@ -296,6 +298,43 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value) /* ****************************** */ +static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value) +{ + KeyingSet *ks = (KeyingSet *)ptr->data; + + /* update names of corresponding groups if name changes */ + if (strcmp(ks->name, value)) { + KS_Path *ksp; + + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) { + AnimData *adt = BKE_animdata_from_id(ksp->id); + + /* TODO: NLA strips? */ + if (adt && adt->action) { + bActionGroup *agrp; + + /* lazy check - should really find the F-Curve for the affected path and check its group + * but this way should be faster and work well for most cases, as long as there are no + * conflicts + */ + for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) { + if (strcmp(ks->name, agrp->name) == 0) { + /* there should only be one of these in the action, so can stop... */ + BLI_strncpy(agrp->name, value, sizeof(agrp->name)); + break; + } + } + } + } + } + } + + /* finally, update name to new value */ + BLI_strncpy(ks->name, value, sizeof(ks->name)); +} + + static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr) { KeyingSet *ks = (KeyingSet *)ptr->data; @@ -334,8 +373,7 @@ static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, i KeyingSet *ks = (KeyingSet *)ptr->data; *min = 0; - *max = BLI_countlist(&ks->paths) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&ks->paths) - 1); } static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr) @@ -369,27 +407,30 @@ static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *report keyingset->active_path = BLI_countlist(&keyingset->paths); } else { - BKE_report(reports, RPT_ERROR, "Keying Set Path could not be added"); + BKE_report(reports, RPT_ERROR, "Keying set path could not be added"); } /* return added path */ return ksp; } -static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports, KS_Path *ksp) +static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports, PointerRNA *ksp_ptr) { + KS_Path *ksp = ksp_ptr->data; + /* if data is valid, call the API function for this */ - if (keyingset && ksp) { - /* remove the active path from the KeyingSet */ - BKE_keyingset_free_path(keyingset, ksp); - - /* the active path number will most likely have changed */ - /* TODO: we should get more fancy and actually check if it was removed, but this will do for now */ - keyingset->active_path = 0; - } - else { - BKE_report(reports, RPT_ERROR, "Keying Set Path could not be removed"); + if ((keyingset && ksp) == FALSE) { + BKE_report(reports, RPT_ERROR, "Keying set path could not be removed"); + return; } + + /* remove the active path from the KeyingSet */ + BKE_keyingset_free_path(keyingset, ksp); + RNA_POINTER_INVALIDATE(ksp_ptr); + + /* the active path number will most likely have changed */ + /* TODO: we should get more fancy and actually check if it was removed, but this will do for now */ + keyingset->active_path = 0; } static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports) @@ -408,7 +449,7 @@ static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports) keyingset->active_path = 0; } else { - BKE_report(reports, RPT_ERROR, "Keying Set Paths could not be removed"); + BKE_report(reports, RPT_ERROR, "Keying set paths could not be removed"); } } @@ -422,9 +463,17 @@ static NlaTrack *rna_NlaTrack_new(AnimData *adt, bContext *C, NlaTrack *track) return new_track; } -static void rna_NlaTrack_remove(AnimData *adt, bContext *C, NlaTrack *track) +static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports, PointerRNA *track_ptr) { + NlaTrack *track = track_ptr->data; + + if (BLI_findindex(&adt->nla_tracks, track) == -1) { + BKE_reportf(reports, RPT_ERROR, "NlaTrack '%s' cannot be removed", track->name); + return; + } + free_nlatrack(&adt->nla_tracks, track); + RNA_POINTER_INVALIDATE(track_ptr); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); } @@ -448,7 +497,7 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_ { /* verify that we've got a driver to duplicate */ if (ELEM(NULL, src_driver, src_driver->driver)) { - BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of"); + BKE_report(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of"); return NULL; } else { @@ -678,7 +727,8 @@ static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); /* path to remove */ parm = RNA_def_pointer(func, "path", "KeyingSetPath", "Path", ""); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* Remove All Paths */ @@ -709,19 +759,20 @@ static void rna_def_keyingset(BlenderRNA *brna) srna = RNA_def_struct(brna, "KeyingSet", NULL); RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together"); - /* Id/Label. */ + /* Id/Label */ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "idname"); RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP); RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC); - RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); +/* RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */ prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_KeyingSet_name_set"); RNA_def_property_ui_text(prop, "UI Name", ""); RNA_def_struct_ui_icon(srna, ICON_KEYINGSET); RNA_def_struct_name_property(srna, prop); -/* RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/ + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE); RNA_def_property_string_sdna(prop, NULL, "description"); @@ -783,10 +834,11 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_NlaTrack_remove"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Remove a NLA Track"); parm = RNA_def_pointer(func, "track", "NlaTrack", "", "NLA Track to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "NlaTrack"); diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index 39128b48cd8..492659fdc2e 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -56,11 +56,11 @@ static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList if (success != 0) { switch (success) { case MODIFYKEY_INVALID_CONTEXT: - BKE_report(reports, RPT_ERROR, "Invalid context for Keying Set"); + BKE_report(reports, RPT_ERROR, "Invalid context for keying set"); break; case MODIFYKEY_MISSING_TYPEINFO: - BKE_report(reports, RPT_ERROR, "Incomplete built-in Keying Set. Appears to be missing type info"); + BKE_report(reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info"); break; } } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index ceadaa036f1..4c566d71981 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -29,6 +29,7 @@ #include "BLI_math.h" +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" @@ -103,25 +104,27 @@ static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value) static EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, const char *name) { if (arm->edbo == NULL) { - BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant add an editbone", arm->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot add an editbone", arm->id.name + 2); return NULL; } return ED_armature_edit_bone_add(arm, name); } -static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, EditBone *ebone) +static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, PointerRNA *ebone_ptr) { + EditBone *ebone = ebone_ptr->data; if (arm->edbo == NULL) { - BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in editmode, cant remove an editbone", arm->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot remove an editbone", arm->id.name + 2); return; } if (BLI_findindex(arm->edbo, ebone) == -1) { - BKE_reportf(reports, RPT_ERROR, "Armature '%s' doesn't contain bone '%s'", arm->id.name + 2, ebone->name); + BKE_reportf(reports, RPT_ERROR, "Armature '%s' does not contain bone '%s'", arm->id.name + 2, ebone->name); return; } ED_armature_edit_bone_remove(arm, ebone); + RNA_POINTER_INVALIDATE(ebone_ptr); } static void rna_Armature_update_layers(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -564,7 +567,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); else RNA_def_property_update(prop, 0, "rna_Armature_update_data"); RNA_def_property_float_sdna(prop, NULL, "rad_head"); - /* XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); */ + /* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */ /*RNA_def_property_range(prop, 0, 1000); */ RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)"); @@ -573,7 +576,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); else RNA_def_property_update(prop, 0, "rna_Armature_update_data"); RNA_def_property_float_sdna(prop, NULL, "rad_tail"); - /* XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); */ + /* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */ /*RNA_def_property_range(prop, 0, 1000); */ RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only)"); @@ -865,7 +868,8 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove an existing bone from the armature"); /* target to remove*/ parm = RNA_def_pointer(func, "bone", "EditBone", "", "EditBone to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_armature(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 2a6ea2994fa..3da718afd1c 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -80,6 +80,8 @@ EnumPropertyItem boidruleset_type_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math_base.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_particle.h" @@ -157,8 +159,7 @@ static void rna_BoidState_active_boid_rule_index_range(PointerRNA *ptr, int *min { BoidState *state = (BoidState *)ptr->data; *min = 0; - *max = BLI_countlist(&state->rules) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&state->rules) - 1); } static int rna_BoidState_active_boid_rule_index_get(PointerRNA *ptr) @@ -224,8 +225,7 @@ static void rna_BoidSettings_active_boid_state_index_range(PointerRNA *ptr, int { BoidSettings *boids = (BoidSettings *)ptr->data; *min = 0; - *max = BLI_countlist(&boids->states) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&boids->states) - 1); } static int rna_BoidSettings_active_boid_state_index_get(PointerRNA *ptr) @@ -436,7 +436,7 @@ static void rna_def_boidrule(BlenderRNA *brna) RNA_def_property_ui_text(prop, "On Land", "Use rule when boid is on land"); RNA_def_property_update(prop, 0, "rna_Boids_reset"); - /*prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */ + /*prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */ /*RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded); */ /*RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index e96ed4f38d3..7bdebd620ee 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -146,8 +146,8 @@ static int rna_SculptCapabilities_has_overlay_get(PointerRNA *ptr) { Brush *br = (Brush *)ptr->data; return ELEM(br->mtex.brush_map_mode, - MTEX_MAP_MODE_VIEW, - MTEX_MAP_MODE_TILED); + MTEX_MAP_MODE_VIEW, + MTEX_MAP_MODE_TILED); } static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index ad926d6a08e..b72bba0422a 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -258,7 +258,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "show_title_safe", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWTITLESAFE); - RNA_def_property_ui_text(prop, "Show Title Safe", "Show indicators for the title safe zone in Camera view"); + RNA_def_property_ui_text(prop, "Show Safe Areas", "Show TV title safe and action safe zones in Camera view"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 5f1ce4f2773..b9e86e116a2 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -419,41 +419,41 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) /* unused still */ #if 0 - prop= RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shear"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness"); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_shear"); RNA_def_property_range(prop, 0.0f, upperLimitf); RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value"); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "eff_force_scale"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Effector Force Scale", ""); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "eff_wind_scale"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Effector Wind Scale", ""); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_TEARING); RNA_def_property_ui_text(prop, "Tearing", ""); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "maxspringlen"); RNA_def_property_range(prop, 1.0, 1000.0); RNA_def_property_ui_text(prop, "Maximum Spring Extension", "Maximum extension before spring gets cut"); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 7fb4a1d3839..5752fd318c7 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -45,6 +45,7 @@ #include "DNA_material_types.h" #include "DNA_movieclip_types.h" #include "DNA_node_types.h" +#include "DNA_sequence_types.h" #include "MEM_guardedalloc.h" @@ -53,6 +54,7 @@ #include "BKE_image.h" #include "BKE_movieclip.h" #include "BKE_node.h" +#include "BKE_sequencer.h" #include "BKE_texture.h" #include "ED_node.h" @@ -314,7 +316,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * } } -void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]) +static void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]) { do_colorband(coba, position, color); } @@ -329,12 +331,27 @@ static CBData *rna_ColorRampElement_new(struct ColorBand *coba, ReportList *repo return element; } -static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, CBData *element) +static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, PointerRNA *element_ptr) { + CBData *element = element_ptr->data; int index = (int)(element - coba->data); - if (colorband_element_remove(coba, index) == 0) + if (colorband_element_remove(coba, index) == FALSE) { BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element"); + return; + } + + RNA_POINTER_INVALIDATE(element_ptr); +} + +void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr) +{ + CurveMapPoint *point = point_ptr->data; + if (curvemap_remove_point(cuma, point) == FALSE) { + BKE_report(reports, RPT_ERROR, "Unable to remove curve point"); + return; + } + RNA_POINTER_INVALIDATE(point_ptr); } static void rna_Scopes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -474,14 +491,55 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain) if (GS(id->name) == ID_IM) { Image *ima = (Image *) id; - BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + DAG_id_tag_update(&ima->id, 0); + + BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE); + WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); + WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); } else if (GS(id->name) == ID_MC) { MovieClip *clip = (MovieClip *) id; BKE_movieclip_reload(clip); + + /* all sequencers for now, we don't know which scenes are using this clip as a strip */ + BKE_sequencer_cache_cleanup(); + BKE_sequencer_preprocessed_cache_cleanup(); + WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id); + WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, &clip->id); + } + else if (GS(id->name) == ID_SCE) { + Scene *scene = (Scene *) id; + + if (scene->ed) { + ColorManagedColorspaceSettings *colorspace_settings = (ColorManagedColorspaceSettings *) ptr->data; + Sequence *seq; + int seq_found = FALSE; + + if (&scene->sequencer_colorspace_settings != colorspace_settings) { + SEQ_BEGIN(scene->ed, seq); + { + if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) { + seq_found = TRUE; + break; + } + } + SEQ_END; + } + + if (seq_found) { + BKE_sequence_invalidate_cache(scene, seq); + BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); + } + else { + BKE_sequencer_cache_cleanup(); + BKE_sequencer_preprocessed_cache_cleanup(); + } + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); + } } } @@ -553,10 +611,12 @@ static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "New point"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "remove", "curvemap_remove_point"); + func = RNA_def_function(srna, "remove", "rna_CurveMap_remove_point"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Delete point from CurveMap"); parm = RNA_def_pointer(func, "point", "CurveMapPoint", "", "PointElement to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_curvemap(BlenderRNA *brna) @@ -705,7 +765,8 @@ static void rna_def_color_ramp_element_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete element from ColorRamp"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "element", "ColorRampElement", "", "Element to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_color_ramp(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index f2454a2dcfb..7b6b629ca82 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -703,11 +703,6 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock Z Rot", "Constraint rotation along Z axis"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update"); - prop = RNA_def_property(srna, "use_target", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_AUTO); - RNA_def_property_ui_text(prop, "Target", "Disable for targetless IK"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_STRETCH); RNA_def_property_ui_text(prop, "Stretch", "Enable IK Stretching"); @@ -2422,7 +2417,7 @@ void RNA_def_constraint(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "rot_error"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Rot error", - "Amount of residual error in radiant for constraints that work on orientation"); + "Amount of residual error in radians for constraints that work on orientation"); /* pointers */ rna_def_constrainttarget(brna); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index aef1f765fe2..c59e376da82 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -240,7 +240,7 @@ void RNA_def_controller(BlenderRNA *brna) /* State */ /* array of OB_MAX_STATES */ - /*prop= RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */ + /*prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */ /*RNA_def_property_array(prop, OB_MAX_STATES); */ /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ /*RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)"); */ diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index c47cb8ef2af..1e1a8c82b8e 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -26,6 +26,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" @@ -62,9 +63,9 @@ EnumPropertyItem keyframe_handle_type_items[] = { }; EnumPropertyItem beztriple_interpolation_mode_items[] = { - {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""}, - {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""}, - {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, + {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation, value of A gets held until B is encountered"}, + {BEZT_IPO_LIN, "LINEAR", 0, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"}, + {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"}, {0, NULL, 0, NULL, NULL} }; @@ -241,16 +242,14 @@ static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max, { Curve *cu = (Curve *)ptr->id.data; *min = 0; - *max = cu->totcol - 1; - *max = MAX2(0, *max); + *max = max_ii(0, cu->totcol - 1); } static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) { Curve *cu = (Curve *)ptr->id.data; *min = 0; - *max = cu->totbox - 1; - *max = MAX2(0, *max); + *max = max_ii(0, cu->totbox - 1); } @@ -511,7 +510,7 @@ static void rna_Nurb_update_knot_v(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number) { if (nu->type == CU_BEZIER) { - BKE_report(reports, RPT_ERROR, "Bezier spline can't have points added"); + BKE_report(reports, RPT_ERROR, "Bezier spline cannot have points added"); } else if (number == 0) { /* do nothing */ @@ -573,20 +572,18 @@ static Nurb *rna_Curve_spline_new(Curve *cu, int type) return nu; } -static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu) +static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, PointerRNA *nu_ptr) { - int found = 0; + Nurb *nu = nu_ptr->data; ListBase *nurbs = BKE_curve_nurbs_get(cu); - found = BLI_remlink_safe(nurbs, nu); - - if (!found) { - BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" does not contain spline given", cu->id.name + 2); + if (BLI_remlink_safe(nurbs, nu) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "Curve '%s' does not contain spline given", cu->id.name + 2); return; } BKE_nurb_free(nu); - /* invalidate pointer!, no can do */ + RNA_POINTER_INVALIDATE(nu_ptr); DAG_id_tag_update(&cu->id, OB_RECALC_DATA); WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); @@ -721,7 +718,7 @@ static void rna_def_bpoint(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Number values */ - prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View"); @@ -808,13 +805,14 @@ static void rna_def_beztriple(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_update_points"); /* Number values */ - prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "weight"); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); @@ -1108,7 +1106,7 @@ static void rna_def_charinfo(BlenderRNA *brna) /* probably there is no reason to expose this */ #if 0 - prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP); RNA_def_property_ui_text(prop, "Wrap", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */ @@ -1163,14 +1161,15 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_Curve_spline_points_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); - RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); #if 0 - func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); + func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); RNA_def_function_ui_description(func, "Remove a spline from a curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); #endif } @@ -1190,14 +1189,15 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); - RNA_def_int(func, "count", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); #if 0 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); RNA_def_function_ui_description(func, "Remove a spline from a curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); #endif } @@ -1226,7 +1226,8 @@ static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_Curve_spline_clear"); RNA_def_function_ui_description(func, "Remove all spline from a curve"); @@ -1421,6 +1422,11 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for beveled curves"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + prop = RNA_def_property(srna, "use_map_taper", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_MAP_TAPER); + RNA_def_property_ui_text(prop, "Map Taper", "Map effect of taper object on actually bevelled curve"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + /* texture space */ prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 45092d09ce1..bb1ecea6a24 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -42,10 +42,23 @@ #include "BLI_listbase.h" #include "BLI_ghash.h" +#include "BLF_translation.h" + #include "RNA_define.h" #include "rna_internal.h" + +#ifdef DEBUG +# define ASSERT_SOFT_HARD_LIMITS \ + if (softmin < hardmin || softmax > hardmax) { \ + fprintf(stderr, "Error with soft/hard limits: %s.%s\n", CONTAINER_RNA_ID(cont), identifier); \ + BLI_assert(!"invalid soft/hard limits"); \ + } (void)0 +#else +# define ASSERT_SOFT_HARD_LIMITS (void)0 +#endif + /* Global used during defining */ BlenderDefRNA DefRNA = {NULL, {NULL, NULL}, {NULL, NULL}, NULL, 0, 0, 0, 1}; @@ -887,7 +900,7 @@ void RNA_def_struct_translation_context(StructRNA *srna, const char *context) PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype) { - /*StructRNA *srna= DefRNA.laststruct;*/ /* invalid for python defined props */ + /*StructRNA *srna = DefRNA.laststruct;*/ /* invalid for python defined props */ ContainerRNA *cont = cont_; ContainerDefRNA *dcont; PropertyDefRNA *dprop = NULL; @@ -968,8 +981,10 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier sprop->defaultvalue = ""; break; } - case PROP_ENUM: case PROP_POINTER: + prop->flag |= PROP_THICK_WRAP; /* needed for default behavior when PROP_RNAPTR is set */ + break; + case PROP_ENUM: case PROP_COLLECTION: break; default: @@ -2248,12 +2263,15 @@ PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_, const char *iden return prop; } -PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, - int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax) +PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, + int hardmin, int hardmax, const char *ui_name, const char *ui_description, + int softmin, int softmax) { ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE); RNA_def_property_int_default(prop, default_value); if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2270,6 +2288,8 @@ PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifi ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); /* XXX */ if (len != 0) RNA_def_property_array(prop, len); if (default_value) RNA_def_property_int_array_default(prop, default_value); @@ -2287,6 +2307,8 @@ PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifie ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE); if (len != 0) RNA_def_property_array(prop, len); if (default_value) RNA_def_property_int_array_default(prop, default_value); @@ -2426,6 +2448,8 @@ PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, f ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE); RNA_def_property_float_default(prop, default_value); if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2442,6 +2466,8 @@ PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identi ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ); if (len != 0) RNA_def_property_array(prop, len); if (default_value) RNA_def_property_float_array_default(prop, default_value); @@ -2472,6 +2498,8 @@ PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identif ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR); if (len != 0) RNA_def_property_array(prop, len); if (default_value) RNA_def_property_float_array_default(prop, default_value); @@ -2489,10 +2517,9 @@ PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_, const char *identi { ContainerRNA *cont = cont_; PropertyRNA *prop; - int length[2]; + const int length[2] = {rows, columns}; - length[0] = rows; - length[1] = columns; + ASSERT_SOFT_HARD_LIMITS; prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, length); @@ -2510,7 +2537,9 @@ PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_, const char *iden { ContainerRNA *cont = cont_; PropertyRNA *prop; - + + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, (len != 0) ? PROP_EULER : PROP_ANGLE); if (len != 0) { RNA_def_property_array(prop, len); @@ -2534,6 +2563,8 @@ PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identif ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE); if (len != 0) RNA_def_property_array(prop, len); if (default_value) RNA_def_property_float_array_default(prop, default_value); @@ -2551,6 +2582,8 @@ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_, const char *id ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_default(prop, default_value); if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2567,6 +2600,8 @@ PropertyRNA *RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identi ContainerRNA *cont = cont_; PropertyRNA *prop; + ASSERT_SOFT_HARD_LIMITS; + prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_default(prop, default_value); if (hardmin != hardmax) RNA_def_property_range(prop, hardmin, hardmax); @@ -2777,14 +2812,26 @@ int rna_parameter_size(PropertyRNA *parm) { #ifdef RNA_RUNTIME if (parm->flag & PROP_RNAPTR) - return sizeof(PointerRNA); + if (parm->flag & PROP_THICK_WRAP) { + return sizeof(PointerRNA); + } + else { + return sizeof(PointerRNA *); + } else return sizeof(void *); #else - if (parm->flag & PROP_RNAPTR) - return sizeof(PointerRNA); - else + if (parm->flag & PROP_RNAPTR) { + if (parm->flag & PROP_THICK_WRAP) { + return sizeof(PointerRNA); + } + else { + return sizeof(PointerRNA *); + } + } + else { return sizeof(void *); + } #endif } case PROP_COLLECTION: diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 24b14fdb884..4250acf5848 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -409,14 +409,16 @@ static DriverVar *rna_Driver_new_variable(ChannelDriver *driver) return driver_add_new_variable(driver); } -static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar) +static void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, PointerRNA *dvar_ptr) { + DriverVar *dvar = dvar_ptr->data; if (BLI_findindex(&driver->variables, dvar) == -1) { BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver"); return; } driver_free_variable(driver, dvar); + RNA_POINTER_INVALIDATE(dvar_ptr); } @@ -438,13 +440,16 @@ static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type) return add_fmodifier(&fcu->modifiers, type); } -static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm) +static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, PointerRNA *fcm_ptr) { + FModifier *fcm = fcm_ptr->data; if (BLI_findindex(&fcu->modifiers, fcm) == -1) { BKE_reportf(reports, RPT_ERROR, "F-Curve modifier '%s' not found in F-Curve", fcm->name); return; } + remove_fmodifier(&fcu->modifiers, fcm); + RNA_POINTER_INVALIDATE(fcm_ptr); } static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value)) @@ -610,8 +615,9 @@ static void rna_FKeyframe_points_add(FCurve *fcu, int tot) } } -static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast) +static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, PointerRNA *bezt_ptr, int do_fast) { + BezTriple *bezt = bezt_ptr->data; int index = (int)(bezt - fcu->bezt); if (index < 0 || index >= fcu->totvert) { BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve"); @@ -619,6 +625,7 @@ static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTri } delete_fcurve_key(fcu, index, !do_fast); + RNA_POINTER_INVALIDATE(bezt_ptr); } static void rna_fcurve_range(FCurve *fcu, float range[2]) @@ -1263,7 +1270,8 @@ static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop RNA_def_function_flag(func, FUNC_USE_REPORTS); /* target to remove */ parm = RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_channeldriver(BlenderRNA *brna) @@ -1458,7 +1466,8 @@ static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a modifier from this F-Curve"); /* modifier to remove */ parm = RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } /* fcurve.keyframe_points */ @@ -1497,13 +1506,14 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve"); - RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove"); RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* optional */ RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time"); } diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index daa661175a1..84ff53ee68f 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -699,7 +699,7 @@ void RNA_def_fluidsim(BlenderRNA *brna) 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); */ + /*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"); */ /* types */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index bf7f4984ea1..b3c1f4dd505 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" @@ -111,6 +112,116 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); } +static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count) +{ + if (count > 0) { + if (stroke->points == NULL) + stroke->points = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points"); + else + stroke->points = MEM_reallocN(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count)); + + stroke->totpoints += count; + } +} + +static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, int index) +{ + bGPDspoint *pt_tmp = stroke->points; + + /* python style negative indexing */ + if (index < 0) { + index += stroke->totpoints; + } + + if (stroke->totpoints <= index || index < 0) { + BKE_report(reports, RPT_ERROR, "GPencilStrokePoints.pop: index out of range"); + return; + } + + stroke->totpoints--; + + stroke->points = MEM_callocN(sizeof(bGPDspoint) * stroke->totpoints, "gp_stroke_points"); + + if (index > 0) + memcpy(stroke->points, pt_tmp, sizeof(bGPDspoint) * index); + + if (index < stroke->totpoints) + memcpy(&stroke->points[index], &pt_tmp[index + 1], sizeof(bGPDspoint) * (stroke->totpoints - index)); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + +static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame) +{ + bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); + + BLI_addtail(&frame->strokes, stroke); + + return stroke; +} + +static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, PointerRNA *stroke_ptr) +{ + bGPDstroke *stroke = stroke_ptr->data; + if (BLI_findindex(&frame->strokes, stroke) == -1) { + BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame"); + return; + } + + BLI_freelinkN(&frame->strokes, stroke); + RNA_POINTER_INVALIDATE(stroke_ptr); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + +static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, int frame_number) +{ + bGPDframe *frame; + + if (BKE_gpencil_layer_find_frame(layer, frame_number)) { + BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number %d", frame_number); + return NULL; + } + + frame = gpencil_frame_addnew(layer, frame_number); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + + return frame; +} + +static void rna_GPencil_frame_remove(bGPDlayer *layer, ReportList *reports, PointerRNA *frame_ptr) +{ + bGPDframe *frame = frame_ptr->data; + if (BLI_findindex(&layer->frames, frame) == -1) { + BKE_report(reports, RPT_ERROR, "Frame not found in grease pencil layer"); + return; + } + + gpencil_layer_delframe(layer, frame); + RNA_POINTER_INVALIDATE(frame_ptr); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + +static bGPDframe *rna_GPencil_frame_copy(bGPDlayer *layer, bGPDframe *src) +{ + bGPDframe *frame = gpencil_frame_duplicate(src); + + while (BKE_gpencil_layer_find_frame(layer, frame->framenum)) { + frame->framenum++; + } + + BLI_addtail(&layer->frames, frame); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + + return frame; +} + static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int setactive) { bGPDlayer *gl = gpencil_layer_addnew(gpd, name, setactive); @@ -120,21 +231,37 @@ static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int seta return gl; } -static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlayer *layer) +static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, PointerRNA *layer_ptr) { - bGPDlayer *gl; - - for (gl = gpd->layers.first; gl; gl = gl->next) { - if (gl == layer) - break; - } - - if (gl == NULL) { - BKE_reportf(reports, RPT_ERROR, "Layer not found in grease pencil data"); + bGPDlayer *layer = layer_ptr->data; + if (BLI_findindex(&gpd->layers, layer) == -1) { + BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data"); return; } - + gpencil_layer_delete(gpd, layer); + RNA_POINTER_INVALIDATE(layer_ptr); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + +static void rna_GPencil_frame_clear(bGPDframe *frame) +{ + free_gpencil_strokes(frame); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + +static void rna_GPencil_layer_clear(bGPDlayer *layer) +{ + free_gpencil_frames(layer); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + +static void rna_GPencil_clear(bGPdata *gpd) +{ + free_gpencil_layers(&gpd->layers); WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } @@ -154,19 +281,49 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Coordinates", ""); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pressure"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); +} + +static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + /* PropertyRNA *parm; */ + + RNA_def_property_srna(cprop, "GPencilStrokePoints"); + srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL); + RNA_def_struct_sdna(srna, "bGPDstroke"); + RNA_def_struct_ui_text(srna, "Grease Pencil Stroke Points", "Collection of grease pencil stroke points"); + + func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add"); + RNA_def_function_ui_description(func, "Add a new grease pencil stroke point"); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX); + + func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop"); + RNA_def_function_ui_description(func, "Remove a grease pencil stroke point"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "Index", "point index", INT_MIN, INT_MAX); } static void rna_def_gpencil_stroke(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + static EnumPropertyItem stroke_draw_mode_items[] = { + {0, "SCREEN", 0, "Screen", "Stroke is in screen-space"}, + {GP_STROKE_3DSPACE, "3DSPACE", 0, "3D Space", "Stroke is in 3D-space"}, + {GP_STROKE_2DSPACE, "2DSPACE", 0, "2D Space", "Stroke is in 2D-space"}, + {GP_STROKE_2DIMAGE, "2DIMAGE", 0, "2D Image", "Stroke is in 2D-space (but with special 'image' scaling)"}, + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "GPencilStroke", NULL); RNA_def_struct_sdna(srna, "bGPDstroke"); @@ -177,15 +334,46 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "points", "totpoints"); RNA_def_property_struct_type(prop, "GPencilStrokePoint"); RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points"); - - /* Flags - Readonly type-info really... */ - /* TODO... */ + rna_def_gpencil_stroke_points_api(brna, prop); + + prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, stroke_draw_mode_items); + RNA_def_property_ui_text(prop, "Draw Mode", ""); + RNA_def_property_update(prop, 0, "rna_GPencil_update"); +} + +static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "GPencilStrokes"); + srna = RNA_def_struct(brna, "GPencilStrokes", NULL); + RNA_def_struct_sdna(srna, "bGPDframe"); + RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames"); + + func = RNA_def_function(srna, "new", "rna_GPencil_stroke_new"); + RNA_def_function_ui_description(func, "Add a new grease pencil frame"); + parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "", "The newly created stroke"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_GPencil_stroke_remove"); + RNA_def_function_ui_description(func, "Remove a grease pencil frame"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_gpencil_frame(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + FunctionRNA *func; srna = RNA_def_struct(brna, "GPencilFrame", NULL); RNA_def_struct_sdna(srna, "bGPDframe"); @@ -196,7 +384,8 @@ static void rna_def_gpencil_frame(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "strokes", NULL); RNA_def_property_struct_type(prop, "GPencilStroke"); RNA_def_property_ui_text(prop, "Strokes", "Freehand curves defining the sketch on this frame"); - + rna_def_gpencil_strokes_api(brna, prop); + /* Frame Number */ prop = RNA_def_property(srna, "frame_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "framenum"); @@ -211,12 +400,52 @@ static void rna_def_gpencil_frame(BlenderRNA *brna) prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_SELECT); RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in the DopeSheet"); + + func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear"); + RNA_def_function_ui_description(func, "Remove all the grease pencil frame data"); +} + +static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "GPencilFrames"); + srna = RNA_def_struct(brna, "GPencilFrames", NULL); + RNA_def_struct_sdna(srna, "bGPDlayer"); + RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames"); + + func = RNA_def_function(srna, "new", "rna_GPencil_frame_new"); + RNA_def_function_ui_description(func, "Add a new grease pencil frame"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_int(func, "frame_number", 1, MINFRAME, MAXFRAME, "Frame Number", "The frame on which this sketch appears", MINFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "frame", "GPencilFrame", "", "The newly created frame"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_GPencil_frame_remove"); + RNA_def_function_ui_description(func, "Remove a grease pencil frame"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "frame", "GPencilFrame", "Frame", "The frame to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + + func = RNA_def_function(srna, "copy", "rna_GPencil_frame_copy"); + RNA_def_function_ui_description(func, "Copy a grease pencil frame"); + parm = RNA_def_pointer(func, "source", "GPencilFrame", "Source", "The source frame"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "copy", "GPencilFrame", "", "The newly copied frame"); + RNA_def_function_return(func, parm); } static void rna_def_gpencil_layer(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + FunctionRNA *func; srna = RNA_def_struct(brna, "GPencilLayer", NULL); RNA_def_struct_sdna(srna, "bGPDlayer"); @@ -234,7 +463,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "frames", NULL); RNA_def_property_struct_type(prop, "GPencilFrame"); RNA_def_property_ui_text(prop, "Frames", "Sketches for this layer on different frames"); - + rna_def_gpencil_frames_api(brna, prop); + /* Active Frame */ prop = RNA_def_property(srna, "active_frame", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "actframe"); @@ -317,9 +547,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY); RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear"); + RNA_def_function_ui_description(func, "Remove all the grease pencil layer data"); } -static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; PropertyRNA *prop; @@ -334,7 +567,7 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_GPencil_layer_new"); RNA_def_function_ui_description(func, "Add a new grease pencil layer"); - parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer"); + parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer"); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_boolean(func, "set_active", 0, "Set Active", "Set the newly created layer to the active layer"); parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The newly created layer"); @@ -344,7 +577,8 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a grease pencil layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "GreasePencil"); @@ -357,7 +591,8 @@ static void rna_def_gpencil_data(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - + FunctionRNA *func; + static EnumPropertyItem draw_mode_items[] = { {GP_DATA_VIEWALIGN, "CURSOR", 0, "Cursor", "Draw stroke at the 3D cursor"}, {0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weird, GP_DATA_VIEWALIGN is inverted */ @@ -376,7 +611,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "layers", NULL); RNA_def_property_struct_type(prop, "GPencilLayer"); RNA_def_property_ui_text(prop, "Layers", ""); - rna_def_gpencil_layers(brna, prop); + rna_def_gpencil_layers_api(brna, prop); /* Flags */ prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); @@ -390,6 +625,8 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + func = RNA_def_function(srna, "clear", "rna_GPencil_clear"); + RNA_def_function_ui_description(func, "Remove all the grease pencil data"); } /* --- */ diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 586b71aa2da..4baf46fd0b5 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -54,7 +54,7 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter) static void rna_Group_objects_link(Group *group, bContext *C, ReportList *reports, Object *object) { if (!add_to_group(group, object, CTX_data_scene(C), NULL)) { - BKE_reportf(reports, RPT_ERROR, "Object \"%s\" already in group \"%s\"", object->id.name + 2, group->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' already in group '%s'", object->id.name + 2, group->id.name + 2); return; } @@ -64,7 +64,7 @@ static void rna_Group_objects_link(Group *group, bContext *C, ReportList *report static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object) { if (!rem_from_group(group, object, CTX_data_scene(C), NULL)) { - BKE_reportf(reports, RPT_ERROR, "Object \"%s\" not in group \"%s\"", object->id.name + 2, group->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in group '%s'", object->id.name + 2, group->id.name + 2); return; } diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index a77e93f6a56..f8af2427827 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -150,7 +150,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA * static char *rna_ImageUser_path(PointerRNA *ptr) { if (ptr->id.data) { - /* ImageUser *iuser= ptr->data; */ + /* ImageUser *iuser = ptr->data; */ switch (GS(((ID *)ptr->id.data)->name)) { case ID_TE: @@ -366,7 +366,7 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values) ((unsigned char *)ibuf->rect)[i] = FTOCHAR(values[i]); } - ibuf->userflags |= IB_BITMAPDIRTY; + ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID; } BKE_image_release_ibuf(ima, lock); @@ -388,23 +388,27 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS); RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* animation */ prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0); RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "frames"); RNA_def_property_range(prop, 0, MAXFRAMEF); RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "offset"); RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "sfra"); @@ -412,12 +416,14 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Start Frame", "Global starting frame of the movie/sequence, assuming first picture has a #1"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "fie_ima"); RNA_def_property_range(prop, 1, 200); RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "layer"); @@ -499,7 +505,8 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); RNA_def_property_ui_text(prop, "Fields", "Use fields of the image"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha"); @@ -528,23 +535,27 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_enum_items(prop, image_generated_type_items); RNA_def_property_ui_text(prop, "Generated Type", "Generated image type"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_x"); RNA_def_property_range(prop, 1, 16384); RNA_def_property_ui_text(prop, "Generated Width", "Generated image width"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_y"); RNA_def_property_range(prop, 1, 16384); RNA_def_property_ui_text(prop, "Generated Height", "Generated image height"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT); RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* realtime properties */ prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 71196ea2a97..4d951b54c26 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -79,7 +79,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock); if (ibuf == NULL) { - BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image"); + BKE_report(reports, RPT_ERROR, "Could not acquire buffer from image"); } else { ImBuf *write_ibuf; @@ -91,7 +91,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports write_ibuf->dither = scene->r.dither_intensity; if (!BKE_imbuf_write(write_ibuf, path, &scene->r.im_format)) { - BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); + BKE_reportf(reports, RPT_ERROR, "Could not write image '%s'", path); } if (write_ibuf != ibuf) @@ -101,7 +101,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports BKE_image_release_ibuf(image, lock); } else { - BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters"); + BKE_report(reports, RPT_ERROR, "Scene not in context, could not get save parameters"); } } @@ -115,7 +115,7 @@ static void rna_Image_save(Image *image, ReportList *reports) if (image->packedfile) { if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could saved packed file to \"%s\"", image->id.name + 2, image->name); + BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'", image->id.name + 2, image->name); } } else if (IMB_saveiff(ibuf, filename, ibuf->flags)) { @@ -129,11 +129,11 @@ static void rna_Image_save(Image *image, ReportList *reports) ibuf->userflags &= ~IB_BITMAPDIRTY; } else { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could not be saved to \"%s\"", image->id.name + 2, image->name); + BKE_reportf(reports, RPT_ERROR, "Image '%s' could not be saved to '%s'", image->id.name + 2, image->name); } } else { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } } @@ -142,7 +142,7 @@ static void rna_Image_pack(Image *image, ReportList *reports, int as_png) ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { - BKE_reportf(reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG"); + BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG"); } else { if (as_png) { @@ -179,17 +179,20 @@ static void rna_Image_update(Image *image, ReportList *reports) ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); if (ibuf == NULL) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); return; } - IMB_rect_from_float(ibuf); + if (ibuf->rect) + IMB_rect_from_float(ibuf); + + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; } static void rna_Image_scale(Image *image, ReportList *reports, int width, int height) { if (!BKE_image_scale(image, width, height)) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } } @@ -205,7 +208,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int ibuf = BKE_image_get_ibuf(image, NULL); if (ibuf == NULL || ibuf->rect == NULL) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); return (int)GL_INVALID_OPERATION; } @@ -296,9 +299,9 @@ void RNA_api_image(StructRNA *srna) func = RNA_def_function(srna, "scale", "rna_Image_scale"); RNA_def_function_ui_description(func, "Scale the image in pixels"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_int(func, "width", 0, 1, 10000, "", "Width", 1, 10000); + parm = RNA_def_int(func, "width", 1, 1, 10000, "", "Width", 1, 10000); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_int(func, "height", 0, 1, 10000, "", "Height", 1, 10000); + parm = RNA_def_int(func, "height", 1, 1, 10000, "", "Height", 1, 10000); RNA_def_property_flag(parm, PROP_REQUIRED); func = RNA_def_function(srna, "gl_touch", "rna_Image_gl_touch"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index ffc78ef8ca4..6520f22fbf5 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -407,19 +407,8 @@ int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct Poi /* Internal functions that cycles uses so we need to declare (tsk tsk) */ -struct Mesh *rna_Object_to_mesh(struct Object *ob, struct ReportList *reports, struct Scene *sce, int apply_modifiers, int settings); -void rna_Main_meshes_remove(struct Main *bmain, struct ReportList *reports, struct Mesh *mesh); -void rna_Object_create_duplilist(struct Object *ob, struct ReportList *reports, struct Scene *sce, int settings); -void rna_Object_free_duplilist(struct Object *ob); void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values); void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values); -int rna_Object_is_modified(struct Object *ob, struct Scene *scene, int settings); -int rna_Object_is_deform_modified(struct Object *ob, struct Scene *scene, int settings); -void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]); -void rna_Scene_frame_set(struct Scene *scene, int frame, float subframe); - -void engine_tag_redraw(struct RenderEngine *engine); -void engine_tag_update(struct RenderEngine *engine); #endif /* __RNA_INTERNAL_H__ */ diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index d4082cf3d9f..e4a29d9c674 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -240,6 +240,12 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Deformed Location", ""); RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); + prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_range(prop, 0.01f, 100.0f); + RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); + 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", @@ -320,7 +326,7 @@ static void rna_def_lattice(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Points", "Points of the lattice"); - + /* pointers */ rna_def_animdata_common(srna); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 74b3c431183..04b8d2fa3df 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -51,7 +51,7 @@ static int rna_Main_is_dirty_get(PointerRNA *ptr) /* XXX, not totally nice to do it this way, should store in main ? */ Main *bmain = (Main *)ptr->data; wmWindowManager *wm; - for (wm = bmain->wm.first; wm; wm = wm->id.next) { + if ((wm = bmain->wm.first)) { return !wm->file_saved; } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index f5c59aa583a..cf9415a75e7 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -71,6 +71,7 @@ #include "BKE_speaker.h" #include "BKE_movieclip.h" #include "BKE_mask.h" +#include "BKE_gpencil.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -92,48 +93,55 @@ #include "DNA_node_types.h" #include "DNA_movieclip_types.h" #include "DNA_mask_types.h" +#include "DNA_gpencil_types.h" #include "ED_screen.h" +#include "BLF_translation.h" + static Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name) { ID *id = BKE_camera_add(name); id_us_min(id); return (Camera *)id; } -static void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) +static void rna_Main_cameras_remove(Main *bmain, ReportList *reports, PointerRNA *camera_ptr) { - if (ID_REAL_USERS(camera) <= 0) + Camera *camera = camera_ptr->data; + if (ID_REAL_USERS(camera) <= 0) { BKE_libblock_free(&bmain->camera, camera); - else - BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(camera_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Camera '%s' must have zero users to be removed, found %d", camera->id.name + 2, ID_REAL_USERS(camera)); - - /* XXX python now has invalid pointer? */ + } } static Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name) { return BKE_scene_add(name); } -static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) +static void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, PointerRNA *scene_ptr) { /* don't call BKE_libblock_free(...) directly */ - Scene *newscene; + Scene *scene = scene_ptr->data; + Scene *scene_new; + + if ((scene_new = scene->id.prev) || + (scene_new = scene->id.next)) + { + bScreen *sc = CTX_wm_screen(C); + if (sc->scene == scene) { + ED_screen_set_scene(C, sc, scene_new); + } - if (scene->id.prev) - newscene = scene->id.prev; - else if (scene->id.next) - newscene = scene->id.next; + BKE_scene_unlink(bmain, scene, scene_new); + RNA_POINTER_INVALIDATE(scene_ptr); + } else { - BKE_reportf(reports, RPT_ERROR, "Scene \"%s\" is the last, cant ve removed", scene->id.name + 2); - return; + BKE_reportf(reports, RPT_ERROR, "Scene '%s' is the last, cannot be removed", scene->id.name + 2); } - - if (CTX_wm_screen(C)->scene == scene) - ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - - BKE_scene_unlink(bmain, scene, newscene); } static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data) @@ -147,7 +155,7 @@ static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, co type = OB_MESH; break; case ID_CU: - type = BKE_curve_type_get((struct Curve *)data); + type = BKE_curve_type_get((Curve *)data); break; case ID_MB: type = OB_MBALL; @@ -173,7 +181,7 @@ static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, co if (RNA_enum_id_from_value(id_type_items, GS(data->name), &idname) == 0) idname = "UNKNOWN"; - BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for a object", idname); + BKE_reportf(reports, RPT_ERROR, "ID type '%s' is not valid for an object", idname); return NULL; } } @@ -190,14 +198,16 @@ static Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, co return ob; } -static void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) +static void rna_Main_objects_remove(Main *bmain, ReportList *reports, PointerRNA *object_ptr) { + Object *object = object_ptr->data; if (ID_REAL_USERS(object) <= 0) { BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */ BKE_libblock_free(&bmain->object, object); + RNA_POINTER_INVALIDATE(object_ptr); } else { - BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d", + BKE_reportf(reports, RPT_ERROR, "Object '%s' must have zero users to be removed, found %d", object->id.name + 2, ID_REAL_USERS(object)); } } @@ -208,15 +218,17 @@ static Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) id_us_min(id); return (Material *)id; } -static void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) +static void rna_Main_materials_remove(Main *bmain, ReportList *reports, PointerRNA *material_ptr) { - if (ID_REAL_USERS(material) <= 0) + Material *material = material_ptr->data; + if (ID_REAL_USERS(material) <= 0) { BKE_libblock_free(&bmain->mat, material); - else - BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(material_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Material '%s' must have zero users to be removed, found %d", material->id.name + 2, ID_REAL_USERS(material)); - - /* XXX python now has invalid pointer? */ + } } static bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type) @@ -226,15 +238,17 @@ static bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, i id_us_min(&tree->id); return tree; } -static void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree) +static void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, PointerRNA *tree_ptr) { - if (ID_REAL_USERS(tree) <= 0) + bNodeTree *tree = tree_ptr->data; + if (ID_REAL_USERS(tree) <= 0) { BKE_libblock_free(&bmain->nodetree, tree); - else - BKE_reportf(reports, RPT_ERROR, "Node Tree \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(tree_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Node tree '%s' must have zero users to be removed, found %d", tree->id.name + 2, ID_REAL_USERS(tree)); - - /* XXX python now has invalid pointer? */ + } } static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) @@ -243,15 +257,17 @@ static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) id_us_min(&me->id); return me; } -void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) +static void rna_Main_meshes_remove(Main *bmain, ReportList *reports, PointerRNA *mesh_ptr) { - if (ID_REAL_USERS(mesh) <= 0) + Mesh *mesh = mesh_ptr->data; + if (ID_REAL_USERS(mesh) <= 0) { BKE_libblock_free(&bmain->mesh, mesh); - else - BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(mesh_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Mesh '%s' must have zero users to be removed, found %d", mesh->id.name + 2, ID_REAL_USERS(mesh)); - - /* XXX python now has invalid pointer? */ + } } static Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) @@ -261,15 +277,17 @@ static Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) id_us_min(&lamp->id); return lamp; } -static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) +static void rna_Main_lamps_remove(Main *bmain, ReportList *reports, PointerRNA *lamp_ptr) { - if (ID_REAL_USERS(lamp) <= 0) + Lamp *lamp = lamp_ptr->data; + if (ID_REAL_USERS(lamp) <= 0) { BKE_libblock_free(&bmain->lamp, lamp); - else - BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(lamp_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Lamp '%s' must have zero users to be removed, found %d", lamp->id.name + 2, ID_REAL_USERS(lamp)); - - /* XXX python now has invalid pointer? */ + } } static Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer) @@ -286,21 +304,24 @@ static Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, con errno = 0; ima = BKE_image_load(filepath); - if (!ima) - BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, - errno ? strerror(errno) : "Unsupported image format"); + if (!ima) { + BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, + errno ? strerror(errno) : TIP_("unsupported image format")); + } return ima; } -static void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) +static void rna_Main_images_remove(Main *bmain, ReportList *reports, PointerRNA *image_ptr) { - if (ID_REAL_USERS(image) <= 0) + Image *image = image_ptr->data; + if (ID_REAL_USERS(image) <= 0) { BKE_libblock_free(&bmain->image, image); - else - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(image_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Image '%s' must have zero users to be removed, found %d", image->id.name + 2, ID_REAL_USERS(image)); - - /* XXX python now has invalid pointer? */ + } } static Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) @@ -309,13 +330,17 @@ static Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) id_us_min(<->id); return lt; } -static void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt) +static void rna_Main_lattices_remove(Main *bmain, ReportList *reports, PointerRNA *lt_ptr) { - if (ID_REAL_USERS(lt) <= 0) + Lattice *lt = lt_ptr->data; + if (ID_REAL_USERS(lt) <= 0) { BKE_libblock_free(&bmain->latt, lt); - else - BKE_reportf(reports, RPT_ERROR, "Lattice \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(lt_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Lattice '%s' must have zero users to be removed, found %d", lt->id.name + 2, ID_REAL_USERS(lt)); + } } static Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type) @@ -324,13 +349,17 @@ static Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int typ id_us_min(&cu->id); return cu; } -static void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) +static void rna_Main_curves_remove(Main *bmain, ReportList *reports, PointerRNA *cu_ptr) { - if (ID_REAL_USERS(cu) <= 0) + Curve *cu = cu_ptr->data; + if (ID_REAL_USERS(cu) <= 0) { BKE_libblock_free(&bmain->curve, cu); - else - BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(cu_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Curve '%s' must have zero users to be removed, found %d", cu->id.name + 2, ID_REAL_USERS(cu)); + } } static MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) @@ -339,13 +368,17 @@ static MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) id_us_min(&mb->id); return mb; } -static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb) +static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, PointerRNA *mb_ptr) { - if (ID_REAL_USERS(mb) <= 0) + MetaBall *mb = mb_ptr->data; + if (ID_REAL_USERS(mb) <= 0) { BKE_libblock_free(&bmain->mball, mb); - else - BKE_reportf(reports, RPT_ERROR, "Metaball \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(mb_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Metaball '%s' must have zero users to be removed, found %d", mb->id.name + 2, ID_REAL_USERS(mb)); + } } static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath) @@ -356,21 +389,23 @@ static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char * font = BKE_vfont_load(bmain, filepath); if (!font) - BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, - errno ? strerror(errno) : "Unsupported font format"); + BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, + errno ? strerror(errno) : TIP_("unsupported font format")); return font; } -static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) +static void rna_Main_fonts_remove(Main *bmain, ReportList *reports, PointerRNA *vfont_ptr) { - if (ID_REAL_USERS(vfont) <= 0) + VFont *vfont = vfont_ptr->data; + if (ID_REAL_USERS(vfont) <= 0) { BKE_libblock_free(&bmain->vfont, vfont); - else - BKE_reportf(reports, RPT_ERROR, "Font \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(vfont_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Font '%s' must have zero users to be removed, found %d", vfont->id.name + 2, ID_REAL_USERS(vfont)); - - /* XXX python now has invalid pointer? */ + } } static Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type) @@ -380,13 +415,17 @@ static Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int typ id_us_min(&tex->id); return tex; } -static void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) +static void rna_Main_textures_remove(Main *bmain, ReportList *reports, PointerRNA *tex_ptr) { - if (ID_REAL_USERS(tex) <= 0) + Tex *tex = tex_ptr->data; + if (ID_REAL_USERS(tex) <= 0) { BKE_libblock_free(&bmain->tex, tex); - else - BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(tex_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Texture '%s' must have zero users to be removed, found %d", tex->id.name + 2, ID_REAL_USERS(tex)); + } } static Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) @@ -395,13 +434,17 @@ static Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) id_us_min(&brush->id); return brush; } -static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush) +static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, PointerRNA *brush_ptr) { - if (ID_REAL_USERS(brush) <= 0) + Brush *brush = brush_ptr->data; + if (ID_REAL_USERS(brush) <= 0) { BKE_libblock_free(&bmain->brush, brush); - else - BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(brush_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Brush '%s' must have zero users to be removed, found %d", brush->id.name + 2, ID_REAL_USERS(brush)); + } } static World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name) @@ -410,24 +453,29 @@ static World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name) id_us_min(&world->id); return world; } -static void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world) +static void rna_Main_worlds_remove(Main *bmain, ReportList *reports, PointerRNA *world_ptr) { - if (ID_REAL_USERS(world) <= 0) + Group *world = world_ptr->data; + if (ID_REAL_USERS(world) <= 0) { BKE_libblock_free(&bmain->world, world); - else - BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(world_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "World '%s' must have zero users to be removed, found %d", world->id.name + 2, ID_REAL_USERS(world)); + } } static Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name) { return add_group(name); } -static void rna_Main_groups_remove(Main *bmain, Group *group) +static void rna_Main_groups_remove(Main *bmain, PointerRNA *group_ptr) { + Group *group = group_ptr->data; BKE_group_unlink(group); BKE_libblock_free(&bmain->group, group); - /* XXX python now has invalid pointer? */ + RNA_POINTER_INVALIDATE(group_ptr); } static Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) @@ -436,26 +484,29 @@ static Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) id_us_min(&speaker->id); return speaker; } -static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker) +static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, PointerRNA *speaker_ptr) { - if (ID_REAL_USERS(speaker) <= 0) + Speaker *speaker = speaker_ptr->data; + if (ID_REAL_USERS(speaker) <= 0) { BKE_libblock_free(&bmain->speaker, speaker); - else - BKE_reportf(reports, RPT_ERROR, "Speaker \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(speaker_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Speaker '%s' must have zero users to be removed, found %d", speaker->id.name + 2, ID_REAL_USERS(speaker)); - - /* XXX python now has invalid pointer? */ + } } static Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name) { return BKE_text_add(name); } -static void rna_Main_texts_remove(Main *bmain, Text *text) +static void rna_Main_texts_remove(Main *bmain, PointerRNA *text_ptr) { + Text *text = text_ptr->data; BKE_text_unlink(bmain, text); BKE_libblock_free(&bmain->text, text); - /* XXX python now has invalid pointer? */ + RNA_POINTER_INVALIDATE(text_ptr); } static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath) @@ -466,8 +517,8 @@ static Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *f txt = BKE_text_load(filepath, bmain->name); if (!txt) - BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, - errno ? strerror(errno) : "Unable to load text"); + BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, + errno ? strerror(errno) : TIP_("unable to load text")); return txt; } @@ -478,15 +529,17 @@ static bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name) id_us_min(&arm->id); return arm; } -static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) +static void rna_Main_armatures_remove(Main *bmain, ReportList *reports, PointerRNA *arm_ptr) { - if (ID_REAL_USERS(arm) <= 0) + bArmature *arm = arm_ptr->data; + if (ID_REAL_USERS(arm) <= 0) { BKE_libblock_free(&bmain->armature, arm); - else - BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(arm_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Armature '%s' must have zero users to be removed, found %d", arm->id.name + 2, ID_REAL_USERS(arm)); - - /* XXX python now has invalid pointer? */ + } } static bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name) @@ -496,15 +549,17 @@ static bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name) act->id.flag &= ~LIB_FAKEUSER; return act; } -static void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) +static void rna_Main_actions_remove(Main *bmain, ReportList *reports, PointerRNA *act_ptr) { - if (ID_REAL_USERS(act) <= 0) + bAction *act = act_ptr->data; + if (ID_REAL_USERS(act) <= 0) { BKE_libblock_free(&bmain->action, act); - else - BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(act_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Action '%s' must have zero users to be removed, found %d", act->id.name + 2, ID_REAL_USERS(act)); - - /* XXX python now has invalid pointer? */ + } } static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) @@ -513,15 +568,17 @@ static ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) id_us_min(&part->id); return part; } -static void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part) +static void rna_Main_particles_remove(Main *bmain, ReportList *reports, PointerRNA *part_ptr) { - if (ID_REAL_USERS(part) <= 0) + ParticleSettings *part = part_ptr->data; + if (ID_REAL_USERS(part) <= 0) { BKE_libblock_free(&bmain->particle, part); - else - BKE_reportf(reports, RPT_ERROR, "Particle Settings \"%s\" must have zero users to be removed, found %d", + RNA_POINTER_INVALIDATE(part_ptr); + } + else { + BKE_reportf(reports, RPT_ERROR, "Particle settings '%s' must have zero users to be removed, found %d", part->id.name + 2, ID_REAL_USERS(part)); - - /* XXX python now has invalid pointer? */ + } } static MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, const char *filepath) @@ -532,17 +589,18 @@ static MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *repor clip = BKE_movieclip_file_add(filepath); if (!clip) - BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, - errno ? strerror(errno) : "Unable to load movie clip"); + BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath, + errno ? strerror(errno) : TIP_("unable to load movie clip")); return clip; } -static void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip) +static void rna_Main_movieclips_remove(Main *bmain, PointerRNA *clip_ptr) { + MovieClip *clip = clip_ptr->data; BKE_movieclip_unlink(bmain, clip); BKE_libblock_free(&bmain->movieclip, clip); - /* XXX python now has invalid pointer? */ + RNA_POINTER_INVALIDATE(clip_ptr); } static Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name) @@ -554,11 +612,25 @@ static Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name) return mask; } -static void rna_Main_masks_remove(Main *bmain, Mask *mask) +static void rna_Main_masks_remove(Main *bmain, PointerRNA *mask_ptr) { + Mask *mask = mask_ptr->data; BKE_mask_free(bmain, mask); BKE_libblock_free(&bmain->mask, mask); - /* XXX python now has invalid pointer? */ + RNA_POINTER_INVALIDATE(mask_ptr); +} + +static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, PointerRNA *gpd_ptr) +{ + bGPdata *gpd = gpd_ptr->data; + if (ID_REAL_USERS(gpd) <= 0) { + BKE_gpencil_free(gpd); + BKE_libblock_free(&bmain->gpencil, gpd); + RNA_POINTER_INVALIDATE(gpd_ptr); + } + else + BKE_reportf(reports, RPT_ERROR, "Grease pencil '%s' must have zero users to be removed, found %d", + gpd->id.name + 2, ID_REAL_USERS(gpd)); } /* tag functions, all the same */ @@ -664,7 +736,8 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a camera from the current blendfile"); parm = RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_cameras_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -699,7 +772,8 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a scene from the current blendfile"); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_scenes_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -738,7 +812,8 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a object from the current blendfile"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_objects_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -773,7 +848,8 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a material from the current blendfile"); parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_materials_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -816,7 +892,8 @@ void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a node tree from the current blendfile"); parm = RNA_def_pointer(func, "tree", "NodeTree", "", "Node tree to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_node_groups_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -850,7 +927,8 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_meshes_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -886,7 +964,8 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile"); parm = RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_lamps_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -975,9 +1054,9 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Add a new image to the main database"); parm = RNA_def_string(func, "name", "Image", 0, "", "New name for the datablock"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image", 0, INT_MAX); + parm = RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image", 1, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_int(func, "height", 1024, 1, INT_MAX, "", "Height of the image", 0, INT_MAX); + parm = RNA_def_int(func, "height", 1024, 1, INT_MAX, "", "Height of the image", 1, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_boolean(func, "alpha", 0, "Alpha", "Use alpha channel"); RNA_def_boolean(func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color"); @@ -998,7 +1077,8 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove an image from the current blendfile"); parm = RNA_def_pointer(func, "image", "Image", "", "Image to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_images_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1033,7 +1113,8 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a lattice from the current blendfile"); parm = RNA_def_pointer(func, "lattice", "Lattice", "", "Lattice to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_lattices_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1069,7 +1150,8 @@ void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a curve from the current blendfile"); parm = RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_curves_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1103,7 +1185,8 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a metaball from the current blendfile"); parm = RNA_def_pointer(func, "metaball", "MetaBall", "", "Metaball to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_metaballs_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1138,7 +1221,8 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a font from the current blendfile"); parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "Font to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_fonts_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1174,7 +1258,8 @@ void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a texture from the current blendfile"); parm = RNA_def_pointer(func, "texture", "Texture", "", "Texture to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_textures_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1208,7 +1293,8 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a brush from the current blendfile"); parm = RNA_def_pointer(func, "brush", "Brush", "", "Brush to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_brushes_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1243,7 +1329,8 @@ void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a world from the current blendfile"); parm = RNA_def_pointer(func, "world", "World", "", "World to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_worlds_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1277,7 +1364,8 @@ void RNA_def_main_groups(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_Main_groups_remove"); RNA_def_function_ui_description(func, "Remove a group from the current blendfile"); parm = RNA_def_pointer(func, "group", "Group", "", "Group to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_groups_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1312,7 +1400,8 @@ void RNA_def_main_speakers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a speaker from the current blendfile"); parm = RNA_def_pointer(func, "speaker", "Speaker", "", "Speaker to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_speakers_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1346,7 +1435,8 @@ void RNA_def_main_texts(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_Main_texts_remove"); RNA_def_function_ui_description(func, "Remove a text from the current blendfile"); parm = RNA_def_pointer(func, "text", "Text", "", "Text to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* load func */ func = RNA_def_function(srna, "load", "rna_Main_texts_load"); @@ -1414,7 +1504,8 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a armature from the current blendfile"); parm = RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_armatures_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1448,7 +1539,8 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a action from the current blendfile"); parm = RNA_def_pointer(func, "action", "Action", "", "Action to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_actions_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1482,7 +1574,8 @@ void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a particle settings instance from the current blendfile"); parm = RNA_def_pointer(func, "particle", "ParticleSettings", "", "Particle Settings to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "tag", "rna_Main_particles_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); @@ -1509,6 +1602,21 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + func = RNA_def_function(srna, "new", "gpencil_data_addnew"); + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the datablock"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "New grease pencil datablock"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_grease_pencil_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a grease pencil instance from the current blendfile"); + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "Grease Pencil to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL); @@ -1532,7 +1640,8 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_Main_movieclips_remove"); RNA_def_function_ui_description(func, "Remove a movie clip from the current blendfile."); parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* load func */ func = RNA_def_function(srna, "load", "rna_Main_movieclip_load"); @@ -1563,7 +1672,7 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) /* new func */ func = RNA_def_function(srna, "new", "rna_Main_mask_new"); RNA_def_function_ui_description(func, "Add a new mask with a given name to the main database"); - parm = RNA_def_string_file_path(func, "name", "", MAX_ID_NAME - 2, "Mask", "Name of new mask datablock"); + RNA_def_string_file_path(func, "name", "", MAX_ID_NAME - 2, "Mask", "Name of new mask datablock"); /* return type */ parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask datablock"); RNA_def_function_return(func, parm); @@ -1572,7 +1681,8 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_Main_masks_remove"); RNA_def_function_ui_description(func, "Remove a masks from the current blendfile."); parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } #endif diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 97d9cc961ef..3f23a376ea3 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -158,8 +158,7 @@ static void rna_Mask_layer_active_index_range(PointerRNA *ptr, int *min, int *ma Mask *mask = (Mask *)ptr->id.data; *min = 0; - *max = mask->masklay_tot - 1; - *max = MAX2(0, *max); + *max = max_ii(0, mask->masklay_tot - 1); *softmin = *min; *softmax = *max; @@ -315,14 +314,16 @@ static MaskLayer *rna_Mask_layers_new(Mask *mask, const char *name) return masklay; } -static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, MaskLayer *masklay) +static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, PointerRNA *masklay_ptr) { + MaskLayer *masklay = masklay_ptr->data; if (BLI_findindex(&mask->masklayers, masklay) == -1) { - BKE_reportf(reports, RPT_ERROR, "MaskLayer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Mask layer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2); return; } BKE_mask_layer_remove(mask, masklay); + RNA_POINTER_INVALIDATE(masklay_ptr); WM_main_add_notifier(NC_MASK | NA_EDITED, mask); } @@ -705,7 +706,9 @@ static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_Mask_layers_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove layer from this mask"); - RNA_def_pointer(func, "layer", "MaskLayer", "", "Shape to be removed"); + parm = RNA_def_pointer(func, "layer", "MaskLayer", "", "Shape to be removed"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* clear all layers */ func = RNA_def_function(srna, "clear", "rna_Mask_layers_clear"); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 96529de074b..9232ae098ea 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -81,12 +81,14 @@ EnumPropertyItem ramp_blend_items[] = { #include "MEM_guardedalloc.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_texture.h" #include "BKE_node.h" +#include "BKE_paint.h" #include "ED_node.h" @@ -105,7 +107,18 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *p } } -static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Material_update_previews(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Material *ma = ptr->id.data; + + if (ma->nodetree) + ntreeClearPreview(ma->nodetree); + + rna_Material_update(bmain, scene, ptr); +} + + +static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { Material *ma = ptr->id.data; @@ -319,7 +332,7 @@ MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *re { MTex *mtex = add_mtex_id(self_id, -1); if (mtex == NULL) { - BKE_reportf(reports, RPT_ERROR, "maximum number of textures added %d", MAX_MTEX); + BKE_reportf(reports, RPT_ERROR, "Maximum number of textures added %d", MAX_MTEX); return NULL; } @@ -334,7 +347,7 @@ MTex *rna_mtex_texture_slots_create(ID *self_id, struct bContext *C, ReportList MTex *mtex; if (index < 0 || index >= MAX_MTEX) { - BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index); + BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index); return NULL; } @@ -354,12 +367,12 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r give_active_mtex(self_id, &mtex_ar, &act); if (mtex_ar == NULL) { - BKE_report(reports, RPT_ERROR, "mtex not found for this type"); + BKE_report(reports, RPT_ERROR, "Mtex not found for this type"); return; } if (index < 0 || index >= MAX_MTEX) { - BKE_reportf(reports, RPT_ERROR, "index %d is invalid", index); + BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index); return; } @@ -468,6 +481,12 @@ static void rna_def_material_mtex(BlenderRNA *brna) "from their parent"); RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "use_map_to_bounds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_MAPTO_BOUNDS); + RNA_def_property_ui_text(prop, "Map to Bounds", + "Map coordinates in object bounds"); + RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "use_from_original", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG); RNA_def_property_ui_text(prop, "From Original", @@ -1749,7 +1768,7 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "pr_type"); RNA_def_property_enum_items(prop, preview_type_items); RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_update(prop, 0, "rna_Material_update_previews"); prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "amb"); @@ -1817,7 +1836,12 @@ void RNA_def_material(BlenderRNA *brna) "Material uses the light group exclusively - these lamps are excluded " "from other scene lighting"); RNA_def_property_update(prop, 0, "rna_Material_update"); - + + prop = RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL); + RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, material uses local light group with the same name"); + RNA_def_property_update(prop, 0, "rna_Material_update"); + prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE); RNA_def_property_ui_text(prop, "Traceable", diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 59cf202a416..287995e0aa6 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1010,8 +1010,7 @@ static void rna_MeshPoly_material_index_range(PointerRNA *ptr, int *min, int *ma { Mesh *me = rna_mesh(ptr); *min = 0; - *max = me->totcol - 1; - *max = MAX2(0, *max); + *max = max_ii(0, me->totcol - 1); } static int rna_MeshVertex_index_get(PointerRNA *ptr) @@ -1275,12 +1274,12 @@ static PointerRNA rna_Mesh_tessface_vertex_color_new(struct Mesh *me, struct bCo int index; if (me->edit_btmesh) { - BKE_report(reports, RPT_ERROR, "Can't add tessface colors's in editmode"); + BKE_report(reports, RPT_ERROR, "Cannot add tessface colors in edit mode"); return PointerRNA_NULL; } if (me->mpoly) { - BKE_report(reports, RPT_ERROR, "Can't add tessface colors's when MPoly's exist"); + BKE_report(reports, RPT_ERROR, "Cannot add tessface colors when MPoly's exist"); return PointerRNA_NULL; } @@ -1368,12 +1367,12 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, struct bCont int index; if (me->edit_btmesh) { - BKE_report(reports, RPT_ERROR, "Can't add tessface uv's in editmode"); + BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's in edit mode"); return PointerRNA_NULL; } if (me->mpoly) { - BKE_report(reports, RPT_ERROR, "Can't add tessface uv's when MPoly's exist"); + BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's when MPoly's exist"); return PointerRNA_NULL; } @@ -2394,7 +2393,8 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); #endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); @@ -2571,7 +2571,8 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); #endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); @@ -2808,7 +2809,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop = RNA_def_property(srna, "skin_vertices", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer"); RNA_def_property_collection_funcs(prop, "rna_Mesh_skin_vertices_begin", NULL, NULL, NULL, - "rna_Mesh_skin_vertices_length", NULL, NULL, NULL); + "rna_Mesh_skin_vertices_length", NULL, NULL, NULL); RNA_def_property_struct_type(prop, "MeshSkinVertexLayer"); RNA_def_property_ui_text(prop, "Skin Vertices", "All skin vertices"); rna_def_skin_vertices(brna, prop); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index b63390c65ed..1e75569c841 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -78,7 +78,7 @@ void RNA_api_mesh(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); func = RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare"); - parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to"); + RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); /* return value */ parm = RNA_def_string(func, "result", "nothing", 64, "Return value", "String description of result of comparison"); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index c8b52b45604..08eefc082bf 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -126,19 +127,17 @@ static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type) return ml; } -static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, MetaElem *ml) +static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, PointerRNA *ml_ptr) { - int found = 0; + MetaElem *ml = ml_ptr->data; - found = BLI_remlink_safe(&mb->elems, ml); - - if (!found) { - BKE_reportf(reports, RPT_ERROR, "Metaball \"%s\" does not contain spline given", mb->id.name + 2); + if (BLI_remlink_safe(&mb->elems, ml) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "Metaball '%s' does not contain spline given", mb->id.name + 2); return; } MEM_freeN(ml); - /* invalidate pointer!, no can do */ + RNA_POINTER_INVALIDATE(ml_ptr); /* cheating way for importers to avoid slow updates */ if (mb->id.us > 0) { @@ -254,7 +253,8 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove an element from the metaball"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_MetaBall_elements_clear"); RNA_def_function_ui_description(func, "Remove all elements from the metaball"); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index bc3fd6e2f3c..a381dd489c7 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -84,6 +84,7 @@ EnumPropertyItem modifier_type_items[] = { {eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", ""}, {eModifierType_Displace, "DISPLACE", ICON_MOD_DISPLACE, "Displace", ""}, {eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", ""}, + {eModifierType_LaplacianSmooth, "LAPLACIANSMOOTH", ICON_MOD_SMOOTH, "Laplacian Smooth", ""}, {eModifierType_Lattice, "LATTICE", ICON_MOD_LATTICE, "Lattice", ""}, {eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""}, {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, @@ -210,6 +211,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_RemeshModifier; case eModifierType_Skin: return &RNA_SkinModifier; + case eModifierType_LaplacianSmooth: + return &RNA_LaplacianSmoothModifier; default: return &RNA_Modifier; } @@ -257,9 +260,6 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr) { SmokeModifierData *smd = (SmokeModifierData *)ptr->data; Object *ob = (Object *)ptr->id.data; - ParticleSystemModifierData *psmd = NULL; - ParticleSystem *psys = NULL; - ParticleSettings *part = NULL; /* nothing changed */ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) @@ -273,28 +273,6 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr) ob->dt = OB_WIRE; break; case MOD_SMOKE_TYPE_FLOW: - for (psys = ob->particlesystem.first; psys; psys = psys->next) - if (psys->part->type == PART_EMITTER) - break; - if (ob->type == OB_MESH && !psys) { - /* add particle system */ - psmd = (ParticleSystemModifierData *)object_add_particle_system(scene, ob, NULL); - if (psmd) { - psys = psmd->psys; - part = psys->part; - part->lifetime = 1.0f; - part->sta = 1.0f; - part->end = 250.0f; - part->ren_as = PART_DRAW_NOT; - part->flag |= PART_UNBORN; - part->draw_as = PART_DRAW_DOT; - BLI_strncpy(psys->name, "SmokeParticles", sizeof(psys->name)); - psys->recalc |= (PSYS_RECALC_RESET | PSYS_RECALC_PHYS); - DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); - } - } - if (smd->flow) - smd->flow->psys = psys; case MOD_SMOKE_TYPE_COLL: case 0: default: @@ -384,6 +362,12 @@ static void rna_SmoothModifier_vgroup_set(PointerRNA *ptr, const char *value) rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name)); } +static void rna_LaplacianSmoothModifier_vgroup_set(PointerRNA *ptr, const char *value) +{ + LaplacianSmoothModifierData *lmd = (LaplacianSmoothModifierData *)ptr->data; + rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name)); +} + static void rna_WaveModifier_vgroup_set(PointerRNA *ptr, const char *value) { WaveModifierData *lmd = (WaveModifierData *)ptr->data; @@ -402,6 +386,12 @@ static void rna_SolidifyModifier_vgroup_set(PointerRNA *ptr, const char *value) rna_object_vgroup_name_set(ptr, value, smd->defgrp_name, sizeof(smd->defgrp_name)); } +static void rna_DecimateModifier_vgroup_set(PointerRNA *ptr, const char *value) +{ + DecimateModifierData *dmd = (DecimateModifierData *)ptr->data; + rna_object_vgroup_name_set(ptr, value, dmd->defgrp_name, sizeof(dmd->defgrp_name)); +} + static void rna_WeightVGModifier_vgroup_set(PointerRNA *ptr, const char *value) { ModifierData *md = (ModifierData *)ptr->data; @@ -491,8 +481,7 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max MultiresModifierData *mmd = (MultiresModifierData *)ptr->data; *min = 0; - *max = mmd->totlvl; /* intentionally _not_ -1 */ - *max = MAX2(0, *max); + *max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */ } static int rna_MultiresModifier_external_get(PointerRNA *ptr) @@ -1129,6 +1118,13 @@ static void rna_def_modifier_mirror(BlenderRNA *brna) static void rna_def_modifier_decimate(BlenderRNA *brna) { + static EnumPropertyItem modifier_decim_mode_items[] = { + {MOD_DECIM_MODE_COLLAPSE, "COLLAPSE", 0, "Collapse", "Use edge collapsing"}, + {MOD_DECIM_MODE_UNSUBDIV, "UNSUBDIV", 0, "Un-Subdivide", "Use un-subdivide face reduction"}, + {MOD_DECIM_MODE_DISSOLVE, "DISSOLVE", 0, "Planar", "Dissolve geometry to form planar polygons"}, + {0, NULL, 0, NULL, NULL} + }; + StructRNA *srna; PropertyRNA *prop; @@ -1137,15 +1133,65 @@ static void rna_def_modifier_decimate(BlenderRNA *brna) RNA_def_struct_sdna(srna, "DecimateModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_DECIM); + prop = RNA_def_property(srna, "decimate_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, modifier_decim_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_COLLAPSE) */ prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "percent"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_range(prop, 0, 1, 1, 2); - RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to"); + RNA_def_property_ui_range(prop, 0, 1, 1, 4); + RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to (collapse only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_UNSUBDIV) */ + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "iter"); + RNA_def_property_range(prop, 0, SHRT_MAX); + RNA_def_property_ui_range(prop, 0, 100, 1, 0); + RNA_def_property_ui_text(prop, "Iterations", "Number of times reduce the geometry (unsubdivide only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_DISSOLVE) */ + prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "angle"); + RNA_def_property_range(prop, 0, DEG2RAD(180)); + RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2); + RNA_def_property_ui_text(prop, "Angle Limit", "Only dissolve angles below this (planar only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_COLLAPSE) */ + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name (collapse only)"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DecimateModifier_vgroup_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence (collapse only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_collapse_triangulate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_TRIANGULATE); + RNA_def_property_ui_text(prop, "Triangulate", "Keep triangulated faces resulting from decimation (collapse only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* end collapse-only option */ + + /* (mode == MOD_DECIM_MODE_DISSOLVE) */ + prop = RNA_def_property(srna, "use_dissolve_boundaries", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS); + RNA_def_property_ui_text(prop, "All Boundaries", "Dissolve all vertices inbetween face boundaries (planar only)"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* end dissolve-only option */ + + + /* all modes use this */ prop = RNA_def_property(srna, "face_count", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "faceCount"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Face Count", "The current number of faces in the decimated mesh"); } @@ -1742,6 +1788,64 @@ static void rna_def_modifier_smooth(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LaplacianSmoothModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Laplacian Smooth Modifier", "Smoothing effect modifier"); + RNA_def_struct_sdna(srna, "LaplacianSmoothModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH); + + prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_X); + RNA_def_property_ui_text(prop, "X", "Smooth object along X axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Y); + RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Z); + RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION); + RNA_def_property_ui_text(prop, "Preserve Volume", "Apply volume preservation after smooth"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "lambda_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "lambda"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0000001, 1000.0, 0.0000001, 8); + RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth factor effect"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "lambda_border", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "lambda_border"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0000001, 1000.0, 0.0000001, 8); + RNA_def_property_ui_text(prop, "Lambda Border", "Lambda factor in border"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "repeat"); + RNA_def_property_ui_range(prop, 0, 200, 1, 0); + RNA_def_property_ui_text(prop, "Repeat", ""); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text(prop, "Vertex Group", + "Name of Vertex Group which determines influence of modifier per point"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LaplacianSmoothModifier_vgroup_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + static void rna_def_modifier_cast(BlenderRNA *brna) { StructRNA *srna; @@ -2296,6 +2400,13 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Offset", "Distance to keep from the target"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "project_limit", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "projLimit"); + RNA_def_property_range(prop, 0.0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 100, 1, 2); + RNA_def_property_ui_text(prop, "Project Limit", "Limit the distance used for projection (zero disables)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_project_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS); RNA_def_property_ui_text(prop, "X", ""); @@ -3356,6 +3467,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_ocean(brna); rna_def_modifier_remesh(brna); rna_def_modifier_skin(brna); + rna_def_modifier_laplaciansmooth(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 4ff1365427e..574f06e9107 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" @@ -302,7 +303,7 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo NlaStrip *strip = add_nlastrip(action); if (strip == NULL) { - BKE_reportf(reports, RPT_ERROR, "Unable to create new strip"); + BKE_report(reports, RPT_ERROR, "Unable to create new strip"); return NULL; } @@ -310,8 +311,8 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo strip->start = start; if (BKE_nlastrips_add_strip(&track->strips, strip) == 0) { - BKE_reportf(reports, RPT_ERROR, - "Unable to add strip. Track doesn't have any space to accommodate this new strip"); + BKE_report(reports, RPT_ERROR, + "Unable to add strip (the track does not have any space to accommodate this new strip)"); free_nlastrip(NULL, strip); return NULL; } @@ -345,16 +346,18 @@ static NlaStrip *rna_NlaStrip_new(NlaTrack *track, bContext *C, ReportList *repo return strip; } -static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, NlaStrip *strip) +static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, PointerRNA *strip_ptr) { + NlaStrip *strip = strip_ptr->data; if (BLI_findindex(&track->strips, strip) == -1) { - BKE_reportf(reports, RPT_ERROR, "NLA's Strip '%s' not found in track '%s'", strip->name, track->name); + BKE_reportf(reports, RPT_ERROR, "NLA strip '%s' not found in track '%s'", strip->name, track->name); return; } - else { - free_nlastrip(&track->strips, strip); - WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); - } + + free_nlastrip(&track->strips, strip); + RNA_POINTER_INVALIDATE(strip_ptr); + + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); } /* Set the 'solo' setting for the given NLA-track, making sure that it is the only one @@ -639,7 +642,8 @@ static void rna_api_nlatrack_strips(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a NLA Strip"); parm = RNA_def_pointer(func, "strip", "NlaStrip", "", "NLA Strip to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_nlatrack(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d650c8dbf69..33a41ff6f6e 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -35,12 +35,16 @@ #include "rna_internal_types.h" #include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_string.h" +#include "BLI_utildefines.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_text_types.h" #include "DNA_texture_types.h" #include "BKE_animsys.h" @@ -48,9 +52,9 @@ #include "BKE_node.h" #include "BKE_image.h" #include "BKE_texture.h" +#include "BKE_idprop.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" +#include "IMB_imbuf.h" #include "WM_types.h" @@ -71,12 +75,12 @@ EnumPropertyItem node_quality_items[] = { }; EnumPropertyItem node_chunksize_items[] = { - {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"}, - {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"}, - {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"}, - {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"}, - {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"}, - {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"}, + {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"}, + {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"}, + {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"}, + {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"}, + {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"}, + {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"}, {0, NULL, 0, NULL, NULL} }; @@ -88,6 +92,7 @@ EnumPropertyItem node_socket_type_items[] = { {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, {SOCK_MESH, "MESH", 0, "Mesh", ""}, {SOCK_INT, "INT", 0, "Int", ""}, + {SOCK_STRING, "STRING", 0, "String", ""}, {0, NULL, 0, NULL, NULL} }; @@ -188,6 +193,10 @@ EnumPropertyItem prop_wave_items[] = { SUBTYPE(FLOAT, Float, TIME, Time) \ SUBTYPE(FLOAT, Float, DISTANCE, Distance) +#define NODE_DEFINE_SUBTYPES_STRING \ + SUBTYPE(STRING, String, NONE, None) \ + SUBTYPE(STRING, String, FILEPATH, Filepath) + #define NODE_DEFINE_SUBTYPES_VECTOR \ SUBTYPE(VECTOR, Vector, NONE, None) \ SUBTYPE(VECTOR, Vector, TRANSLATION, Translation) \ @@ -200,14 +209,18 @@ EnumPropertyItem prop_wave_items[] = { #define NODE_DEFINE_SUBTYPES \ NODE_DEFINE_SUBTYPES_INT \ NODE_DEFINE_SUBTYPES_FLOAT \ - NODE_DEFINE_SUBTYPES_VECTOR + NODE_DEFINE_SUBTYPES_STRING \ + NODE_DEFINE_SUBTYPES_VECTOR \ #ifdef RNA_RUNTIME #include "BLI_linklist.h" +#include "BKE_global.h" + #include "ED_node.h" +#include "RE_engine.h" #include "RE_pipeline.h" #include "DNA_scene_types.h" @@ -226,10 +239,6 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr) case NODE_GROUP: return &RNA_NodeGroup; - case NODE_FORLOOP: - return &RNA_NodeForLoop; - case NODE_WHILELOOP: - return &RNA_NodeWhileLoop; case NODE_FRAME: return &RNA_NodeFrame; case NODE_REROUTE: @@ -290,6 +299,9 @@ static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr) case SOCK_VECTOR: NODE_DEFINE_SUBTYPES_VECTOR break; + case SOCK_STRING: + NODE_DEFINE_SUBTYPES_STRING + break; case SOCK_RGBA: return &RNA_NodeSocketRGBA; case SOCK_SHADER: @@ -689,7 +701,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r bNodeTemplate ntemp; if (type == NODE_GROUP && group == NULL) { - BKE_reportf(reports, RPT_ERROR, "node type \'GROUP\' missing group argument"); + BKE_report(reports, RPT_ERROR, "Node type 'GROUP' missing group argument"); return NULL; } @@ -700,7 +712,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r node = nodeAddNode(ntree, &ntemp); if (node == NULL) { - BKE_reportf(reports, RPT_ERROR, "Unable to create node"); + BKE_report(reports, RPT_ERROR, "Unable to create node"); } else { ntreeUpdateTree(ntree); /* update group node socket links*/ @@ -753,20 +765,20 @@ static bNode *rna_NodeTree_node_texture_new(bNodeTree *ntree, bContext *C, Repor return node; } -static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNode *node) +static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, PointerRNA *node_ptr) { + bNode *node = node_ptr->data; if (BLI_findindex(&ntree->nodes, node) == -1) { - BKE_reportf(reports, RPT_ERROR, "Unable to locate node '%s' in nodetree", node->name); + BKE_reportf(reports, RPT_ERROR, "Unable to locate node '%s' in node tree", node->name); + return; } - else { - if (node->id) - id_us_min(node->id); - nodeFreeNode(ntree, node); - ntreeUpdateTree(ntree); /* update group node socket links*/ + id_us_min(node->id); + nodeFreeNode(ntree, node); + RNA_POINTER_INVALIDATE(node_ptr); - WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); - } + ntreeUpdateTree(ntree); /* update group node socket links */ + WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } static void rna_NodeTree_node_clear(bNodeTree *ntree) @@ -800,7 +812,7 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, nodeFindNode(ntree, tosock, &tonode, NULL, &to_in_out); if (&from_in_out == &to_in_out) { - BKE_reportf(reports, RPT_ERROR, "Same input/output direction of sockets"); + BKE_report(reports, RPT_ERROR, "Same input/output direction of sockets"); return NULL; } @@ -824,17 +836,19 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, return ret; } -static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNodeLink *link) +static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, PointerRNA *link_ptr) { + bNodeLink *link = link_ptr->data; if (BLI_findindex(&ntree->links, link) == -1) { - BKE_reportf(reports, RPT_ERROR, "Unable to locate link in nodetree"); + BKE_report(reports, RPT_ERROR, "Unable to locate link in node tree"); + return; } - else { - nodeRemLink(ntree, link); - ntreeUpdateTree(ntree); - WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); - } + nodeRemLink(ntree, link); + RNA_POINTER_INVALIDATE(link_ptr); + + ntreeUpdateTree(ntree); + WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } static void rna_NodeTree_link_clear(bNodeTree *ntree) @@ -882,9 +896,9 @@ static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *repo int index, in_out; if (!nodeFindNode(ntree, sock, &node, &index, &in_out)) - BKE_reportf(reports, RPT_ERROR, "Unable to locate socket in nodetree"); + BKE_report(reports, RPT_ERROR, "Unable to locate socket in node tree"); else if (in_out != SOCK_IN) - BKE_reportf(reports, RPT_ERROR, "Socket is not an input"); + BKE_report(reports, RPT_ERROR, "Socket is not an input"); else { /* XXX should check if tree is a group here! no good way to do this currently. */ gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_IN); @@ -906,9 +920,9 @@ static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *rep int index, in_out; if (!nodeFindNode(ntree, sock, &node, &index, &in_out)) - BKE_reportf(reports, RPT_ERROR, "Unable to locate socket in nodetree"); + BKE_report(reports, RPT_ERROR, "Unable to locate socket in node tree"); else if (in_out != SOCK_OUT) - BKE_reportf(reports, RPT_ERROR, "Socket is not an output"); + BKE_report(reports, RPT_ERROR, "Socket is not an output"); else { /* XXX should check if tree is a group here! no good way to do this currently. */ gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_OUT); @@ -997,6 +1011,145 @@ static void rna_NodeOutputFileSlotLayer_name_set(PointerRNA *ptr, const char *va } } +static bNodeSocket *rna_ShaderNodeScript_find_socket(bNode *node, const char *name, int is_output) +{ + bNodeSocket *sock; + + if (is_output) { + for (sock = node->outputs.first; sock; sock = sock->next) { + if (strcmp(sock->name, name) == 0) { + return sock; + } + } + } + else { + for (sock = node->inputs.first; sock; sock = sock->next) { + if (strcmp(sock->name, name) == 0) { + return sock; + } + } + } + + return NULL; +} + +static void rna_ShaderNodeScript_remove_socket(ID *id, bNode *node, bNodeSocket *sock) +{ + bNodeTree *ntree = (bNodeTree *)id; + + nodeRemoveSocket(ntree, node, sock); + + ED_node_generic_update(G.main, ntree, node); +} + +static bNodeSocket *rna_ShaderNodeScript_add_socket(ID *id, bNode *node, const char *name, int type, int is_output) +{ + bNodeTree *ntree = (bNodeTree *)id; + bNodeSocket *sock; + + /* replace existing socket with the same name, to keep it unique */ + sock = rna_ShaderNodeScript_find_socket(node, name, is_output); + if (sock) + nodeRemoveSocket(ntree, node, sock); + sock = nodeAddSocket(ntree, node, (is_output ? SOCK_OUT : SOCK_IN), name, type); + + ED_node_generic_update(G.main, ntree, node); + + return sock; +} + +static void rna_ShaderNodeScript_mode_set(PointerRNA *ptr, int value) +{ + bNode *node = (bNode *)ptr->data; + NodeShaderScript *nss = node->storage; + + if (nss->mode != value) { + nss->mode = value; + nss->filepath[0] = '\0'; + nss->flag &= ~NODE_SCRIPT_AUTO_UPDATE; + + /* replace text datablock by filepath */ + if (node->id) { + Text *text = (Text*)node->id; + + if (value == NODE_SCRIPT_EXTERNAL && text->name) { + BLI_strncpy(nss->filepath, text->name, sizeof(nss->filepath)); + BLI_path_rel(nss->filepath, G.main->name); + } + + id_us_min(node->id); + node->id = NULL; + } + + /* remove any bytecode */ + if (nss->bytecode) { + MEM_freeN(nss->bytecode); + nss->bytecode = NULL; + } + + nss->bytecode_hash[0] = '\0'; + } +} + +static void rna_ShaderNodeScript_bytecode_get(PointerRNA *ptr, char *value) +{ + bNode *node = (bNode *)ptr->data; + NodeShaderScript *nss = node->storage; + + strcpy(value, (nss->bytecode)? nss->bytecode: ""); +} + +static int rna_ShaderNodeScript_bytecode_length(PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + NodeShaderScript *nss = node->storage; + + return (nss->bytecode) ? strlen(nss->bytecode) : 0; +} + +static void rna_ShaderNodeScript_bytecode_set(PointerRNA *ptr, const char *value) +{ + bNode *node = (bNode *)ptr->data; + NodeShaderScript *nss = node->storage; + + if (nss->bytecode) + MEM_freeN(nss->bytecode); + + if (value && value[0]) + nss->bytecode = BLI_strdup(value); + else + nss->bytecode = NULL; +} + +static IDProperty *rna_ShaderNodeScript_idprops(PointerRNA *ptr, int create) +{ + bNode *node = (bNode *)ptr->data; + NodeShaderScript *nss = node->storage; + + if (create && !nss->prop) { + IDPropertyTemplate val = {0}; + nss->prop = IDP_New(IDP_GROUP, &val, "RNA_ShaderNodeScript ID properties"); + } + + return nss->prop; +} + +static void rna_ShaderNodeScript_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNode *node = (bNode *)ptr->data; + RenderEngineType *engine_type = RE_engines_find(scene->r.engine); + + if(engine_type && engine_type->update_script_node) { + /* auto update node */ + RenderEngine *engine = RE_engine_create(engine_type); + engine_type->update_script_node(engine, ntree, node); + RE_engine_free(engine); + } + + node_update(bmain, scene, ntree, node); +} + #else static EnumPropertyItem prop_image_layer_items[] = { @@ -1037,12 +1190,17 @@ static EnumPropertyItem node_glossy_items[] = { {0, NULL, 0, NULL, NULL} }; +static EnumPropertyItem node_script_mode_items[] = { + {NODE_SCRIPT_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text datablock"}, + {NODE_SCRIPT_EXTERNAL, "EXTERNAL", 0, "External", "Use external .osl or .oso file"}, + {0, NULL, 0, NULL, NULL} +}; + #define MaxNodes 50000 enum { Category_GroupNode, - Category_LoopNode, Category_LayoutNode, Category_ShaderNode, Category_CompositorNode, @@ -1063,7 +1221,7 @@ typedef struct NodeInfo { static NodeInfo nodes[MaxNodes]; static void reg_node(int ID, int category, const char *enum_name, const char *struct_name, - const char *base_name, const char *ui_name, const char *ui_desc) + const char *base_name, const char *ui_name, const char *ui_desc) { NodeInfo *ni = nodes + ID; @@ -1086,8 +1244,6 @@ static void init(void) #include "rna_nodetree_types.h" reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "SpecialNode", "Group", ""); - reg_node(NODE_FORLOOP, Category_LoopNode, "FORLOOP", "NodeForLoop", "SpecialNode", "ForLoop", ""); - reg_node(NODE_WHILELOOP, Category_LoopNode, "WHILELOOP", "NodeWhileLoop", "SpecialNode", "WhileLoop", ""); reg_node(NODE_FRAME, Category_LayoutNode, "FRAME", "NodeFrame", "SpecialNode", "Frame", ""); reg_node(NODE_REROUTE, Category_LayoutNode, "REROUTE", "NodeReroute", "SpecialNode", "Reroute", ""); } @@ -1145,6 +1301,14 @@ static void alloc_node_type_items(EnumPropertyItem *items, int category) item++; + item->value = NODE_FRAME; + item->identifier = "FRAME"; + item->icon = 0; + item->name = "Frame"; + item->description = ""; + + item++; + /* NOTE!, increase 'count' when adding items here */ memset(item, 0, sizeof(EnumPropertyItem)); @@ -1166,36 +1330,6 @@ static void def_group(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); } -static void def_forloop(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "NodeTree"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Node Tree", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); -} - -static void def_whileloop(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "NodeTree"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Node Tree", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); - - prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "custom1"); - RNA_def_property_range(prop, 0.0f, SHRT_MAX); - RNA_def_property_ui_text(prop, "Max. Iterations", "Limit for number of iterations"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); -} - static void def_frame(StructRNA *srna) { PropertyRNA *prop; @@ -1462,7 +1596,8 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "turbidity", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Turbidity", ""); + RNA_def_property_range(prop, 1.0f, 30.0f); + RNA_def_property_ui_text(prop, "Turbidity", "Atmospheric turbidity"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -1741,6 +1876,138 @@ static void def_glossy(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_sh_normal_map(StructRNA *srna) +{ + static EnumPropertyItem prop_space_items[] = { + {SHD_NORMAL_MAP_TANGENT, "TANGENT", 0, "Tangent Space", "Tangent space normal mapping"}, + {SHD_NORMAL_MAP_OBJECT, "OBJECT", 0, "Object Space", "Object space normal mapping"}, + {SHD_NORMAL_MAP_WORLD, "WORLD", 0, "World Space", "World space normal mapping"}, + {0, NULL, 0, NULL, NULL} + }; + + PropertyRNA *prop; + + RNA_def_struct_sdna_from(srna, "NodeShaderNormalMap", "storage"); + + prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_space_items); + RNA_def_property_ui_text(prop, "Space", "Space of the input normal"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "uv_map", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "UV Map", "UV Map for tangent space maps"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "bNode", NULL); +} + +static void def_sh_tangent(StructRNA *srna) +{ + static EnumPropertyItem prop_direction_type_items[] = { + {SHD_TANGENT_RADIAL, "RADIAL", 0, "Radial", "Radial tangent around the X, Y or Z axis"}, + {SHD_TANGENT_UVMAP, "UV_MAP", 0, "UV Map", "Tangent from UV map"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem prop_axis_items[] = { + {SHD_TANGENT_AXIS_X, "X", 0, "X", "X axis"}, + {SHD_TANGENT_AXIS_Y, "Y", 0, "Y", "Y axis"}, + {SHD_TANGENT_AXIS_Z, "Z", 0, "Z", "Z axis"}, + {0, NULL, 0, NULL, NULL} + }; + + PropertyRNA *prop; + + RNA_def_struct_sdna_from(srna, "NodeShaderTangent", "storage"); + + prop = RNA_def_property(srna, "direction_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_direction_type_items); + RNA_def_property_ui_text(prop, "Direction", "Method to use for the tangent"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_axis_items); + RNA_def_property_ui_text(prop, "Axis", "Axis for radial tangents"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "uv_map", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "UV Map", "UV Map for tangent generated from UV"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "bNode", NULL); +} + +static void def_sh_script(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop, *parm; + + prop = RNA_def_property(srna, "script", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "Text"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); + RNA_def_property_ui_text(prop, "Script", "Internal shader script to define the shader"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeScript_update"); + + RNA_def_struct_sdna_from(srna, "NodeShaderScript", "storage"); + RNA_def_struct_idprops_func(srna, "rna_ShaderNodeScript_idprops"); + + prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_ui_text(prop, "File Path", "Shader script path"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeScript_update"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_funcs(prop, NULL, "rna_ShaderNodeScript_mode_set", NULL); + RNA_def_property_enum_items(prop, node_script_mode_items); + RNA_def_property_ui_text(prop, "Script Source", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_auto_update", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_SCRIPT_AUTO_UPDATE); + RNA_def_property_ui_text(prop, "Auto Update", + "Automatically update the shader when the .osl file changes (external scripts only)"); + + prop = RNA_def_property(srna, "bytecode", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_ShaderNodeScript_bytecode_get", "rna_ShaderNodeScript_bytecode_length", + "rna_ShaderNodeScript_bytecode_set"); + RNA_def_property_ui_text(prop, "Bytecode", "Compile bytecode for shader script node"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "bytecode_hash", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Bytecode Hash", "Hash of compile bytecode, for quick equality checking"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + /* needs to be reset to avoid bad pointer type in API functions below */ + RNA_def_struct_sdna_from(srna, "bNode", NULL); + + /* API functions */ + + func = RNA_def_function(srna, "find_socket", "rna_ShaderNodeScript_find_socket"); + RNA_def_function_ui_description(func, "Find a socket by name"); + parm = RNA_def_string(func, "name", "", 0, "Socket name", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + /*parm =*/ RNA_def_boolean(func, "is_output", FALSE, "Output", "Whether the socket is an output"); + parm = RNA_def_pointer(func, "result", "NodeSocket", "", ""); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "add_socket", "rna_ShaderNodeScript_add_socket"); + RNA_def_function_ui_description(func, "Add a socket socket"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + parm = RNA_def_string(func, "name", "", 0, "Name", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_enum(func, "type", node_socket_type_items, SOCK_FLOAT, "Type", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + /*parm =*/ RNA_def_boolean(func, "is_output", FALSE, "Output", "Whether the socket is an output"); + parm = RNA_def_pointer(func, "result", "NodeSocket", "", ""); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove_socket", "rna_ShaderNodeScript_remove_socket"); + RNA_def_function_ui_description(func, "Remove a socket socket"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + parm = RNA_def_pointer(func, "sock", "NodeSocket", "Socket", ""); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); +} + /* -- Compositor Nodes ------------------------------------------------------ */ static void def_cmp_alpha_over(StructRNA *srna) @@ -3994,8 +4261,6 @@ static void rna_def_special_node(BlenderRNA *brna) static EnumPropertyItem specific_node_type_items[] = { {NODE_GROUP, "GROUP", ICON_NODE, "Group", ""}, - {NODE_FORLOOP, "FORLOOP", ICON_NODE, "For Loop", ""}, - {NODE_WHILELOOP, "WHILELOOP", ICON_NODE, "While Loop", ""}, {NODE_FRAME, "FRAME", ICON_NODE, "Frame", ""}, {NODE_REROUTE, "REROUTE", ICON_NODE, "Reroute", ""}, {0, NULL, 0, NULL, NULL} @@ -4039,7 +4304,8 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "remove a node link from the node tree"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "link", "NodeLink", "", "The node link to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_NodeTree_link_clear"); RNA_def_function_ui_description(func, "remove all node links from the node tree"); @@ -4083,7 +4349,8 @@ static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a node from this node tree"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "node", "Node", "", "The node to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); @@ -4116,7 +4383,8 @@ static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a node from this node tree"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "node", "Node", "", "The node to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); @@ -4149,7 +4417,8 @@ static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a node from this node tree"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "node", "Node", "", "The node to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); @@ -4291,6 +4560,20 @@ static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype, RNA_def_property_ui_text(prop, "Default Value", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update"); break; + case SOCK_STRING: + RNA_def_struct_sdna_from(srna, "bNodeSocketValueString", "default_value"); + + prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "subtype"); + RNA_def_property_enum_items(prop, subtype_items); + RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update"); + + prop = RNA_def_property(srna, "default_value", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "value"); + RNA_def_property_ui_text(prop, "Default Value", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update"); + break; } /* XXX need to reset the from-type here, so subtype subclasses cast correctly! (RNA bug) */ @@ -4618,8 +4901,6 @@ void RNA_def_nodetree(BlenderRNA *brna) #include "rna_nodetree_types.h" define_specific_node(brna, NODE_GROUP, def_group); - define_specific_node(brna, NODE_FORLOOP, def_forloop); - define_specific_node(brna, NODE_WHILELOOP, def_whileloop); define_specific_node(brna, NODE_FRAME, def_frame); define_specific_node(brna, NODE_REROUTE, 0); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index db1e1e16adf..fbbcbae6c12 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -65,11 +65,14 @@ DefNode( ShaderNode, SH_NODE_LAYER_WEIGHT, 0, "LA DefNode( ShaderNode, SH_NODE_MIX_SHADER, 0, "MIX_SHADER", MixShader, "Mix Shader", "" ) DefNode( ShaderNode, SH_NODE_ADD_SHADER, 0, "ADD_SHADER", AddShader, "Add Shader", "" ) DefNode( ShaderNode, SH_NODE_ATTRIBUTE, def_sh_attribute, "ATTRIBUTE", Attribute, "Attribute", "" ) +DefNode( ShaderNode, SH_NODE_AMBIENT_OCCLUSION, 0, "AMBIENT_OCCLUSION", AmbientOcclusion, "Ambient Occlusion", "" ) DefNode( ShaderNode, SH_NODE_BACKGROUND, 0, "BACKGROUND", Background, "Background", "" ) DefNode( ShaderNode, SH_NODE_HOLDOUT, 0, "HOLDOUT", Holdout, "Holdout", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_ANISOTROPIC, 0, "BSDF_ANISOTROPIC", BsdfAnisotropic, "Anisotropic Bsdf", "" ) DefNode( ShaderNode, SH_NODE_BSDF_DIFFUSE, 0, "BSDF_DIFFUSE", BsdfDiffuse, "Diffuse Bsdf", "" ) DefNode( ShaderNode, SH_NODE_BSDF_GLOSSY, def_glossy, "BSDF_GLOSSY", BsdfGlossy, "Glossy Bsdf", "" ) DefNode( ShaderNode, SH_NODE_BSDF_GLASS, def_glossy, "BSDF_GLASS", BsdfGlass, "Glass Bsdf", "" ) +DefNode( ShaderNode, SH_NODE_BSDF_REFRACTION, def_glossy, "BSDF_REFRACTION", BsdfRefraction, "Refraction Bsdf", "" ) DefNode( ShaderNode, SH_NODE_BSDF_TRANSLUCENT, 0, "BSDF_TRANSLUCENT", BsdfTranslucent, "Translucent Bsdf", "" ) DefNode( ShaderNode, SH_NODE_BSDF_TRANSPARENT, 0, "BSDF_TRANSPARENT", BsdfTransparent, "Transparent Bsdf", "" ) DefNode( ShaderNode, SH_NODE_BSDF_VELVET, 0, "BSDF_VELVET", BsdfVelvet, "Velvet Bsdf", "" ) @@ -81,6 +84,10 @@ DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LI DefNode( ShaderNode, SH_NODE_LIGHT_FALLOFF, 0, "LIGHT_FALLOFF", LightFalloff, "Light Falloff", "" ) DefNode( ShaderNode, SH_NODE_OBJECT_INFO, 0, "OBJECT_INFO", ObjectInfo, "Object Info", "" ) DefNode( ShaderNode, SH_NODE_PARTICLE_INFO, 0, "PARTICLE_INFO", ParticleInfo, "Particle Info", "" ) +DefNode( ShaderNode, SH_NODE_BUMP, 0, "BUMP", Bump, "Bump", "" ) +DefNode( ShaderNode, SH_NODE_NORMAL_MAP, def_sh_normal_map, "NORMAL_MAP", NormalMap, "Normal Map", "" ) +DefNode( ShaderNode, SH_NODE_TANGENT, def_sh_tangent, "TANGENT", Tangent, "Tangent", "" ) +DefNode( ShaderNode, SH_NODE_SCRIPT, def_sh_script, "SCRIPT", Script, "Script", "" ) DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture","" ) DefNode( ShaderNode, SH_NODE_TEX_SKY, def_sh_tex_sky, "TEX_SKY", TexSky, "Sky Texture", "" ) @@ -91,7 +98,7 @@ DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TE DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" ) -DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" ) +DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TEX_COORD", TexCoord, "Texture Coordinate","" ) DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 0b8afef0364..d436e4719ea 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -506,7 +506,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) ob->dup_group = grp; else BKE_report(NULL, RPT_ERROR, - "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle"); + "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle"); } static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) @@ -547,8 +547,7 @@ static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min Object *ob = (Object *)ptr->id.data; *min = 0; - *max = BLI_countlist(&ob->defbase) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&ob->defbase) - 1); } void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index) @@ -658,7 +657,7 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in { Object *ob = (Object *)ptr->id.data; *min = 0; - *max = MAX2(ob->totcol - 1, 0); + *max = max_ii(ob->totcol - 1, 0); } /* returns active base material */ @@ -684,8 +683,7 @@ static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int * { Object *ob = (Object *)ptr->id.data; *min = 0; - *max = BLI_countlist(&ob->particlesystem) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1); } static int rna_Object_active_particle_system_index_get(PointerRNA *ptr) @@ -851,11 +849,11 @@ static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value) if (value) { ob->matbits[index] = 1; - /* ob->colbits |= (1<<index); */ /* DEPRECATED */ + /* ob->colbits |= (1 << index); */ /* DEPRECATED */ } else { ob->matbits[index] = 0; - /* ob->colbits &= ~(1<<index); */ /* DEPRECATED */ + /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */ } } @@ -1036,8 +1034,8 @@ static unsigned int rna_Object_layer_validate__internal(const int *values, unsig return 0; for (i = 0; i < 20; i++) { - if (values[i]) lay |= (1 << i); - else lay &= ~(1 << i); + if (values[i]) lay |= (1 << i); + else lay &= ~(1 << i); } return lay; @@ -1072,8 +1070,9 @@ static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values) int all_states = (ob->scaflag & OB_ALLSTATE ? 1 : 0); memset(values, 0, sizeof(int) * OB_MAX_STATES); - for (i = 0; i < OB_MAX_STATES; i++) + for (i = 0; i < OB_MAX_STATES; i++) { values[i] = (ob->state & (1 << i)) | all_states; + } } static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values) @@ -1111,6 +1110,65 @@ static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values) } } +static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values) +{ + Object *ob = (Object*)ptr->data; + int i; + + for (i = 0; i < OB_MAX_COL_MASKS; i++) { + values[i] = (ob->col_group & (1 << i)); + } +} + +static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values) +{ + Object *ob = (Object*)ptr->data; + int i, tot = 0; + + /* ensure we always have some group selected */ + for (i = 0; i < OB_MAX_COL_MASKS; i++) + if (values[i]) + tot++; + + if (tot == 0) + return; + + for (i = 0; i < OB_MAX_COL_MASKS; i++) { + if (values[i]) ob->col_group |= (1 << i); + else ob->col_group &= ~(1 << i); + } +} + +static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values) +{ + Object *ob = (Object*)ptr->data; + int i; + + for (i = 0; i < OB_MAX_COL_MASKS; i++) { + values[i] = (ob->col_mask & (1 << i)); + } +} + +static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values) +{ + Object *ob = (Object*)ptr->data; + int i, tot = 0; + + /* ensure we always have some mask selected */ + for (i = 0; i < OB_MAX_COL_MASKS; i++) + if (values[i]) + tot++; + + if (tot == 0) + return; + + for (i = 0; i < OB_MAX_COL_MASKS; i++) { + if (values[i]) ob->col_mask |= (1 << i); + else ob->col_mask &= ~(1 << i); + } +} + + static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) { Object *ob = (Object *)ptr->id.data; @@ -1199,14 +1257,17 @@ static bConstraint *rna_Object_constraints_new(Object *object, int type) return add_ob_constraint(object, NULL, type); } -static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con) +static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr) { + bConstraint *con = con_ptr->data; if (BLI_findindex(&object->constraints, con) == -1) { BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2); return; } remove_constraint(&object->constraints, con); + RNA_POINTER_INVALIDATE(con_ptr); + ED_object_constraint_update(object); ED_object_constraint_set_active(object, NULL); WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object); @@ -1228,9 +1289,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); } -static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md) +static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr) { - ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md); + ModifierData *md = md_ptr->data; + if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) == FALSE) { + /* error is already set */ + return; + } + + RNA_POINTER_INVALIDATE(md_ptr); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object); } @@ -1264,9 +1331,16 @@ static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name) return defgroup; } -static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) +static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr) { + bDeformGroup *defgroup = defgroup_ptr->data; + if (BLI_findindex(&ob->defbase, defgroup) == -1) { + BKE_reportf(reports, RPT_ERROR, "DeformGroup '%s' not in object '%s'", defgroup->name, ob->id.name + 2); + return; + } + ED_vgroup_delete(ob, defgroup); + RNA_POINTER_INVALIDATE(defgroup_ptr); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); } @@ -1284,7 +1358,7 @@ static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *re Object *ob = (Object *)id; if (ED_vgroup_object_is_edit_mode(ob)) { - BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode"); + BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode"); return; } @@ -1299,7 +1373,7 @@ static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList * Object *ob = (Object *)id; if (ED_vgroup_object_is_edit_mode(ob)) { - BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode"); + BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode"); return; } @@ -1314,7 +1388,7 @@ static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *report float weight = ED_vgroup_vert_weight((Object *)id, dg, index); if (weight < 0) { - BKE_reportf(reports, RPT_ERROR, "Vertex not in group"); + BKE_report(reports, RPT_ERROR, "Vertex not in group"); } return weight; } @@ -1345,6 +1419,12 @@ int rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) return ((Object *)value.id.data)->type == OB_CAMERA; } +int rna_DupliObject_index_get(PointerRNA *ptr) +{ + DupliObject *dob = (DupliObject *)ptr->data; + return dob->persistent_id[0]; +} + #else static int rna_matrix_dimsize_4x4[] = {4, 4}; @@ -1578,6 +1658,17 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall"); + prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1); + RNA_def_property_array(prop, OB_MAX_COL_MASKS); + RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object"); + RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set"); + + prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1); + RNA_def_property_array(prop, OB_MAX_COL_MASKS); + RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with"); + RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set"); /* lock position */ prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE); @@ -1745,7 +1836,8 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); /* constraint to remove */ parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear"); RNA_def_function_ui_description(func, "Remove all constraint from this object"); @@ -1796,7 +1888,8 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove an existing modifier from the object"); /* modifier to remove */ parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* clear all modifiers */ func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); @@ -1874,9 +1967,11 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Delete vertex group from object"); parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear"); RNA_def_function_ui_description(func, "Delete all vertex groups from object"); @@ -2564,22 +2659,23 @@ static void rna_def_dupli_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render"); prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "index"); + RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list"); - - prop = RNA_def_property(srna, "particle_index", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "particle_index"); + + prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur"); + + prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Particle Index", "Index in the lowest-level particle dupli list"); + RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from"); prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_float_sdna(prop, NULL, "orco"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space"); prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "uv"); RNA_def_property_array(prop, 2); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 879a77527cd..87fc3be28a2 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -74,7 +74,7 @@ /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 0 - preview, 1 - render */ -Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings) +static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings) { Mesh *tmpmesh; Curve *tmpcu = NULL, *copycu; @@ -158,7 +158,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked */ if (tmpobj->type != OB_MESH) { BKE_libblock_free_us(&(G.main->object), tmpobj); - BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?"); + BKE_report(reports, RPT_ERROR, "Cannot convert curve to mesh (does the curve have any segments?)"); return NULL; } @@ -321,7 +321,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e } } - if (level == 0 && enable) { + if (enable) { /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ @@ -340,7 +340,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e dupli_render_particle_set(scene, go->ob, level + 1, enable); } /* When no longer needed, duplilist should be freed with Object.free_duplilist */ -void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) +static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) { int for_render = settings == eModifierMode_Render; @@ -351,7 +351,7 @@ void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, in /* free duplilist if a user forgets to */ if (ob->duplilist) { - BKE_reportf(reports, RPT_WARNING, "Object.dupli_list has not been freed"); + BKE_report(reports, RPT_WARNING, "Object.dupli_list has not been freed"); free_object_duplilist(ob->duplilist); ob->duplilist = NULL; @@ -364,7 +364,7 @@ void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, in /* ob->duplilist should now be freed with Object.free_duplilist */ } -void rna_Object_free_duplilist(Object *ob) +static void rna_Object_free_duplilist(Object *ob) { if (ob->duplilist) { free_object_duplilist(ob->duplilist); @@ -387,7 +387,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList * return keyptr; } else { - BKE_reportf(reports, RPT_ERROR, "Object \"%s\"does not support shapes", ob->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' does not support shapes", ob->id.name + 2); return PointerRNA_NULL; } } @@ -402,14 +402,14 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int float weight, int assignmode) { if (ob->type != OB_MESH) { - BKE_report(reports, RPT_ERROR, "Object should be of MESH type"); + BKE_report(reports, RPT_ERROR, "Object should be of mesh type"); return; } Mesh *me = (Mesh *)ob->data; int group_index = BLI_findlink(&ob->defbase, group); if (group_index == -1) { - BKE_report(reports, RPT_ERROR, "No deform groups assigned to mesh"); + BKE_report(reports, RPT_ERROR, "No vertex groups assigned to mesh"); return; } @@ -441,7 +441,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start BVHTreeFromMesh treeData = {NULL}; if (ob->derivedFinal == NULL) { - BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for ray casting", ob->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for ray casting", ob->id.name + 2); return; } @@ -449,7 +449,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6); if (treeData.tree == NULL) { - BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for ray casting", ob->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for ray casting", ob->id.name + 2); return; } else { @@ -483,7 +483,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl BVHTreeFromMesh treeData = {NULL}; if (ob->derivedFinal == NULL) { - BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for finding nearest point", + BKE_reportf(reports, RPT_ERROR, "Object '%s' has no mesh data to be used for finding nearest point", ob->id.name + 2); return; } @@ -492,7 +492,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6); if (treeData.tree == NULL) { - BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for finding nearest point", + BKE_reportf(reports, RPT_ERROR, "Object '%s' could not create internal data for finding nearest point", ob->id.name + 2); return; } @@ -522,12 +522,12 @@ static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) base->lay = base->object->lay = v3d->lay; } -int rna_Object_is_modified(Object *ob, Scene *scene, int settings) +static int rna_Object_is_modified(Object *ob, Scene *scene, int settings) { return BKE_object_is_modified(scene, ob) & settings; } -int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) +static int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) { return BKE_object_is_deform_modified(scene, ob) & settings; } @@ -613,7 +613,7 @@ void RNA_api_object(StructRNA *srna) "objects real matrix and layers"); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate duplis"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); - parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Generate texture coordinates for rendering"); + RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Generate texture coordinates for rendering"); RNA_def_function_flag(func, FUNC_USE_REPORTS); func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 1c896133408..6d7187da7d9 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -51,6 +51,9 @@ static EnumPropertyItem effector_shape_items[] = { #ifdef RNA_RUNTIME +#include "BLI_math_base.h" + + /* type specific return values only used from functions */ static EnumPropertyItem curve_shape_items[] = { {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""}, @@ -239,8 +242,7 @@ static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) { - *max = BLI_countlist(pid->ptcaches) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(pid->ptcaches) - 1); break; } } @@ -820,10 +822,13 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_ui_text(prop, "File Path", "Cache file path"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + /* removed, see PTCACHE_QUICK_CACHE */ +#if 0 prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE); RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); +#endif prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "info"); @@ -1056,6 +1061,13 @@ static void rna_def_effector_weight(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3); RNA_def_property_ui_text(prop, "Drag", "Drag effector weight"); RNA_def_property_update(prop, 0, "rna_EffectorWeight_update"); + + prop = RNA_def_property(srna, "smokeflow", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "weight[13]"); + RNA_def_property_range(prop, -200.0f, 200.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3); + RNA_def_property_ui_text(prop, "Smoke Flow", "Smoke Flow effector weight"); + RNA_def_property_update(prop, 0, "rna_EffectorWeight_update"); } static void rna_def_field(BlenderRNA *brna) @@ -1082,6 +1094,7 @@ static void rna_def_field(BlenderRNA *brna) {PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""}, {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", "Create turbulence with a noise field"}, {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", "Create a force that dampens motion"}, + {PFIELD_SMOKEFLOW, "SMOKE_FLOW", ICON_FORCE_SMOKEFLOW, "Smoke Flow", "Create a force based on smoke simulation air flow"}, {0, NULL, 0, NULL, NULL} }; @@ -1307,7 +1320,7 @@ static void rna_def_field(BlenderRNA *brna) prop = RNA_def_property(srna, "use_2d_force", 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_ui_text(prop, "2D", "Apply force only in 2D"); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop = RNA_def_property(srna, "use_root_coords", PROP_BOOLEAN, PROP_NONE); @@ -1334,6 +1347,11 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_MULTIPLE_SPRINGS); RNA_def_property_ui_text(prop, "Multiple Springs", "Every point is effected by multiple springs"); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); + + prop = RNA_def_property(srna, "use_smoke_density", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_SMOKE_DENSITY); + RNA_def_property_ui_text(prop, "Apply Density", "Adjust force strength based on smoke density"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); /* Pointer */ @@ -1342,6 +1360,12 @@ static void rna_def_field(BlenderRNA *brna) 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"); + + prop = RNA_def_property(srna, "source_object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "f_source"); + RNA_def_property_ui_text(prop, "Domain Object", "Select domain object of the smoke simulation"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); /********** Curve Guide Field Settings **********/ diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 89638389fd2..6825d3d781d 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -530,8 +530,7 @@ static void rna_ParticleSystem_active_particle_target_index_range(PointerRNA *pt { ParticleSystem *psys = (ParticleSystem *)ptr->data; *min = 0; - *max = BLI_countlist(&psys->targets) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&psys->targets) - 1); } static int rna_ParticleSystem_active_particle_target_index_get(PointerRNA *ptr) @@ -670,8 +669,7 @@ static void rna_ParticleDupliWeight_active_index_range(PointerRNA *ptr, int *min { ParticleSettings *part = (ParticleSettings *)ptr->id.data; *min = 0; - *max = BLI_countlist(&part->dupliweights) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&part->dupliweights) - 1); } static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr) @@ -823,12 +821,12 @@ static void psys_vg_name_set__internal(PointerRNA *ptr, const char *value, int i psys->vgroup[index] = 0; } else { - int vgroup_num = defgroup_name_index(ob, value); + int defgrp_index = defgroup_name_index(ob, value); - if (vgroup_num == -1) + if (defgrp_index == -1) return; - psys->vgroup[index] = vgroup_num + 1; + psys->vgroup[index] = defgrp_index + 1; } } diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index df278e7cf16..412aad20a41 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -381,13 +381,7 @@ static void rna_PoseChannel_bone_group_index_range(PointerRNA *ptr, int *min, in bPose *pose = (ob) ? ob->pose : NULL; *min = 0; - - if (pose) { - *max = BLI_countlist(&pose->agroups) - 1; - *max = MAX2(0, *max); - } - else - *max = 0; + *max = pose ? max_ii(0, BLI_countlist(&pose->agroups) - 1) : 0; } static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr) @@ -419,8 +413,7 @@ static void rna_Pose_active_bone_group_index_range(PointerRNA *ptr, int *min, in bPose *pose = (bPose *)ptr->data; *min = 0; - *max = BLI_countlist(&pose->agroups) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&pose->agroups) - 1); } #if 0 @@ -497,24 +490,28 @@ static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, int typ return add_pose_constraint(NULL, pchan, NULL, type); } -static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, bConstraint *con) +static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, ReportList *reports, PointerRNA *con_ptr) { + bConstraint *con = con_ptr->data; + const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK); + Object *ob = (Object *)id; + if (BLI_findindex(&pchan->constraints, con) == -1) { BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in pose bone '%s'", con->name, pchan->name); return; } - else { - Object *ob = (Object *)id; - const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK); - remove_constraint(&pchan->constraints, con); - ED_object_constraint_update(ob); - constraints_set_active(&pchan->constraints, NULL); - WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id); + remove_constraint(&pchan->constraints, con); + RNA_POINTER_INVALIDATE(con_ptr); - if (is_ik) { - BIK_clear_data(ob->pose); - } + ED_object_constraint_update(ob); + + constraints_set_active(&pchan->constraints, NULL); /* XXX, is this really needed? - Campbell */ + + WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, id); + + if (is_ik) { + BIK_clear_data(ob->pose); } } @@ -727,7 +724,8 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); /* ID needed for refresh */ /* constraint to remove */ parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } static void rna_def_pose_channel(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 039d50e4ee8..46b22cd0963 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -50,12 +50,12 @@ /* RenderEngine Callbacks */ -void engine_tag_redraw(RenderEngine *engine) +static void engine_tag_redraw(RenderEngine *engine) { engine->flag |= RE_ENGINE_DO_DRAW; } -void engine_tag_update(RenderEngine *engine) +static void engine_tag_update(RenderEngine *engine) { engine->flag |= RE_ENGINE_DO_UPDATE; } @@ -129,6 +129,24 @@ static void engine_view_draw(RenderEngine *engine, const struct bContext *contex RNA_parameter_list_free(&list); } +static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node) +{ + extern FunctionRNA rna_RenderEngine_update_script_node_func; + PointerRNA ptr, nodeptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr); + RNA_pointer_create((ID*)ntree, &RNA_Node, node, &nodeptr); + func = &rna_RenderEngine_update_script_node_func; + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "node", &nodeptr); + engine->type->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_list_free(&list); +} + /* RenderEngine registration */ static void rna_RenderEngine_unregister(Main *UNUSED(bmain), StructRNA *type) @@ -149,7 +167,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo RenderEngineType *et, dummyet = {NULL}; RenderEngine dummyengine = {NULL}; PointerRNA dummyptr; - int have_function[4]; + int have_function[5]; /* setup dummy engine & engine type to store static properties in */ dummyengine.type = &dummyet; @@ -160,7 +178,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo return NULL; if (strlen(identifier) >= sizeof(dummyet.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering render engine class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyet.idname)); return NULL; } @@ -188,6 +206,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo et->render = (have_function[1]) ? engine_render : NULL; et->view_update = (have_function[2]) ? engine_view_update : NULL; et->view_draw = (have_function[3]) ? engine_view_draw : NULL; + et->update_script_node = (have_function[4]) ? engine_update_script_node : NULL; BLI_addtail(&R_engines, et); @@ -300,6 +319,13 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); RNA_def_pointer(func, "context", "Context", "", ""); + /* shader script callbacks */ + func = RNA_def_function(srna, "update_script_node", NULL); + RNA_def_function_ui_description(func, "Compile shader script node"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); + prop = RNA_def_pointer(func, "node", "Node", "", ""); + RNA_def_property_flag(prop, PROP_RNAPTR); + /* tag for redraw */ RNA_def_function(srna, "tag_redraw", "engine_tag_redraw"); RNA_def_function_ui_description(func, "Request redraw for viewport rendering"); @@ -328,7 +354,7 @@ static void rna_def_render_engine(BlenderRNA *brna) func = RNA_def_function(srna, "end_result", "RE_engine_end_result"); prop = RNA_def_pointer(func, "result", "RenderResult", "Result", ""); RNA_def_property_flag(prop, PROP_REQUIRED); - prop = RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results"); + RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results"); func = RNA_def_function(srna, "test_break", "RE_engine_test_break"); prop = RNA_def_boolean(func, "do_break", 0, "Break", ""); @@ -344,6 +370,11 @@ static void rna_def_render_engine(BlenderRNA *brna) prop = RNA_def_float(func, "progress", 0, 0.0f, 1.0f, "", "Percentage of render that's done", 0.0f, 1.0f); RNA_def_property_flag(prop, PROP_REQUIRED); + func = RNA_def_function(srna, "update_memory_stats", "RE_engine_update_memory_stats"); + RNA_def_float(func, "memory_used", 0, 0.0f, FLT_MAX, "", "Current memory usage in megabytes", 0.0f, FLT_MAX); + RNA_def_float(func, "memory_peak", 0, 0.0f, FLT_MAX, "", "Peak memory usage in megabytes", 0.0f, FLT_MAX); + RNA_def_property_flag(prop, PROP_REQUIRED); + func = RNA_def_function(srna, "report", "RE_engine_report"); prop = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", ""); RNA_def_property_flag(prop, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index db309ed8f1f..7355e464fc3 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -829,7 +829,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point int totitem, free = 0; rna_idproperty_check(&prop, ptr); - /* eprop= (EnumPropertyRNA *)prop; */ + /* eprop = (EnumPropertyRNA *)prop; */ RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free); rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ada41bb9818..0ba15193985 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -276,6 +276,7 @@ EnumPropertyItem image_color_mode_items[] = { EnumPropertyItem image_color_depth_items[] = { /* 1 (monochrome) not used */ {R_IMF_CHAN_DEPTH_8, "8", 0, "8", "8 bit color channels"}, + {R_IMF_CHAN_DEPTH_10, "10", 0, "10", "10 bit color channels"}, {R_IMF_CHAN_DEPTH_12, "12", 0, "12", "12 bit color channels"}, {R_IMF_CHAN_DEPTH_16, "16", 0, "16", "16 bit color channels"}, /* 24 not used */ @@ -357,7 +358,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report Base *base; if (BKE_scene_base_find(scene, ob)) { - BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\"", ob->id.name + 2, scene->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' is already in scene '%s'", ob->id.name + 2, scene->id.name + 2); return NULL; } @@ -389,7 +390,7 @@ static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *o return; } if (base == scene->basact && ob->mode != OB_MODE_OBJECT) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in 'Object Mode' to unlink", ob->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in object mode to unlink", ob->id.name + 2); return; } if (scene->basact == base) { @@ -714,6 +715,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) R_IMF_CHAN_DEPTH_24, R_IMF_CHAN_DEPTH_16, R_IMF_CHAN_DEPTH_12, + R_IMF_CHAN_DEPTH_10, R_IMF_CHAN_DEPTH_8, R_IMF_CHAN_DEPTH_1, 0}; @@ -811,9 +813,10 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, const int is_float = ELEM3(imf->imtype, R_IMF_IMTYPE_RADHDR, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER); EnumPropertyItem *item_8bit = &image_color_depth_items[0]; - EnumPropertyItem *item_12bit = &image_color_depth_items[1]; - EnumPropertyItem *item_16bit = &image_color_depth_items[2]; - EnumPropertyItem *item_32bit = &image_color_depth_items[3]; + EnumPropertyItem *item_10bit = &image_color_depth_items[1]; + EnumPropertyItem *item_12bit = &image_color_depth_items[2]; + EnumPropertyItem *item_16bit = &image_color_depth_items[3]; + EnumPropertyItem *item_32bit = &image_color_depth_items[4]; int totitem = 0; EnumPropertyItem *item = NULL; @@ -823,6 +826,10 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, RNA_enum_item_add(&item, &totitem, item_8bit); } + if (depth_ok & R_IMF_CHAN_DEPTH_10) { + RNA_enum_item_add(&item, &totitem, item_10bit); + } + if (depth_ok & R_IMF_CHAN_DEPTH_12) { RNA_enum_item_add(&item, &totitem, item_12bit); } @@ -995,8 +1002,7 @@ static void rna_RenderSettings_active_layer_index_range(PointerRNA *ptr, int *mi RenderData *rd = (RenderData *)ptr->data; *min = 0; - *max = BLI_countlist(&rd->layers) - 1; - *max = MAX2(0, *max); + *max = max_ii(0, BLI_countlist(&rd->layers) - 1); } static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr) @@ -1026,17 +1032,20 @@ static SceneRenderLayer *rna_RenderLayer_new(ID *id, RenderData *UNUSED(rd), con } static void rna_RenderLayer_remove(ID *id, RenderData *UNUSED(rd), Main *bmain, ReportList *reports, - SceneRenderLayer *srl) + PointerRNA *srl_ptr) { + SceneRenderLayer *srl = srl_ptr->data; Scene *scene = (Scene *)id; if (!BKE_scene_remove_render_layer(bmain, scene, srl)) { - BKE_reportf(reports, RPT_ERROR, "RenderLayer '%s' could not be removed from scene '%s'", + BKE_reportf(reports, RPT_ERROR, "Render layer '%s' could not be removed from scene '%s'", srl->name, scene->id.name + 2); + return; } - else { - WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); - } + + RNA_POINTER_INVALIDATE(srl_ptr); + + WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) @@ -1209,9 +1218,12 @@ static void object_simplify_update(Object *ob) ModifierData *md; ParticleSystem *psys; - for (md = ob->modifiers.first; md; md = md->next) - if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) - ob->recalc |= OB_RECALC_DATA | PSYS_RECALC_CHILD; + for (md = ob->modifiers.first; md; md = md->next) { + if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) { + ob->recalc |= PSYS_RECALC_CHILD; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } for (psys = ob->particlesystem.first; psys; psys = psys->next) psys->recalc |= PSYS_RECALC_CHILD; @@ -1242,6 +1254,12 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr rna_Scene_use_simplify_update(bmain, scene, ptr); } +static void rna_Scene_use_persistent_data_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) +{ + if (!(scene->r.mode & R_PERSISTENT_DATA)) + RE_FreePersistentData(); +} + static int rna_Scene_use_audio_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->data; @@ -1323,15 +1341,16 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) return marker; } -static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *marker) +static void rna_TimeLine_remove(Scene *scene, ReportList *reports, PointerRNA *marker_ptr) { - if (!BLI_remlink_safe(&scene->markers, marker)) { - BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in scene '%s'", marker->name, scene->id.name + 2); + TimeMarker *marker = marker_ptr->data; + if (BLI_remlink_safe(&scene->markers, marker) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in scene '%s'", marker->name, scene->id.name + 2); return; } - /* XXX, invalidates PyObject */ MEM_freeN(marker); + RNA_POINTER_INVALIDATE(marker_ptr); WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL); WM_main_add_notifier(NC_ANIMATION | ND_MARKERS, NULL); @@ -1357,7 +1376,7 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons return ks; } else { - BKE_report(reports, RPT_ERROR, "Keying Set could not be added"); + BKE_report(reports, RPT_ERROR, "Keying set could not be added"); return NULL; } } @@ -1404,6 +1423,12 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po DAG_id_tag_update(&camera->id, 0); } +static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + BKE_sequencer_cache_cleanup(); + BKE_sequencer_preprocessed_cache_cleanup(); +} + #else static void rna_def_transform_orientation(BlenderRNA *brna) @@ -2809,7 +2834,8 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a render layer"); RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS | FUNC_USE_SELF_ID); parm = RNA_def_pointer(func, "layer", "SceneRenderLayer", "", "Timeline marker to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } /* use for render output and image save operator, @@ -2901,7 +2927,6 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) #endif - #ifdef WITH_OPENJPEG /* Jpeg 2000 */ prop = RNA_def_property(srna, "use_jpeg2k_ycc", PROP_BOOLEAN, PROP_NONE); @@ -2923,7 +2948,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) /* Cineon and DPX */ prop = RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_CINEON_LOG); + RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_IMF_CINEON_FLAG_LOG); RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); @@ -3388,16 +3413,16 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "xparts"); - RNA_def_property_range(prop, 1, 512); - RNA_def_property_ui_text(prop, "Parts X", "Number of horizontal tiles to use while rendering"); + prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "tilex"); + RNA_def_property_range(prop, 8, 10000); + RNA_def_property_ui_text(prop, "Tile X", "Horizontal tile size to use while rendering"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "parts_y", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "yparts"); - RNA_def_property_range(prop, 1, 512); - RNA_def_property_ui_text(prop, "Parts Y", "Number of vertical tiles to use while rendering"); + prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "tiley"); + RNA_def_property_range(prop, 8, 10000); + RNA_def_property_ui_text(prop, "Tile Y", "Vertical tile size to use while rendering"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); @@ -3613,14 +3638,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR); RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "mblur_samples"); RNA_def_property_range(prop, 1, 32); RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "blurfac"); @@ -3628,7 +3653,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.01, 2.0f, 1, 0); RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); /* border */ prop = RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE); @@ -3943,15 +3968,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_PREV); RNA_def_property_ui_text(prop, "Sequencer OpenGL", ""); +#if 0 /* see R_SEQ_GL_REND comment */ prop = RNA_def_property(srna, "use_sequencer_gl_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_REND); RNA_def_property_ui_text(prop, "Sequencer OpenGL", ""); - +#endif prop = RNA_def_property(srna, "sequencer_gl_preview", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "seq_prev_type"); RNA_def_property_enum_items(prop, viewport_shade_items); RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update"); prop = RNA_def_property(srna, "sequencer_gl_render", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "seq_rend_type"); @@ -4028,6 +4055,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE); RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated"); + /* persistent data */ + prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA); + RNA_def_property_ui_text(prop, "Persistent Data", "Keep render data around for faster re-renders"); + RNA_def_property_update(prop, 0, "rna_Scene_use_persistent_data_update"); + /* Scene API */ RNA_api_scene_render(srna); } @@ -4119,7 +4152,8 @@ static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a timeline marker"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_TimeLine_clear"); RNA_def_function_ui_description(func, "Remove all timeline markers"); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index cdf7ac5e68f..63253153699 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -53,7 +53,7 @@ -void rna_Scene_frame_set(Scene *scene, int frame, float subframe) +static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) { scene->r.cfra = frame; scene->r.subframe = subframe; @@ -89,29 +89,29 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name #include "../../collada/collada.h" static void rna_Scene_collada_export( - Scene *scene, - const char *filepath, - int apply_modifiers, - int export_mesh_type, - - int selected, - int include_children, - int include_armatures, - int deform_bones_only, - - int active_uv_only, - int include_uv_textures, - int include_material_textures, - int use_texture_copies, - - int use_object_instantiation, - int sort_by_name, - int second_life) + Scene *scene, + const char *filepath, + int apply_modifiers, + int export_mesh_type, + + int selected, + int include_children, + int include_armatures, + int deform_bones_only, + + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + + int use_object_instantiation, + int sort_by_name, + int second_life) { - collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected, + collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected, include_children, include_armatures, deform_bones_only, - active_uv_only, include_uv_textures, include_material_textures, - use_texture_copies, use_object_instantiation, sort_by_name, second_life); + active_uv_only, include_uv_textures, include_material_textures, + use_texture_copies, use_object_instantiation, sort_by_name, second_life); } #endif diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 58d676555c1..84e76fae896 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -60,6 +60,8 @@ static EnumPropertyItem particle_edit_hair_brush_items[] = { #include "BKE_particle.h" #include "BKE_depsgraph.h" +#include "BLI_pbvh.h" + #include "ED_particle.h" static EnumPropertyItem particle_edit_disconnected_hair_brush_items[] = { @@ -206,6 +208,21 @@ static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNU } } +static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + Object *ob = (scene->basact) ? scene->basact->object : NULL; + + if (ob) { + Sculpt *sd = scene->toolsettings->sculpt; + ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; + + if (ob->sculpt->pbvh) + pbvh_show_diffuse_color_set(ob->sculpt->pbvh, ob->sculpt->show_diffuse_color); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + } +} + #else static void rna_def_paint(BlenderRNA *brna) @@ -297,6 +314,12 @@ static void rna_def_sculpt(BlenderRNA *brna) "Use only deformation modifiers (temporary disable all " "constructive modifiers except multi-resolution)"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); + + prop = RNA_def_property(srna, "show_diffuse_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SHOW_DIFFUSE); + RNA_def_property_ui_text(prop, "Show Diffuse Color", + "Show diffuse color of object and overlay sculpt mask on top of it"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index d8ca1aea5dd..c2fa64698e4 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -966,18 +966,20 @@ static SequenceModifierData *rna_Sequence_modifier_new(Sequence *seq, bContext * } } -static void rna_Sequence_modifier_remove(Sequence *seq, bContext *C, ReportList *reports, SequenceModifierData *smd) +static void rna_Sequence_modifier_remove(Sequence *seq, bContext *C, ReportList *reports, PointerRNA *smd_ptr) { + SequenceModifierData *smd = smd_ptr->data; Scene *scene = CTX_data_scene(C); - if (BKE_sequence_modifier_remove(seq, smd)) { - BKE_sequence_invalidate_cache_for_modifier(scene, seq); - - WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); - } - else { + if (BKE_sequence_modifier_remove(seq, smd) == FALSE) { BKE_report(reports, RPT_ERROR, "Modifier was not found in the stack"); + return; } + + RNA_POINTER_INVALIDATE(smd_ptr); + BKE_sequence_invalidate_cache_for_modifier(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); } static void rna_Sequence_modifier_clear(Sequence *seq, bContext *C) @@ -1267,7 +1269,8 @@ static void rna_def_sequence_modifiers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove an existing modifier from the sequence"); /* modifier to remove */ parm = RNA_def_pointer(func, "modifier", "SequenceModifier", "", "Modifier to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* clear all modifiers */ func = RNA_def_function(srna, "clear", "rna_Sequence_modifier_clear"); @@ -1685,6 +1688,16 @@ static void rna_def_effect_inputs(StructRNA *srna, int count) #endif } +static void rna_def_color_management(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "strip->colorspace_settings"); + RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings"); + RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings"); +} + static void rna_def_image(BlenderRNA *brna) { StructRNA *srna; @@ -1711,6 +1724,7 @@ static void rna_def_image(BlenderRNA *brna) rna_def_filter_video(srna); rna_def_proxy(srna); rna_def_input(srna); + rna_def_color_management(srna); } static void rna_def_meta(BlenderRNA *brna) @@ -1796,6 +1810,7 @@ static void rna_def_movie(BlenderRNA *brna) rna_def_filter_video(srna); rna_def_proxy(srna); rna_def_input(srna); + rna_def_color_management(srna); } static void rna_def_movieclip(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index f63ef6c8d76..7602ec99c2b 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -89,6 +89,8 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start if (file) { strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem"); BLI_split_dirfile(file, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); + + BKE_sequence_init_colorspace(seq); } else { strip->stripdata = NULL; @@ -234,9 +236,10 @@ static Sequence *rna_Sequences_new_sound(ID *id, Editing *ed, Main *bmain, Repor } #else /* WITH_AUDASPACE */ static Sequence *rna_Sequences_new_sound(ID *UNUSED(id), Editing *UNUSED(ed), Main *UNUSED(bmain), ReportList *reports, - const char *UNUSED(name), const char *UNUSED(file), int UNUSED(channel), int UNUSED(start_frame)) + const char *UNUSED(name), const char *UNUSED(file), int UNUSED(channel), + int UNUSED(start_frame)) { - BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support."); + BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support"); return NULL; } #endif /* WITH_AUDASPACE */ @@ -249,39 +252,37 @@ static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *repor Scene *scene = (Scene *)id; Sequence *seq; struct SeqEffectHandle sh; + int num_inputs = BKE_sequence_effect_get_num_inputs(type); - switch (BKE_sequence_effect_get_num_inputs(type)) { + switch (num_inputs) { case 0: if (end_frame <= start_frame) { - BKE_report(reports, RPT_ERROR, - "Sequences.new_effect: End frame not set"); + BKE_report(reports, RPT_ERROR, "Sequences.new_effect: end frame not set"); return NULL; } break; case 1: if (seq1 == NULL) { - BKE_report(reports, RPT_ERROR, - "Sequences.new_effect: Effect takes 1 input sequence"); + BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 1 input sequence"); return NULL; } break; case 2: if (seq1 == NULL || seq2 == NULL) { - BKE_report(reports, RPT_ERROR, - "Sequences.new_effect: Effect takes 2 input sequences"); + BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 2 input sequences"); return NULL; } break; case 3: if (seq1 == NULL || seq2 == NULL || seq3 == NULL) { - BKE_report(reports, RPT_ERROR, - "Sequences.new_effect: Effect takes 3 input sequences"); + BKE_report(reports, RPT_ERROR, "Sequences.new_effect: effect takes 3 input sequences"); return NULL; } break; default: - BKE_report(reports, RPT_ERROR, - "Sequences.new_effect: BKE_sequence_effect_get_num_inputs() > 3 (should never happen)"); + BKE_reportf(reports, RPT_ERROR, + "Sequences.new_effect: effect expects more than 3 inputs (%d, should never happen!)", + num_inputs); return NULL; } @@ -309,12 +310,18 @@ static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *repor return seq; } -static void rna_Sequences_remove(ID *id, Editing *ed, Sequence *seq) +static void rna_Sequences_remove(ID *id, Editing *ed, ReportList *reports, PointerRNA *seq_ptr) { + Sequence *seq = seq_ptr->data; Scene *scene = (Scene *)id; - BLI_remlink(&ed->seqbase, seq); + if (BLI_remlink_safe(&ed->seqbase, seq) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "Sequence '%s' not in scene '%s'", seq->name + 2, scene->id.name + 2); + return; + } + BKE_sequence_free(scene, seq); + RNA_POINTER_INVALIDATE(seq_ptr); WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); } @@ -342,7 +349,7 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports, StripElem *new_seq, *se; if (seq->len == 1) { - BKE_report(reports, RPT_ERROR, "SequenceElements.pop: can not pop the last element"); + BKE_report(reports, RPT_ERROR, "SequenceElements.pop: cannot pop the last element"); return; } @@ -456,7 +463,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_clip", "rna_Sequences_new_clip"); RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie clip sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to add"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); @@ -472,8 +479,8 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_mask", "rna_Sequences_new_mask"); RNA_def_function_flag(func, FUNC_USE_SELF_ID); - RNA_def_function_ui_description(func, "Add a new movie clip sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_function_ui_description(func, "Add a new mask sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to add"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); @@ -490,7 +497,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene"); RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new scene sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to add"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); @@ -507,7 +514,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_image", "rna_Sequences_new_image"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new image sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to image"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -524,7 +531,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_movie", "rna_Sequences_new_movie"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -540,8 +547,8 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_sound", "rna_Sequences_new_sound"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID | FUNC_USE_MAIN); - RNA_def_function_ui_description(func, "Add a new movie clip sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_function_ui_description(func, "Add a new sound sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -558,7 +565,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new_effect", "rna_Sequences_new_effect"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new effect sequence"); - parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_enum(func, "type", seq_effect_items, 0, "Type", "type for the new sequence"); @@ -569,21 +576,22 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", "The start frame for the new sequence", -MAXFRAME, MAXFRAME); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_int(func, "end_frame", 0, -MAXFRAME, MAXFRAME, "", - "The end frame for the new sequence", -MAXFRAME, MAXFRAME); - parm = RNA_def_pointer(func, "seq1", "Sequence", "", "Sequence 1 for effect"); - parm = RNA_def_pointer(func, "seq2", "Sequence", "", "Sequence 2 for effect"); - parm = RNA_def_pointer(func, "seq3", "Sequence", "", "Sequence 3 for effect"); + RNA_def_int(func, "end_frame", 0, -MAXFRAME, MAXFRAME, "", + "The end frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_pointer(func, "seq1", "Sequence", "", "Sequence 1 for effect"); + RNA_def_pointer(func, "seq2", "Sequence", "", "Sequence 2 for effect"); + RNA_def_pointer(func, "seq3", "Sequence", "", "Sequence 3 for effect"); /* return type */ parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Sequences_remove"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a Sequence"); parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Sequence to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index e8818248609..bdcda79583e 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -65,14 +65,20 @@ static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *p DAG_scene_sort(bmain, scene); } +static void rna_Smoke_resetCache(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; + if (settings->smd && settings->smd->domain) + settings->point_cache[0]->flag |= PTCACHE_OUTDATED; + DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); +} + static void rna_Smoke_reset(Main *bmain, Scene *scene, PointerRNA *ptr) { SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; smokeModifier_reset(settings->smd); - - if (settings->smd && settings->smd->domain) - settings->point_cache[0]->flag |= PTCACHE_OUTDATED; + rna_Smoke_resetCache(bmain, scene, ptr); rna_Smoke_update(bmain, scene, ptr); } @@ -142,6 +148,30 @@ static void rna_SmokeModifier_density_get(PointerRNA *ptr, float *values) memcpy(values, density, size * sizeof(float)); } +static void rna_SmokeFlow_density_vgroup_get(PointerRNA *ptr, char *value) +{ + SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data; + rna_object_vgroup_name_index_get(ptr, value, flow->vgroup_density); +} + +static int rna_SmokeFlow_density_vgroup_length(PointerRNA *ptr) +{ + SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data; + return rna_object_vgroup_name_index_length(ptr, flow->vgroup_density); +} + +static void rna_SmokeFlow_density_vgroup_set(PointerRNA *ptr, const char *value) +{ + SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data; + rna_object_vgroup_name_index_set(ptr, value, &flow->vgroup_density); +} + +static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value) +{ + SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data; + rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name)); +} + #else static void rna_def_smoke_domain_settings(BlenderRNA *brna) @@ -217,7 +247,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Density", "How much density affects smoke motion (higher value results in faster rising smoke)"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "beta"); @@ -225,7 +255,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Heat", "How much heat affects smoke motion (higher value results in faster rising smoke)"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "coll_group"); @@ -253,24 +283,24 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 10.0); RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2); RNA_def_property_ui_text(prop, "Strength", "Strength of noise"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "diss_speed"); RNA_def_property_range(prop, 1.0, 10000.0); RNA_def_property_ui_range(prop, 1.0, 10000.0, 1, 0); RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "use_dissolve_smoke", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE); RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "use_dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG); RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x "); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -297,21 +327,21 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "smooth_emitter", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGH_SMOOTH); RNA_def_property_ui_text(prop, "Smooth Emitter", "Smooth emitted smoke to avoid blockiness"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "time_scale"); RNA_def_property_range(prop, 0.2, 1.5); RNA_def_property_ui_range(prop, 0.2, 1.5, 0.02, 5); RNA_def_property_ui_text(prop, "Time Scale", "Adjust simulation speed"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "vorticity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vorticity"); RNA_def_property_range(prop, 0.01, 4.0); RNA_def_property_ui_range(prop, 0.01, 4.0, 0.02, 5); RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE); RNA_def_property_array(prop, 32); @@ -321,25 +351,81 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_float_funcs(prop, "rna_SmokeModifier_density_get", NULL, NULL); RNA_def_property_ui_text(prop, "Density", "Smoke density"); - prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dx"); + prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */ RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "dx", "Cell Size"); + RNA_def_property_ui_text(prop, "cell_size", "Cell Size"); - prop = RNA_def_property(srna, "start_point", PROP_FLOAT, PROP_XYZ); + prop = RNA_def_property(srna, "start_point", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */ RNA_def_property_float_sdna(prop, NULL, "p0"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "p0", "Start point"); - prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "scale"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "scale", "Domain scale factor"); - - prop = RNA_def_property(srna, "domain_resolution", PROP_INT, PROP_XYZ); + prop = RNA_def_property(srna, "domain_resolution", PROP_INT, PROP_XYZ); /* can change each frame when using adaptive domain */ RNA_def_property_int_sdna(prop, NULL, "res"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "res", "Smoke Grid Resolution"); + + prop = RNA_def_property(srna, "burning_rate", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.01, 4.0); + RNA_def_property_ui_range(prop, 0.01, 2.0, 1.0, 5); + RNA_def_property_ui_text(prop, "Speed", "Speed of the burning reaction (use larger values for smaller flame)"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "flame_smoke", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 8.0); + RNA_def_property_ui_range(prop, 0.0, 4.0, 1.0, 5); + RNA_def_property_ui_text(prop, "Smoke", "Amount of smoke created by burning fuel"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "flame_vorticity", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 2.0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5); + RNA_def_property_ui_text(prop, "Vorticity", "Additional vorticity for the flames"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "flame_ignition", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.5, 5.0); + RNA_def_property_ui_range(prop, 0.5, 2.5, 1.0, 5); + RNA_def_property_ui_text(prop, "Ignition", "Minimum temperature of flames"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "flame_max_temp", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 1.0, 10.0); + RNA_def_property_ui_range(prop, 1.0, 5.0, 1.0, 5); + RNA_def_property_ui_text(prop, "Maximum", "Maximum temperature of flames"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "flame_smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke emitted from burning fuel"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "use_adaptive_domain", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_ADAPTIVE_DOMAIN); + RNA_def_property_ui_text(prop, "Adaptive Domain", "Adapt simulation resolution and size to fluid"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "additional_res", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "adapt_res"); + RNA_def_property_range(prop, 0, 512); + RNA_def_property_ui_range(prop, 0, 512, 2, 0); + RNA_def_property_ui_text(prop, "Additional", "Maximum number of additional cells"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "adapt_margin", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "adapt_margin"); + RNA_def_property_range(prop, 2, 24); + RNA_def_property_ui_range(prop, 2, 24, 2, 0); + RNA_def_property_ui_text(prop, "Margin", "Margin added around fluid to minimize boundary interference"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.01, 0.5); + RNA_def_property_ui_range(prop, 0.01, 0.5, 1.0, 5); + RNA_def_property_ui_text(prop, "Threshold", + "Maximum amount of fluid cell can contain before it is considered empty"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) @@ -347,6 +433,26 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem smoke_flow_types[] = { + {MOD_SMOKE_FLOW_TYPE_OUTFLOW, "OUTFLOW", 0, "Outflow", "Delete smoke from simulation"}, + {MOD_SMOKE_FLOW_TYPE_SMOKE, "SMOKE", 0, "Smoke", "Add smoke"}, + {MOD_SMOKE_FLOW_TYPE_SMOKEFIRE, "BOTH", 0, "Fire + Smoke", "Add fire and smoke"}, + {MOD_SMOKE_FLOW_TYPE_FIRE, "FIRE", 0, "Fire", "Add fire"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem smoke_flow_sources[] = { + {MOD_SMOKE_FLOW_SOURCE_PARTICLES, "PARTICLES", ICON_PARTICLES, "Particle System", "Emit smoke from particles"}, + {MOD_SMOKE_FLOW_SOURCE_MESH, "MESH", ICON_META_CUBE, "Mesh", "Emit smoke from mesh surface or volume"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem smoke_flow_texture_types[] = { + {MOD_SMOKE_FLOW_TEXTURE_MAP_AUTO, "AUTO", 0, "Generated", "Generated coordinates centered to flow object"}, + {MOD_SMOKE_FLOW_TEXTURE_MAP_UV, "UV", 0, "UV", "Use UV layer for texture coordinates"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "SmokeFlowSettings", NULL); RNA_def_struct_ui_text(srna, "Flow Settings", "Smoke flow settings"); RNA_def_struct_sdna(srna, "SmokeFlowSettings"); @@ -354,11 +460,23 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "density"); - RNA_def_property_range(prop, 0.001, 1); - RNA_def_property_ui_range(prop, 0.001, 1.0, 1.0, 4); + RNA_def_property_range(prop, 0.0, 1); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 4); RNA_def_property_ui_text(prop, "Density", ""); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "color"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "fuel_amount", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 10); + RNA_def_property_ui_range(prop, 0.0, 5.0, 1.0, 4); + RNA_def_property_ui_text(prop, "Flame Rate", ""); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "temp"); RNA_def_property_range(prop, -10, 10); @@ -373,9 +491,16 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object"); RNA_def_property_update(prop, 0, "rna_Smoke_reset_dependancy"); - prop = RNA_def_property(srna, "use_outflow", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "type", MOD_SMOKE_FLOW_TYPE_OUTFLOW); - RNA_def_property_ui_text(prop, "Outflow", "Delete smoke from simulation"); + prop = RNA_def_property(srna, "smoke_flow_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, smoke_flow_types); + RNA_def_property_ui_text(prop, "Flow Type", "Change how flow affects the simulation"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "smoke_flow_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "source"); + RNA_def_property_enum_items(prop, smoke_flow_sources); + RNA_def_property_ui_text(prop, "Source", "Change how smoke is emitted"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); prop = RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE); @@ -385,14 +510,82 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "initial_velocity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_INITVELOCITY); - RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke inherits its velocity from the emitter particle"); + RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke has some initial velocity when it is emitted"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vel_multi"); RNA_def_property_range(prop, -2.0, 2.0); RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5); - RNA_def_property_ui_text(prop, "Multiplier", "Multiplier to adjust velocity passed to smoke"); + RNA_def_property_ui_text(prop, "Source", "Multiplier of source velocity passed to smoke"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "velocity_normal", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vel_normal"); + RNA_def_property_range(prop, -2.0, 2.0); + RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5); + RNA_def_property_ui_text(prop, "Normal", "Amount of normal directional velocity"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "velocity_random", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vel_random"); + RNA_def_property_range(prop, 0.0, 2.0); + RNA_def_property_ui_range(prop, 0.0, 2.0, 0.05, 5); + RNA_def_property_ui_text(prop, "Random", "Amount of random velocity"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "volume_density", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.05, 5); + RNA_def_property_ui_text(prop, "Volume", "Factor for smoke emitted from inside the mesh volume"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "surface_distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.5, 10.0); + RNA_def_property_ui_range(prop, 0.5, 5.0, 0.05, 5); + RNA_def_property_ui_text(prop, "Surface", "Maximum distance from mesh surface to emit smoke"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "density_vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_SmokeFlow_density_vgroup_get", + "rna_SmokeFlow_density_vgroup_length", + "rna_SmokeFlow_density_vgroup_set"); + RNA_def_property_ui_text(prop, "Vertex Group", + "Name of vertex group which determines surface emission rate"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_TEXTUREEMIT); + RNA_def_property_ui_text(prop, "Use Texture", "Use a texture to control emission strength"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "texture_map_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "texture_type"); + RNA_def_property_enum_items(prop, smoke_flow_texture_types); + RNA_def_property_ui_text(prop, "Mapping", "Texture mapping type"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); + RNA_def_property_ui_text(prop, "UV Map", "UV map name"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SmokeFlow_uvlayer_set"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "noise_texture", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Texture", "Texture that controls emission strength"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "texture_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.01, 10.0); + RNA_def_property_ui_range(prop, 0.1, 5.0, 0.05, 5); + RNA_def_property_ui_text(prop, "Size", "Size of texture mapping"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + + prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0, 200.0); + RNA_def_property_ui_range(prop, 0.0, 100.0, 0.05, 5); + RNA_def_property_ui_text(prop, "Offset", "Z-offset of texture mapping"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index ff5f4988cc1..962a92223eb 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -336,6 +336,15 @@ static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) copy_v3_v3(cursor, values); } +static float rna_View3D_GridScaleUnit_get(PointerRNA *ptr) +{ + View3D *v3d = (View3D *)(ptr->data); + bScreen *sc = (bScreen *)ptr->id.data; + Scene *scene = (Scene *)sc->scene; + + return ED_view3d_grid_scale(scene, v3d, NULL); +} + static void rna_SpaceView3D_layer_set(PointerRNA *ptr, const int *values) { View3D *v3d = (View3D *)(ptr->data); @@ -949,15 +958,17 @@ static BGpic *rna_BackgroundImage_new(View3D *v3d) return bgpic; } -static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic *bgpic) +static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, PointerRNA *bgpic_ptr) { + BGpic *bgpic = bgpic_ptr->data; if (BLI_findindex(&v3d->bgpicbase, bgpic) == -1) { - BKE_report(reports, RPT_ERROR, "BackgroundImage can't be removed"); - } - else { - ED_view3D_background_image_remove(v3d, bgpic); - WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d); + BKE_report(reports, RPT_ERROR, "Background image cannot be removed"); } + + ED_view3D_background_image_remove(v3d, bgpic); + RNA_POINTER_INVALIDATE(bgpic_ptr); + + WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d); } static void rna_BackgroundImage_clear(View3D *v3d) @@ -1324,7 +1335,7 @@ static void rna_def_background_image(BlenderRNA *brna) srna = RNA_def_struct(brna, "BackgroundImage", NULL); RNA_def_struct_sdna(srna, "BGpic"); - RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3d View background"); + RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3D View background"); prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "source"); @@ -1442,7 +1453,8 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove background image"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "clear", "rna_BackgroundImage_clear"); RNA_def_function_ui_description(func, "Remove all background images"); @@ -1494,7 +1506,39 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Camera", "Active camera used in this view (when unlocked from the scene's active camera)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - + + /* render border */ + prop = RNA_def_property(srna, "use_render_border", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_BORDER); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Render Border", + "Use a user-defined border region within the frame size for rendered viewport"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "render_border_min_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "render_border.xmin"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Border Minimum X", "Minimum X value to for the render border"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "render_border_min_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "render_border.ymin"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Border Minimum Y", "Minimum Y value for the render border"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "render_border_max_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "render_border.xmax"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Border Maximum X", "Maximum X value for the render border"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "render_border_max_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "render_border.ymax"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Border Maximum Y", "Maximum Y value for the render border"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "lock_object", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_sdna(prop, NULL, "ob_centre"); @@ -1533,7 +1577,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "lens"); - RNA_def_property_ui_text(prop, "Lens", "Lens angle (mm) in perspective view"); + RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle (mm)"); RNA_def_property_range(prop, 1.0f, 250.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -1571,7 +1615,12 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_range(prop, 1, 1024); RNA_def_property_int_default(prop, 10); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - + + prop = RNA_def_property(srna, "grid_scale_unit", PROP_FLOAT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_View3D_GridScaleUnit_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Grid Scale Unit", "Grid cell size scaled by scene unit system settings"); + prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_FLOOR); RNA_def_property_ui_text(prop, "Display Grid Floor", "Show the ground plane grid in perspective view"); @@ -2780,6 +2829,12 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_FILE_BLEND, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "use_filter_backup", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE_BACKUP); + RNA_def_property_ui_text(prop, "Filter BlenderBackup files", "Show .blend1, .blend2, etc. files"); + RNA_def_property_ui_icon(prop, ICON_FILE_BACKUP, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "use_filter_movie", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE); RNA_def_property_ui_text(prop, "Filter Movies", "Show movie files"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 45e3d15b9be..e77c5d13a6b 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -71,7 +71,7 @@ EnumPropertyItem texture_type_items[] = { {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""}, {TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", "Procedural - create a fractal noise texture"}, {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", "Procedural - create cell-like patterns based on Worley noise"}, - {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3d texture based on volumetric data"}, + {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3D texture based on volumetric data"}, {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - wave generated bands or rings, with optional noise"}, {TEX_OCEAN, "OCEAN", ICON_TEXTURE, "Ocean", "Use a texture generated by an Ocean modifier"}, {0, NULL, 0, NULL, NULL} @@ -1800,7 +1800,8 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) }; static EnumPropertyItem smoked_type_items[] = { - {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Density", "Use smoke density as texture data"}, + {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Smoke", "Use smoke density and color as texture data"}, + {TEX_VD_SMOKEFLAME, "SMOKEFLAME", 0, "Flame", "Use flame temperature as texture data"}, {TEX_VD_SMOKEHEAT, "SMOKEHEAT", 0, "Heat", "Use smoke heat as texture data. Values from -2.0 to 2.0 are used"}, {TEX_VD_SMOKEVEL, "SMOKEVEL", 0, "Velocity", "Use smoke velocity as texture data"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index a2880510958..5be9d3a0dec 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -120,10 +120,10 @@ void RNA_api_environment_map(StructRNA *srna) RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken"); - RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 0.0f, "File layout", + RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 1000.0f, "File layout", "Flat array describing the X,Y position of each cube face in the " "output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] " - "(use -1 to skip a face)", 0.0f, 0.0f); + "(use -1 to skip a face)", 0.0f, 1000.0f); } #endif diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 0c62a280935..4aefaf991d2 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -35,6 +35,7 @@ #include "BKE_movieclip.h" #include "BKE_tracking.h" +#include "RNA_access.h" #include "RNA_define.h" #include "rna_internal.h" @@ -119,8 +120,7 @@ static void rna_tracking_active_object_index_range(PointerRNA *ptr, int *min, in MovieClip *clip = (MovieClip *)ptr->id.data; *min = 0; - *max = clip->tracking.tot_object - 1; - *max = MAX2(0, *max); + *max = max_ii(0, clip->tracking.tot_object - 1); } static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr) @@ -262,8 +262,7 @@ static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min MovieClip *clip = (MovieClip *)ptr->id.data; *min = 0; - *max = clip->tracking.stabilization.tot_track - 1; - *max = MAX2(0, *max); + *max = max_ii(0, clip->tracking.stabilization.tot_track - 1); } static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) @@ -447,9 +446,15 @@ static MovieTrackingObject *rna_trackingObject_new(MovieTracking *tracking, cons return object; } -static void rna_trackingObject_remove(MovieTracking *tracking, MovieTrackingObject *object) +static void rna_trackingObject_remove(MovieTracking *tracking, ReportList *reports, PointerRNA *object_ptr) { - BKE_tracking_object_delete(tracking, object); + MovieTrackingObject *object = object_ptr->data; + if (BKE_tracking_object_delete(tracking, object) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "MovieTracking '%s' cannot be removed", object->name); + return; + } + + RNA_POINTER_INVALIDATE(object_ptr); WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL); } @@ -567,17 +572,21 @@ static void rna_def_trackingSettings(BlenderRNA *brna) "Limit speed of tracking to make visual feedback easier " "(this does not affect the tracking quality)"); - /* keyframe_a */ - prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE); + /* reconstruction success_threshold */ + prop = RNA_def_property(srna, "reconstruction_success_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "keyframe1"); - RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization"); + RNA_def_property_float_default(prop, 0.001f); + RNA_def_property_range(prop, 0, FLT_MAX); + RNA_def_property_ui_text(prop, "Success Threshold", + "Threshold value of reconstruction error which is still considered successful"); - /* keyframe_b */ - prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE); + /* use fallback reconstruction */ + prop = RNA_def_property(srna, "use_fallback_reconstruction", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "keyframe2"); - RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization"); + RNA_def_property_boolean_sdna(prop, NULL, "reconstruction_flag", TRACKING_USE_FALLBACK_RECONSTRUCTION); + RNA_def_property_ui_text(prop, "Use Fallback", + "Use fallback reconstruction algorithm in cases main reconstruction algorithm failed " + "(could give better solution with bad tracks)"); /* intrinsics refinement during bundle adjustment */ prop = RNA_def_property(srna, "refine_intrinsics", PROP_ENUM, PROP_NONE); @@ -628,7 +637,8 @@ static void rna_def_trackingSettings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_tripod_solver", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "motion_flag", TRACKING_MOTION_TRIPOD); - RNA_def_property_ui_text(prop, "Tripod Motion", "Use special solver to track a stable camera position, such as a tripod"); + RNA_def_property_ui_text(prop, "Tripod Motion", + "Use special solver to track a stable camera position, such as a tripod"); /* default_limit_frames */ prop = RNA_def_property(srna, "default_frames_limit", PROP_INT, PROP_NONE); @@ -668,7 +678,9 @@ static void rna_def_trackingSettings(BlenderRNA *brna) /* default_use_brute */ prop = RNA_def_property(srna, "use_default_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "default_algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK); - RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking"); + RNA_def_property_ui_text(prop, "Use Mask", + "Use a grease pencil datablock as a mask to use only specified areas of pattern " + "when tracking"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); /* default_use_normalization */ @@ -909,8 +921,8 @@ static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_int(func, "frame", 1, MINFRAME, MAXFRAME, "Frame", "Frame number to find marker for", MINFRAME, MAXFRAME); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_boolean(func, "exact", TRUE, "Exact", - "Get marker at exact frame number rather than get estimated marker"); + RNA_def_boolean(func, "exact", TRUE, "Exact", + "Get marker at exact frame number rather than get estimated marker"); parm = RNA_def_pointer(func, "marker", "MovieTrackingMarker", "", "Marker for specified frame"); RNA_def_function_return(func, parm); @@ -1005,7 +1017,9 @@ static void rna_def_trackingTrack(BlenderRNA *brna) /* use_brute */ prop = RNA_def_property(srna, "use_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "algorithm_flag", TRACK_ALGORITHM_FLAG_USE_MASK); - RNA_def_property_ui_text(prop, "Use Mask", "Use a grease pencil datablock as a mask to use only specified areas of pattern when tracking"); + RNA_def_property_ui_text(prop, "Use Mask", + "Use a grease pencil datablock as a mask to use only specified areas of pattern " + "when tracking"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); /* use_normalization */ @@ -1393,6 +1407,18 @@ static void rna_def_trackingObject(BlenderRNA *brna) RNA_def_property_float_default(prop, 1.0f); RNA_def_property_ui_text(prop, "Scale", "Scale of object solution in camera space"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingObject_flushUpdate"); + + /* keyframe_a */ + prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "keyframe1"); + RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization"); + + /* keyframe_b */ + prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "keyframe2"); + RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization"); } static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop) @@ -1416,8 +1442,11 @@ static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_trackingObject_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove tracking object from this movie clip"); - RNA_def_pointer(func, "object", "MovieTrackingObject", "", "Motion tracking object to be removed"); + parm = RNA_def_pointer(func, "object", "MovieTrackingObject", "", "Motion tracking object to be removed"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); /* active object */ prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); @@ -1437,7 +1466,8 @@ static void rna_def_trackingDopesheet(BlenderRNA *brna) {TRACKING_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"}, {TRACKING_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"}, {TRACKING_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"}, - {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", "Sort channels by average reprojection error of tracks after solve"}, + {TRACKING_DOPE_SORT_AVERAGE_ERROR, "AVERAGE_ERROR", 0, "Average Error", + "Sort channels by average reprojection error of tracks after solve"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 70d94bfc7ed..a0a9f6183af 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -85,7 +85,7 @@ static ARegionType *region_type_find(ReportList *reports, int space_type, int re /* region type not found? abort */ if (art == NULL) { - BKE_report(reports, RPT_ERROR, "Region not found in spacetype"); + BKE_report(reports, RPT_ERROR, "Region not found in space type"); return NULL; } @@ -192,7 +192,7 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat return NULL; if (strlen(identifier) >= sizeof(dummypt.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummypt.idname)); return NULL; } @@ -309,7 +309,7 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da return NULL; if (strlen(identifier) >= sizeof(dummyht.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering header class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyht.idname)); return NULL; } @@ -438,7 +438,7 @@ static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data return NULL; if (strlen(identifier) >= sizeof(dummymt.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering menu class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummymt.idname)); return NULL; } diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 006e1ad3903..548539e3395 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -236,41 +236,41 @@ void RNA_api_ui_layout(StructRNA *srna) /* useful in C but not in python */ #if 0 - func= RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string"); + func = RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "value", "", 0, "", "Enum property value"); + parm = RNA_def_string(func, "value", "", 0, "", "Enum property value"); RNA_def_property_flag(parm, PROP_REQUIRED); - func= RNA_def_function(srna, "operator_boolean", "uiItemBooleanO"); + func = RNA_def_function(srna, "operator_boolean", "uiItemBooleanO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with"); + parm = RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with"); RNA_def_property_flag(parm, PROP_REQUIRED); */ - func= RNA_def_function(srna, "operator_int", "uiItemIntO"); + func = RNA_def_function(srna, "operator_int", "uiItemIntO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", + parm = RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", "Value of the property to call the operator with", INT_MIN, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); */ - func= RNA_def_function(srna, "operator_float", "uiItemFloatO"); + func = RNA_def_function(srna, "operator_float", "uiItemFloatO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", + parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", "Value of the property to call the operator with", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); */ - func= RNA_def_function(srna, "operator_string", "uiItemStringO"); + func = RNA_def_function(srna, "operator_string", "uiItemStringO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with"); + parm = RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with"); RNA_def_property_flag(parm, PROP_REQUIRED); #endif @@ -390,7 +390,7 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); - func = RNA_def_function(srna, "template_color_wheel", "uiTemplateColorWheel"); + func = RNA_def_function(srna, "template_color_picker", "uiTemplateColorPicker"); RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors"); api_ui_item_rna_common(func); RNA_def_boolean(func, "value_slider", 0, "", "Display the value slider to the right of the color wheel"); @@ -439,7 +439,8 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_boolean(func, "compact", 0, "", "Use more compact layout"); func = RNA_def_function(srna, "template_list", "uiTemplateList"); - RNA_def_function_ui_description(func, "Item. A list widget to display data. e.g. vertexgroups"); + RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups " + "(WARNING: only one per panel allowed!)."); RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9c989121aa4..3e9f5b44a3d 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -24,9 +24,9 @@ * \ingroup RNA */ - #include <stdlib.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -311,9 +311,16 @@ static bAddon *rna_userdef_addon_new(void) return bext; } -static void rna_userdef_addon_remove(bAddon *bext) +static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *bext_ptr) { + bAddon *bext = bext_ptr->data; + if (BLI_findindex(&U.addons, bext) == -1) { + BKE_report(reports, RPT_ERROR, "Addon is no longer valid"); + return; + } + BLI_freelinkN(&U.addons, bext); + RNA_POINTER_INVALIDATE(bext_ptr); } static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) @@ -388,7 +395,7 @@ static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), P int a; if (devices) { - for (a = 0; devices[a].name; a++) { + for (a = 0; devices[a].identifier[0]; a++) { tmp.value = devices[a].value; tmp.identifier = devices[a].identifier; tmp.name = devices[a].name; @@ -410,6 +417,15 @@ static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), P } #endif +#ifdef WITH_INTERNATIONAL +static EnumPropertyItem *rna_lang_enum_properties_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), int *free) +{ + *free = 0; /* These items are handled by BLF code! */ + return BLF_RNA_lang_enum_properties(); +} +#endif + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -481,7 +497,7 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) /* (not used yet) */ #if 0 - prop= RNA_def_property(srna, "panelzoom", PROP_FLOAT, PROP_NONE); + 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"); #endif @@ -754,6 +770,25 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) prop = RNA_def_property(srna, "icon_alpha", PROP_FLOAT, PROP_FACTOR); RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + /* axis */ + prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "xaxis"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "X Axis", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "yaxis"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Y Axis", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "zaxis"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Z Axis", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_space_generic(BlenderRNA *brna) @@ -2510,7 +2545,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sub Level Menu Open Delay", "Time delay in 1/10 seconds before automatically opening sub level menus"); - prop = RNA_def_property(srna, "quit_dialog", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_quit_dialog", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_QUIT_PROMPT); RNA_def_property_ui_text(prop, "Prompt Quit", "Asks for confirmation when quitting through the window close button"); @@ -2745,6 +2780,11 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTAVAIL); RNA_def_property_ui_text(prop, "Auto Keyframe Insert Available", "Automatic keyframe insertion in available F-Curves"); + + prop = RNA_def_property(srna, "use_auto_keying_warning", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_NOWARNING); + RNA_def_property_ui_text(prop, "Show Auto Keying Warning", + "Show warning indicators when transforming objects and bones if auto keying is enabled"); /* keyframing settings */ prop = RNA_def_property(srna, "use_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE); @@ -2778,7 +2818,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NONEGFRAMES); RNA_def_property_ui_text(prop, "Allow Negative Frames", "Current frame number can be manually set to a negative value"); - + /* fcurve opacity */ prop = RNA_def_property(srna, "fcurve_unselected_alpha", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "fcu_inactive_alpha"); @@ -2978,11 +3018,21 @@ static void rna_def_userdef_system(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem multi_sample_levels[] = { + {USER_MULTISAMPLE_NONE, "MULTISAMPLE_NONE", 0, "No MultiSample", "Do not use OpenGL MultiSample"}, + {USER_MULTISAMPLE_2, "MULTISAMPLE_2", 0, "MultiSample: 2", "Use 2x OpenGL MultiSample (requires restart)"}, + {USER_MULTISAMPLE_4, "MULTISAMPLE_4", 0, "MultiSample: 4", "Use 4x OpenGL MultiSample (requires restart)"}, + {USER_MULTISAMPLE_8, "MULTISAMPLE_8", 0, "MultiSample: 8", "Use 8x OpenGL MultiSample (requires restart)"}, + {USER_MULTISAMPLE_16, "MULTISAMPLE_16", 0, "MultiSample: 16", "Use 16x OpenGL MultiSample (requires restart)"}, + {0, NULL, 0, NULL, NULL} + }; + +#if 0 /* hardcoded here, could become dynamic somehow */ /* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */ /* if you edit here, please also edit the source/blender/blenfont/intern/blf_lang.c 's locales */ /* Note: As this list is in alphabetical order, and not defined order, - * here is the highest define currently in use: 33 (Hebrew). */ + * here is the highest define currently in use: 35 (Esperanto). */ static EnumPropertyItem language_items[] = { { 0, "", 0, N_("Nearly Done"), ""}, { 0, "DEFAULT", 0, "Default (Default)", ""}, @@ -3000,31 +3050,39 @@ static void rna_def_userdef_system(BlenderRNA *brna) {14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"}, {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, { 0, "", 0, N_("In Progress"), ""}, - {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"}, - {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, +/* {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"},*/ /* XXX Not active nor enough translated. */ +/* {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"},*/ /* XXX Not active nor enough translated. */ {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, {11, "CZECH", 0, "Czech (Český)", "cs_CZ"}, { 3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, - { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, + {35, "ESPERANTO", 0, "Esperanto (Esperanto)", "eo"}, + {34, "ESTONIAN", 0, "Estonian (Eestlane)", "et_EE"}, +/* { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"},*/ /* XXX Not active nor enough translated. */ { 5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, - {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, +/* {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"},*/ /* XXX Not active nor enough translated. */ /* using the utf8 flipped form of Hebrew (עִבְרִית)) */ {33, "HEBREW", 0, "Hebrew (תירִבְעִ)", "he_IL"}, {31, "HUNGARIAN", 0, "Hungarian (Magyar)", "hu_HU"}, {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, {29, "KYRGYZ", 0, "Kyrgyz (Кыргыз тили)", "ky_KG"}, -/* {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, */ /* XXX No po's yet. */ - {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"}, +/* {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, */ /* XXX Not active nor enough translated. */ +/* {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"},*/ /* XXX Not active nor enough translated. */ /* using the utf8 flipped form of Persian (فارسی) */ {26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_IR"}, - {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, -/* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX No po's yet. */ +/* {19, "POLISH", 0, "Polish (Polski)", "pl_PL"},*/ /* XXX Not active nor enough translated. */ +/* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX Not active nor enough translated. */ {17, "SERBIAN", 0, "Serbian (Српски)", "sr_RS"}, {28, "SERBIAN_LATIN", 0, "Serbian Latin (Srpski latinica)", "sr_RS@latin"}, { 7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, {30, "TURKISH", 0, "Turkish (Türkçe)", "tr_TR"}, { 0, NULL, 0, NULL, NULL} }; +#else + static EnumPropertyItem language_items[] = { + { 0, "DEFAULT", 0, "Default (Default)", ""}, + { 0, NULL, 0, NULL, NULL} + }; +#endif #ifdef WITH_CYCLES static EnumPropertyItem compute_device_items[] = { @@ -3067,6 +3125,9 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop = RNA_def_property(srna, "language", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, language_items); +#ifdef WITH_INTERNATIONAL + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_lang_enum_properties_itemf"); +#endif RNA_def_property_ui_text(prop, "Language", "Language used for translation"); RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update"); @@ -3110,6 +3171,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_enum_items(prop, color_picker_types); RNA_def_property_enum_sdna(prop, NULL, "color_picker_type"); RNA_def_property_ui_text(prop, "Color Picker Type", "Different styles of displaying the color picker widget"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "use_preview_images", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ALLWINCODECS); @@ -3259,6 +3321,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased"); RNA_def_property_update(prop, 0, "rna_userdef_text_update"); + /* Full scene anti-aliasing */ + prop = RNA_def_property(srna, "ogl_multisamples", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "ogl_multisamples"); + RNA_def_property_enum_items(prop, multi_sample_levels); + RNA_def_property_ui_text(prop, "MultiSample", "Enable OpenGL multi-sampling, only for systems that support it, requires restart"); + #ifdef WITH_CYCLES prop = RNA_def_property(srna, "compute_device_type", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); @@ -3388,10 +3456,10 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_SHOW_GUIDE); RNA_def_property_ui_text(prop, "Show Navigation Guide", "Display the center and axis during rotation"); /* TODO: update description when fly-mode visuals are in place ("projected position in fly mode")*/ - + /* 3D view */ prop = RNA_def_property(srna, "ndof_view_rotate_method", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "ndof_flag"); RNA_def_property_enum_items(prop, ndof_view_rotation_items); RNA_def_property_ui_text(prop, "NDOF View Rotation", "Rotation style in the viewport"); @@ -3504,6 +3572,10 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_RECENT); RNA_def_property_ui_text(prop, "Hide Recent Locations", "Hide recent locations in the file selector"); + prop = RNA_def_property(srna, "hide_system_bookmarks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_SYSTEM_BOOKMARKS); + RNA_def_property_ui_text(prop, "Hide System Bookmarks", "Hide system bookmarks in the file selector"); + prop = RNA_def_property(srna, "show_thumbnails", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_THUMBNAILS); RNA_def_property_ui_text(prop, "Show Thumbnails", "Open in thumbnail view for images and movies"); @@ -3619,10 +3691,11 @@ static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cpro RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_userdef_addon_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove addon"); parm = RNA_def_pointer(func, "addon", "Addon", "", "Addon to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } void RNA_def_userdef(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index d8753f4ff43..e5f44644f7a 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -122,6 +122,7 @@ EnumPropertyItem event_timer_type_items[] = { }; EnumPropertyItem event_ndof_type_items[] = { + {NDOF_MOTION, "NDOF_MOTION", 0, "Motion", ""}, /* buttons on all 3dconnexion devices */ {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "Menu", ""}, {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "Fit", ""}, @@ -622,13 +623,34 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) kmi->val = KM_NOTHING; break; case KMI_TYPE_NDOF: - kmi->type = NDOF_BUTTON_MENU; - kmi->val = KM_PRESS; + kmi->type = NDOF_MOTION; + kmi->val = KM_NOTHING; break; } } } +/* assumes value to be an enum from event_type_items */ +/* function makes sure keymodifiers are only valid keys, ESC keeps it unaltered */ +static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value) +{ + wmKeyMapItem *kmi = ptr->data; + + /* XXX, this should really be managed in an _itemf function, + * giving a list of valid enums, then silently changing them when they are set is not + * a good precedent, don't do this unless you have a good reason! */ + if (value == ESCKEY) { + /* pass */ + } + else if (value >= AKEY) { + kmi->keymodifier = value; + } + else { + kmi->keymodifier = 0; + } +} + + static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free)) { @@ -1062,7 +1084,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void * } else { BKE_reportf(reports, RPT_ERROR, - "registering operator class: '%s', invalid bl_idname '%s', at position %d", + "Registering operator class: '%s', invalid bl_idname '%s', at position %d", identifier, _operator_idname, i); return NULL; } @@ -1071,7 +1093,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void * } if (i > ((int)sizeof(dummyop.idname)) - 3) { - BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', " + BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s', invalid bl_idname '%s', " "is too long, maximum length is %d", identifier, _operator_idname, (int)sizeof(dummyop.idname) - 3); return NULL; @@ -1079,7 +1101,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void * if (dot != 1) { BKE_reportf(reports, RPT_ERROR, - "registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character", + "Registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character", identifier, _operator_idname); return NULL; } @@ -1180,7 +1202,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, v } if (strlen(identifier) >= sizeof(dummyop.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyop.idname)); return NULL; } @@ -1230,24 +1252,30 @@ static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value) { wmOperator *data = (wmOperator *)(ptr->data); char *str = (char *)data->type->idname; - if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ - else assert(!"setting the bl_idname on a non-builtin operator"); + if (!str[0]) + BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */ + else + assert(!"setting the bl_idname on a non-builtin operator"); } static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value) { wmOperator *data = (wmOperator *)(ptr->data); char *str = (char *)data->type->name; - if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ - else assert(!"setting the bl_label on a non-builtin operator"); + if (!str[0]) + BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */ + else + assert(!"setting the bl_label on a non-builtin operator"); } static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value) { wmOperator *data = (wmOperator *)(ptr->data); char *str = (char *)data->type->description; - if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ - else assert(!"setting the bl_description on a non-builtin operator"); + if (!str[0]) + BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ + else + assert(!"setting the bl_description on a non-builtin operator"); } static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -1404,7 +1432,7 @@ static void rna_def_operator_type_macro(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added"); RNA_def_struct_sdna(srna, "wmOperatorTypeMacro"); -/* prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */ +/* prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */ /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ /* RNA_def_property_string_sdna(prop, NULL, "idname"); */ /* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */ @@ -1865,6 +1893,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "keymodifier"); RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_wmKeyMapItem_keymodifier_set", NULL); RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier"); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index d6979161cdc..b7895cc0e2d 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -153,6 +153,18 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, ReportList *reports return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue); } +static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr) +{ + wmKeyMapItem *kmi = kmi_ptr->data; + + if (WM_keymap_remove_item(km, kmi) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "KeyMapItem '%s' cannot be removed from '%s'", kmi->idname, km->idname); + return; + } + + RNA_POINTER_INVALIDATE(kmi_ptr); +} + static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, int modal) { if (modal == 0) { @@ -178,6 +190,18 @@ static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char return ot->modalkeymap; } +static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr) +{ + wmKeyConfig *keyconf = keyconf_ptr->data; + + if (WM_keyconfig_remove(wm, keyconf) == FALSE) { + BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname); + return; + } + + RNA_POINTER_INVALIDATE(keyconf_ptr); +} + #else #define WM_GEN_INVOKE_EVENT (1 << 0) @@ -292,7 +316,7 @@ void RNA_api_operator(StructRNA *srna) /* exec */ func = RNA_def_function(srna, "execute", NULL); RNA_def_function_ui_description(func, "Execute the operator"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); @@ -303,7 +327,7 @@ void RNA_api_operator(StructRNA *srna) /* check */ func = RNA_def_function(srna, "check", NULL); RNA_def_function_ui_description(func, "Check the operator settings, return True to signal a change to redraw"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); @@ -313,7 +337,7 @@ void RNA_api_operator(StructRNA *srna) /* invoke */ func = RNA_def_function(srna, "invoke", NULL); RNA_def_function_ui_description(func, "Invoke the operator"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); parm = RNA_def_pointer(func, "event", "Event", "", ""); @@ -325,7 +349,7 @@ void RNA_api_operator(StructRNA *srna) func = RNA_def_function(srna, "modal", NULL); /* same as invoke */ RNA_def_function_ui_description(func, "Modal operator function"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); parm = RNA_def_pointer(func, "event", "Event", "", ""); @@ -345,7 +369,7 @@ void RNA_api_operator(StructRNA *srna) /* cancel */ func = RNA_def_function(srna, "cancel", NULL); RNA_def_function_ui_description(func, "Called when the operator is canceled"); - RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); @@ -464,9 +488,11 @@ void RNA_api_keymapitems(StructRNA *srna) parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "remove", "WM_keymap_remove_item"); + func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", ""); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); func = RNA_def_function(srna, "from_id", "WM_keymap_item_find_id"); parm = RNA_def_property(func, "id", PROP_INT, PROP_NONE); @@ -516,10 +542,11 @@ void RNA_api_keyconfigs(StructRNA *srna) parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "remove", "WM_keyconfig_remove"); /* remove_keyconfig */ + func = RNA_def_function(srna, "remove", "rna_KeyConfig_remove"); /* remove_keyconfig */ + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration"); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); } #endif - |