diff options
Diffstat (limited to 'source/blender/makesrna')
28 files changed, 1130 insertions, 420 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 188f933dba5..7fa7405add1 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -801,6 +801,11 @@ PropertyRNA *RNA_struct_name_property(const StructRNA *type); const EnumPropertyItem *RNA_struct_property_tag_defines(const StructRNA *type); PropertyRNA *RNA_struct_iterator_property(StructRNA *type); StructRNA *RNA_struct_base(StructRNA *type); +/** + * Use to find the sub-type directly below a base-type. + * + * So if type were `RNA_SpotLight`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Light`. + */ const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type); bool RNA_struct_is_ID(const StructRNA *type); @@ -823,16 +828,32 @@ struct IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create); bool RNA_struct_idprops_check(StructRNA *srna); bool RNA_struct_idprops_register_check(const StructRNA *type); bool RNA_struct_idprops_datablock_allowed(const StructRNA *type); +/** + * Whether given type implies datablock usage by IDProperties. + * This is used to prevent classes allowed to have IDProperties, + * but not datablock ones, to indirectly use some + * (e.g. by assigning an IDP_GROUP containing some IDP_ID pointers...). + */ bool RNA_struct_idprops_contains_datablock(const StructRNA *type); +/** + * Remove an id-property. + */ bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier); PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier); bool RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test); unsigned int RNA_struct_count_properties(StructRNA *srna); -/* lower level functions for access to type properties */ +/** + * Low level direct access to type->properties, + * note this ignores parent classes so should be used with care. + */ const struct ListBase *RNA_struct_type_properties(StructRNA *srna); PropertyRNA *RNA_struct_type_find_property_no_base(StructRNA *srna, const char *identifier); +/** + * \note #RNA_struct_find_property is a higher level alternative to this function + * which takes a #PointerRNA instead of a #StructRNA. + */ PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifier); FunctionRNA *RNA_struct_find_function(StructRNA *srna, const char *identifier); @@ -840,6 +861,9 @@ const struct ListBase *RNA_struct_type_functions(StructRNA *srna); char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len); +/** + * Use when registering structs with the #STRUCT_PUBLIC_NAMESPACE flag. + */ bool RNA_struct_available_or_report(struct ReportList *reports, const char *identifier); bool RNA_struct_bl_idname_ok_or_report(struct ReportList *reports, const char *identifier, @@ -861,17 +885,32 @@ PropertyUnit RNA_property_unit(PropertyRNA *prop); PropertyScaleType RNA_property_ui_scale(PropertyRNA *prop); int RNA_property_flag(PropertyRNA *prop); int RNA_property_override_flag(PropertyRNA *prop); +/** + * Get the tags set for \a prop as int bitfield. + * \note Doesn't perform any validity check on the set bits. #RNA_def_property_tags does this + * in debug builds (to avoid performance issues in non-debug builds), which should be + * the only way to set tags. Hence, at this point we assume the tag bitfield to be valid. + */ int RNA_property_tags(PropertyRNA *prop); bool RNA_property_builtin(PropertyRNA *prop); void *RNA_property_py_data_get(PropertyRNA *prop); int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_array_check(PropertyRNA *prop); +/** + * Return the size of Nth dimension. + */ int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dimension); +/** + * Used by BPY to make an array from the python object. + */ int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[]); char RNA_property_array_item_char(PropertyRNA *prop, int index); int RNA_property_array_item_index(PropertyRNA *prop, char name); +/** + * \return the maximum length including the \0 terminator. '0' is used when there is no maximum. + */ int RNA_property_string_maxlength(PropertyRNA *prop); const char *RNA_property_ui_name(const PropertyRNA *prop); @@ -906,6 +945,10 @@ bool RNA_enum_name(const EnumPropertyItem *item, const int value, const char **r bool RNA_enum_description(const EnumPropertyItem *item, const int value, const char **description); int RNA_enum_from_value(const EnumPropertyItem *item, const int value); int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier); +/** + * Take care using this with translated enums, + * prefer #RNA_enum_from_identifier where possible. + */ int RNA_enum_from_name(const EnumPropertyItem *item, const char *name); unsigned int RNA_enum_items_count(const EnumPropertyItem *item); @@ -967,27 +1010,54 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value); bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop); +/** + * Version of #RNA_property_editable that tries to return additional info in \a r_info + * that can be exposed in UI. + */ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info); +/** + * Same as RNA_property_editable(), except this checks individual items in an array. + */ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index); -/* without lib check, only checks the flag */ +/** + * Without lib check, only checks the flag. + */ bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop); +/** + * \note Does not take into account editable status, this has to be checked separately + * (using #RNA_property_editable_flag() usually). + */ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop); +/** + * Should only be used for custom properties. + */ bool RNA_property_overridable_library_set(PointerRNA *ptr, PropertyRNA *prop, const bool is_overridable); bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop); bool RNA_property_comparable(PointerRNA *ptr, PropertyRNA *prop); +/** + * This function is to check if its possible to create a valid path from the ID + * its slow so don't call in a loop. + */ bool RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop); /* slow, use with care */ void RNA_property_update(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop); +/** + * \param scene: may be NULL. + */ void RNA_property_update_main(struct Main *bmain, struct Scene *scene, PointerRNA *ptr, PropertyRNA *prop); +/** + * \note its possible this returns a false positive in the case of #PROP_CONTEXT_UPDATE + * but this isn't likely to be a performance problem. + */ bool RNA_property_update_check(struct PropertyRNA *prop); /* Property Data */ @@ -1031,15 +1101,28 @@ char *RNA_property_string_get_alloc( PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len); void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value); void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const char *value, int len); +/** + * \return the length without `\0` terminator. + */ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_string_get_default(PropertyRNA *prop, char *value, int max_len); char *RNA_property_string_get_default_alloc( PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len); +/** + * \return the length without `\0` terminator. + */ int RNA_property_string_default_length(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value); int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop); +/** + * Get the value of the item that is \a step items away from \a from_value. + * + * \param from_value: Item value to start stepping from. + * \param step: Absolute value defines step size, sign defines direction. + * E.g to get the next item, pass 1, for the previous -1. + */ int RNA_property_enum_step( const struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int from_value, int step); @@ -1068,6 +1151,9 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PointerRNA *r_ptr); int RNA_property_collection_lookup_string_index( PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr, int *r_index); +/** + * Zero return is an assignment error. + */ int RNA_property_collection_assign_int(PointerRNA *ptr, PropertyRNA *prop, const int key, @@ -1125,31 +1211,99 @@ char *RNA_path_append( char *RNA_path_back(const char *path); #endif -/* path_resolve() variants only ensure that a valid pointer (and optionally property) exist */ +/* RNA_path_resolve() variants only ensure that a valid pointer (and optionally property) exist. */ + +/** + * Resolve the given RNA Path to find the pointer and/or property + * indicated by fully resolving the path. + * + * \warning Unlike \a RNA_path_resolve_property(), that one *will* try to follow RNAPointers, + * e.g. the path 'parent' applied to a RNAObject \a ptr will return the object.parent in \a r_ptr, + * and a NULL \a r_prop... + * + * \note Assumes all pointers provided are valid + * \return True if path can be resolved to a valid "pointer + property" OR "pointer only" + */ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop); +/** + * Resolve the given RNA Path to find the pointer and/or property + array index + * indicated by fully resolving the path. + * + * \note Assumes all pointers provided are valid. + * \return True if path can be resolved to a valid "pointer + property" OR "pointer only" + */ bool RNA_path_resolve_full( PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index); +/** + * A version of #RNA_path_resolve_full doesn't check the value of #PointerRNA.data. + * + * \note While it's correct to ignore the value of #PointerRNA.data + * most callers need to know if the resulting pointer was found and not null. + */ bool RNA_path_resolve_full_maybe_null( PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index); -/* path_resolve_property() variants ensure that pointer + property both exist */ +/* RNA_path_resolve_property() variants ensure that pointer + property both exist. */ + +/** + * Resolve the given RNA Path to find both the pointer AND property + * indicated by fully resolving the path. + * + * This is a convenience method to avoid logic errors and ugly syntax. + * \note Assumes all pointers provided are valid + * \return True only if both a valid pointer and property are found after resolving the path + */ bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop); +/** + * Resolve the given RNA Path to find the pointer AND property (as well as the array index) + * indicated by fully resolving the path. + * + * This is a convenience method to avoid logic errors and ugly syntax. + * \note Assumes all pointers provided are valid + * \return True only if both a valid pointer and property are found after resolving the path + */ bool RNA_path_resolve_property_full( PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index); -/* path_resolve_property_and_item_pointer() variants ensure that pointer + property both exist, +/* RNA_path_resolve_property_and_item_pointer() variants ensure that pointer + property both exist, * and resolve last Pointer value if possible (Pointer prop or item of a Collection prop). */ + +/** + * Resolve the given RNA Path to find both the pointer AND property + * indicated by fully resolving the path, and get the value of the Pointer property + * (or item of the collection). + * + * This is a convenience method to avoid logic errors and ugly syntax, + * it combines both \a RNA_path_resolve and #RNA_path_resolve_property in a single call. + * \note Assumes all pointers provided are valid. + * \param r_item_ptr: The final Pointer or Collection item value. + * You must check for its validity before use! + * \return True only if both a valid pointer and property are found after resolving the path + */ bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, PointerRNA *r_item_ptr); +/** + * Resolve the given RNA Path to find both the pointer AND property (as well as the array index) + * indicated by fully resolving the path, + * and get the value of the Pointer property (or item of the collection). + * + * This is a convenience method to avoid logic errors and ugly syntax, + * it combines both \a RNA_path_resolve_full and + * \a RNA_path_resolve_property_full in a single call. + * \note Assumes all pointers provided are valid. + * \param r_item_ptr: The final Pointer or Collection item value. + * You must check for its validity before use! + * \return True only if both a valid pointer and property are found after resolving the path + */ bool RNA_path_resolve_property_and_item_pointer_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, @@ -1164,10 +1318,36 @@ struct PropertyElemRNA { PropertyRNA *prop; int index; }; +/** + * Resolve the given RNA Path into a linked list of #PropertyElemRNA's. + * + * To be used when complex operations over path are needed, like e.g. get relative paths, + * to avoid too much string operations. + * + * \return True if there was no error while resolving the path + * \note Assumes all pointers provided are valid + */ bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, struct ListBase *r_elements); +/** + * Find the path from the structure referenced by the pointer to the runtime RNA-defined + * #IDProperty object. + * + * \note Does *not* handle pure user-defined IDProperties (a.k.a. custom properties). + * + * \param ptr: Reference to the object owning the custom property storage. + * \param needle: Custom property object to find. + * \return Relative path or NULL. + */ char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, struct IDProperty *needle); +/** + * Find the actual ID pointer and path from it to the given ID. + * + * \param id: ID reference to search the global owner for. + * \param[out] r_path: Path from the real ID to the initial ID. + * \return The ID pointer, or NULL in case of failure. + */ struct ID *RNA_find_real_ID_and_path(struct Main *bmain, struct ID *id, const char **r_path); char *RNA_path_from_ID_to_struct(const PointerRNA *ptr); @@ -1175,6 +1355,11 @@ char *RNA_path_from_ID_to_struct(const PointerRNA *ptr); char *RNA_path_from_real_ID_to_struct(struct Main *bmain, PointerRNA *ptr, struct ID **r_real); char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop); +/** + * \param index_dim: The dimension to show, 0 disables. 1 for 1d array, 2 for 2d. etc. + * \param index: The *flattened* index to use when \a `index_dim > 0`, + * this is expanded when used with multi-dimensional arrays. + */ char *RNA_path_from_ID_to_property_index(PointerRNA *ptr, PropertyRNA *prop, int index_dim, @@ -1187,19 +1372,43 @@ char *RNA_path_from_real_ID_to_property_index(struct Main *bmain, int index, struct ID **r_real_id); +/** + * \return the path to given ptr/prop from the closest ancestor of given type, + * if any (else return NULL). + */ char *RNA_path_resolve_from_type_to_property(struct PointerRNA *ptr, struct PropertyRNA *prop, const struct StructRNA *type); +/** + * Get the ID as a python representation, eg: + * bpy.data.foo["bar"] + */ char *RNA_path_full_ID_py(struct Main *bmain, struct ID *id); +/** + * Get the ID.struct as a python representation, eg: + * bpy.data.foo["bar"].some_struct + */ char *RNA_path_full_struct_py(struct Main *bmain, struct PointerRNA *ptr); +/** + * Get the ID.struct.property as a python representation, eg: + * bpy.data.foo["bar"].some_struct.some_prop[10] + */ char *RNA_path_full_property_py_ex( struct Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback); char *RNA_path_full_property_py(struct Main *bmain, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); +/** + * Get the struct.property as a python representation, eg: + * some_struct.some_prop[10] + */ char *RNA_path_struct_property_py(struct PointerRNA *ptr, struct PropertyRNA *prop, int index); +/** + * Get the struct.property as a python representation, eg: + * some_prop[10] + */ char *RNA_path_property_py(const struct PointerRNA *ptr, struct PropertyRNA *prop, int index); /* Quick name based property access @@ -1314,24 +1523,38 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); } \ ((void)0) -/* check if the idproperty exists, for operators */ +/** + * Check if the #IDproperty exists, for operators. + */ bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost); bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop); bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost); bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier); bool RNA_property_is_idprop(const PropertyRNA *prop); +/** + * \note Mainly for the UI. + */ bool RNA_property_is_unlink(PropertyRNA *prop); void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier); -/* python compatible string representation of this property, (must be freed!) */ +/** + * Python compatible string representation of this property, (must be freed!). + */ char *RNA_property_as_string( struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length); +/** + * String representation of a property, Python compatible but can be used for display too. + * \param C: can be NULL. + */ char *RNA_pointer_as_string_id(struct bContext *C, PointerRNA *ptr); char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop); +/** + * \param C: can be NULL. + */ char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, const bool as_function, @@ -1383,7 +1606,9 @@ void RNA_parameter_get(ParameterList *parms, PropertyRNA *parm, void **value); void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **value); void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, const void *value); void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value); + /* Only for PROP_DYNAMIC properties! */ + int RNA_parameter_dynamic_length_get(ParameterList *parms, PropertyRNA *parm); int RNA_parameter_dynamic_length_get_data(ParameterList *parms, PropertyRNA *parm, void *data); void RNA_parameter_dynamic_length_set(ParameterList *parms, PropertyRNA *parm, int length); @@ -1454,6 +1679,7 @@ StructRNA *ID_code_to_RNA_type(short idcode); # define RNA_warning(format, ...) _RNA_warning("%s: " format "\n", __FUNCTION__, __VA_ARGS__) #endif +/** Use to implement the #RNA_warning macro which includes `__func__` suffix. */ void _RNA_warning(const char *format, ...) ATTR_PRINTF_FORMAT(1, 2); /* Equals test. */ @@ -1520,6 +1746,16 @@ typedef enum eRNAOverrideStatus { RNA_OVERRIDE_STATUS_LOCKED = 1 << 3, } eRNAOverrideStatus; +/** + * Check whether reference and local overridden data match (are the same), + * with respect to given restrictive sets of properties. + * If requested, will generate needed new property overrides, and/or restore values from reference. + * + * \param r_report_flags: If given, + * will be set with flags matching actions taken by the function on \a ptr_local. + * + * \return True if _resulting_ \a ptr_local does match \a ptr_reference. + */ bool RNA_struct_override_matches(struct Main *bmain, struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, @@ -1529,6 +1765,10 @@ bool RNA_struct_override_matches(struct Main *bmain, const eRNAOverrideMatch flags, eRNAOverrideMatchResult *r_report_flags); +/** + * Store needed second operands into \a storage data-block + * for differential override operations. + */ bool RNA_struct_override_store(struct Main *bmain, struct PointerRNA *ptr_local, struct PointerRNA *ptr_reference, @@ -1544,6 +1784,10 @@ typedef enum eRNAOverrideApplyFlag { RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS = 1 << 0, } eRNAOverrideApplyFlag; +/** + * Apply given \a override operations on \a ptr_dst, using \a ptr_src + * (and \a ptr_storage for differential ops) as source. + */ void RNA_struct_override_apply(struct Main *bmain, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 01e26cbb41c..3596a5f2234 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -49,6 +49,10 @@ void RNA_free(BlenderRNA *brna); void RNA_define_verify_sdna(bool verify); void RNA_define_animate_sdna(bool animate); void RNA_define_fallback_property_update(int noteflag, const char *updatefunc); +/** + * Properties defined when this is enabled are lib-overridable by default + * (except for Pointer ones). + */ void RNA_define_lib_overridable(const bool make_overridable); void RNA_init(void); @@ -56,6 +60,9 @@ void RNA_exit(void); /* Struct */ +/** + * Struct Definition. + */ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom); StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from); void RNA_def_struct_sdna(StructRNA *srna, const char *structname); @@ -72,6 +79,9 @@ void RNA_def_struct_register_funcs(StructRNA *srna, const char *unreg, const char *instance); void RNA_def_struct_path_func(StructRNA *srna, const char *path); +/** + * Only used in one case when we name the struct for the purpose of useful error messages. + */ void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identifier); void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier); void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description); @@ -176,6 +186,9 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, int default_value, const char *ui_name, const char *ui_description); +/** + * Same as above but sets #PROP_ENUM_FLAG before setting the default value. + */ PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, @@ -362,6 +375,13 @@ void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag); void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag); void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag); void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag); +/** + * Add the property-tags passed as \a tags to \a prop (if valid). + * + * \note Multiple tags can be set by passing them within \a tags (using bit-flags). + * \note Doesn't do any type-checking with the tags defined in the parent #StructRNA + * of \a prop. This should be done before (e.g. see #WM_operatortype_prop_tag). + */ void RNA_def_property_tags(PropertyRNA *prop, int tags); void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype); void RNA_def_property_array(PropertyRNA *prop, int length); @@ -381,11 +401,25 @@ void RNA_def_property_boolean_array_default(PropertyRNA *prop, const bool *array void RNA_def_property_int_default(PropertyRNA *prop, int value); void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array); void RNA_def_property_float_default(PropertyRNA *prop, float value); +/** + * Array must remain valid after this function finishes. + */ void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array); void RNA_def_property_enum_default(PropertyRNA *prop, int value); void RNA_def_property_string_default(PropertyRNA *prop, const char *value); void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description); +/** + * The values hare are a little confusing: + * + * \param step: Used as the value to increase/decrease when clicking on number buttons, + * as well as scaling mouse input for click-dragging number buttons. + * For floats this is (step * UI_PRECISION_FLOAT_SCALE), why? - nobody knows. + * For ints, whole values are used. + * + * \param precision: The number of zeros to show + * (as a whole number - common range is 1 - 6), see UI_PRECISION_FLOAT_MAX + */ void RNA_def_property_ui_range( PropertyRNA *prop, double min, double max, double step, int precision); void RNA_def_property_ui_scale_type(PropertyRNA *prop, PropertyScaleType scale_type); @@ -395,6 +429,11 @@ void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *update void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable); void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable); +/** + * Set custom callbacks for override operations handling. + * + * \note \a diff callback will also be used by RNA comparison/equality functions. + */ void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, @@ -472,6 +511,9 @@ void RNA_def_property_translation_context(PropertyRNA *prop, const char *context FunctionRNA *RNA_def_function(StructRNA *srna, const char *identifier, const char *call); FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, CallFunc call); +/** + * C return value only! multiple RNA returns can be done with #RNA_def_function_output. + */ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret); void RNA_def_function_output(FunctionRNA *func, PropertyRNA *ret); void RNA_def_function_flag(FunctionRNA *func, int flag); @@ -514,7 +556,8 @@ void RNA_def_property_free_identifier_deferred_finish(StructOrFunctionRNA *cont_ void RNA_def_property_free_pointers_set_py_data_callback( void (*py_data_clear_fn)(PropertyRNA *prop)); -/* utilities */ +/* Utilities. */ + const char *RNA_property_typename(PropertyType type); #define IS_DNATYPE_FLOAT_COMPAT(_str) (strcmp(_str, "float") == 0 || strcmp(_str, "double") == 0) #define IS_DNATYPE_INT_COMPAT(_str) \ @@ -525,16 +568,19 @@ const char *RNA_property_typename(PropertyType type); void RNA_identifier_sanitize(char *identifier, int property); +/* Common arguments for length. */ + extern const int rna_matrix_dimsize_3x3[]; extern const int rna_matrix_dimsize_4x4[]; extern const int rna_matrix_dimsize_4x2[]; +/* Common arguments for defaults. */ + extern const float rna_default_axis_angle[4]; extern const float rna_default_quaternion[4]; extern const float rna_default_scale_3d[3]; -/* max size for dynamic defined type descriptors, - * this value is arbitrary */ +/** Maximum size for dynamic defined type descriptors, this value is arbitrary. */ #define RNA_DYN_DESCR_MAX 240 #ifdef __cplusplus diff --git a/source/blender/makesrna/RNA_enum_items.h b/source/blender/makesrna/RNA_enum_items.h index fb18802483d..531af92c544 100644 --- a/source/blender/makesrna/RNA_enum_items.h +++ b/source/blender/makesrna/RNA_enum_items.h @@ -61,6 +61,8 @@ DEF_ENUM(rna_enum_object_shaderfx_type_items) DEF_ENUM(rna_enum_modifier_triangulate_quad_method_items) DEF_ENUM(rna_enum_modifier_triangulate_ngon_method_items) DEF_ENUM(rna_enum_modifier_shrinkwrap_mode_items) +DEF_ENUM(rna_enum_shrinkwrap_type_items) +DEF_ENUM(rna_enum_shrinkwrap_face_cull_items) DEF_ENUM(rna_enum_image_type_items) DEF_ENUM(rna_enum_image_color_mode_items) @@ -172,6 +174,7 @@ DEF_ENUM(rna_enum_mapping_type_items) DEF_ENUM(rna_enum_node_vec_math_items) DEF_ENUM(rna_enum_node_boolean_math_items) DEF_ENUM(rna_enum_node_float_compare_items) +DEF_ENUM(rna_enum_node_compare_operation_items) DEF_ENUM(rna_enum_node_filter_items) DEF_ENUM(rna_enum_node_float_to_int_items) DEF_ENUM(rna_enum_node_map_range_items) @@ -210,6 +213,7 @@ DEF_ENUM(rna_enum_attribute_type_with_auto_items) DEF_ENUM(rna_enum_attribute_domain_items) DEF_ENUM(rna_enum_attribute_domain_without_corner_items) DEF_ENUM(rna_enum_attribute_domain_with_auto_items) +DEF_ENUM(rna_enum_geometry_component_type_items) DEF_ENUM(rna_enum_volume_grid_data_type_items) @@ -221,7 +225,7 @@ DEF_ENUM(rna_enum_subdivision_boundary_smooth_items) DEF_ENUM(rna_enum_transform_orientation_items) -/* Not available to RNA pre-processing (`makrsrna`). +/* Not available to RNA pre-processing (`makesrna`). * Defined in editors for example. */ #ifndef RNA_MAKESRNA diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index d7520834287..da07f1043a7 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -83,8 +83,10 @@ const EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PropertyRNA *prop, bool *r_free); -/* Generic functions, return an enum from library data, index is the position - * in the linked list can add more for different types as needed */ +/** + * Generic functions, return an enum from library data, index is the position + * in the linked list can add more for different types as needed. + */ const EnumPropertyItem *RNA_action_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 40b5f3ed1da..b64fa58cf6b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -438,12 +438,6 @@ static PropertyRNA *arraytypemap[IDP_NUMTYPES] = { (PropertyRNA *)&rna_PropertyGroupItem_double_array, }; -/* This function initializes a PropertyRNAOrID with all required info, from a given PropertyRNA - * and PointerRNA data. It deals properly with the three cases (static RNA, runtime RNA, and - * IDProperty). - * WARNING: given `ptr` PointerRNA is assumed to be a valid data one here, calling code is - * responsible to ensure that. - */ void rna_property_rna_or_id_get(PropertyRNA *prop, PointerRNA *ptr, PropertyRNAOrID *r_prop_rna_or_id) @@ -515,8 +509,6 @@ void rna_property_rna_or_id_get(PropertyRNA *prop, } } -/* This function only returns an IDProperty, - * or NULL (in case IDProp could not be found, or prop is a real RNA property). */ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) { PropertyRNAOrID prop_rna_or_id; @@ -527,8 +519,6 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) return prop_rna_or_id.idprop; } -/* This function always return the valid, real data pointer, be it a regular RNA property one, - * or an IDProperty one. */ PropertyRNA *rna_ensure_property_realdata(PropertyRNA **prop, PointerRNA *ptr) { PropertyRNAOrID prop_rna_or_id; @@ -661,11 +651,6 @@ StructRNA *RNA_struct_base(StructRNA *type) return type->base; } -/** - * Use to find the subtype directly below a base-type. - * - * So if type were `RNA_SpotLIght`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Light`. - */ const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type) { while (type) { @@ -697,18 +682,11 @@ bool RNA_struct_idprops_datablock_allowed(const StructRNA *type) return (type->flag & (STRUCT_NO_DATABLOCK_IDPROPERTIES | STRUCT_NO_IDPROPERTIES)) == 0; } -/** - * Whether given type implies datablock usage by IDProperties. - * This is used to prevent classes allowed to have IDProperties, - * but not datablock ones, to indirectly use some - * (e.g. by assigning an IDP_GROUP containing some IDP_ID pointers...). - */ bool RNA_struct_idprops_contains_datablock(const StructRNA *type) { return (type->flag & (STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES | STRUCT_ID)) != 0; } -/* remove an id-property */ bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier) { IDProperty *group = RNA_struct_idprops(ptr, 0); @@ -825,8 +803,6 @@ unsigned int RNA_struct_count_properties(StructRNA *srna) return counter; } -/* Low level direct access to type->properties, - * note this ignores parent classes so should be used with care. */ const struct ListBase *RNA_struct_type_properties(StructRNA *srna) { return &srna->cont.properties; @@ -837,10 +813,6 @@ PropertyRNA *RNA_struct_type_find_property_no_base(StructRNA *srna, const char * return BLI_findstring_ptr(&srna->cont.properties, identifier, offsetof(PropertyRNA, identifier)); } -/** - * \note #RNA_struct_find_property is a higher level alternative to this function - * which takes a #PointerRNA instead of a #StructRNA. - */ PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifier) { for (; srna; srna = srna->base) { @@ -953,9 +925,6 @@ char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, i return NULL; } -/** - * Use when registering structs with the #STRUCT_PUBLIC_NAMESPACE flag. - */ bool RNA_struct_available_or_report(ReportList *reports, const char *identifier) { const StructRNA *srna_exists = RNA_struct_find(identifier); @@ -1098,12 +1067,6 @@ int RNA_property_flag(PropertyRNA *prop) return rna_ensure_property(prop)->flag; } -/** - * Get the tags set for \a prop as int bitfield. - * \note Doesn't perform any validity check on the set bits. #RNA_def_property_tags does this - * in debug builds (to avoid performance issues in non-debug builds), which should be - * the only way to set tags. Hence, at this point we assume the tag bitfield to be valid. - */ int RNA_property_tags(PropertyRNA *prop) { return rna_ensure_property(prop)->tags; @@ -1129,7 +1092,6 @@ bool RNA_property_array_check(PropertyRNA *prop) return rna_ensure_property_array_check(prop); } -/* used by BPY to make an array from the python object */ int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[]) { PropertyRNA *rprop = rna_ensure_property(prop); @@ -1141,7 +1103,6 @@ int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[ return rprop->arraydimension; } -/* Return the size of Nth dimension. */ int RNA_property_multi_array_length(PointerRNA *ptr, PropertyRNA *prop, int dim) { int len[RNA_MAX_ARRAY_DIMENSION]; @@ -1445,9 +1406,6 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value) return 0; } -/** - * \return the maximum length including the \0 terminator. '0' is used when there is no maximum. - */ int RNA_property_string_maxlength(PropertyRNA *prop) { StringPropertyRNA *sprop = (StringPropertyRNA *)rna_ensure_property(prop); @@ -1774,10 +1732,6 @@ int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifie return -1; } -/** - * Take care using this with translated enums, - * prefer #RNA_enum_from_identifier where possible. - */ int RNA_enum_from_name(const EnumPropertyItem *item, const char *name) { int i = 0; @@ -1973,10 +1927,6 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop_orig) (!ID_IS_OVERRIDE_LIBRARY(id) || RNA_property_overridable_get(ptr, prop_orig))))); } -/** - * Version of #RNA_property_editable that tries to return additional info in \a r_info - * that can be exposed in UI. - */ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info) { ID *id = ptr->owner_id; @@ -2027,7 +1977,6 @@ bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop) return (flag & PROP_EDITABLE) != 0; } -/* same as RNA_property_editable(), except this checks individual items in an array */ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) { ID *id; @@ -2090,8 +2039,6 @@ bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop) return false; } -/* this function is to check if its possible to create a valid path from the ID - * its slow so don't call in a loop */ bool RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop) { char *path = RNA_path_from_ID_to_property(ptr, prop); @@ -2194,11 +2141,9 @@ static void rna_property_update( } } -/* must keep in sync with 'rna_property_update' - * NOTE: its possible this returns a false positive in the case of #PROP_CONTEXT_UPDATE - * but this isn't likely to be a performance problem. */ bool RNA_property_update_check(PropertyRNA *prop) { + /* NOTE: must keep in sync with #rna_property_update. */ return (prop->magic != RNA_MAGIC || prop->update || prop->noteflag); } @@ -2207,7 +2152,6 @@ void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop) rna_property_update(C, CTX_data_main(C), CTX_data_scene(C), ptr, prop); } -/* NOTE: `scene` pointer may be NULL. */ void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop) { rna_property_update(NULL, bmain, scene, ptr, prop); @@ -3277,7 +3221,6 @@ char *RNA_property_string_get_alloc( return buf; } -/* this is the length without \0 terminator */ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop) { StringPropertyRNA *sprop = (StringPropertyRNA *)prop; @@ -3417,7 +3360,6 @@ char *RNA_property_string_get_default_alloc( return buf; } -/* this is the length without \0 terminator */ int RNA_property_string_default_length(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { StringPropertyRNA *sprop = (StringPropertyRNA *)rna_ensure_property(prop); @@ -3498,13 +3440,6 @@ int RNA_property_enum_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop) return eprop->defaultvalue; } -/** - * Get the value of the item that is \a step items away from \a from_value. - * - * \param from_value: Item value to start stepping from. - * \param step: Absolute value defines step size, sign defines direction. - * E.g to get the next item, pass 1, for the previous -1. - */ int RNA_property_enum_step( const bContext *C, PointerRNA *ptr, PropertyRNA *prop, int from_value, int step) { @@ -4212,7 +4147,6 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, return RNA_property_collection_lookup_string_index(ptr, prop, key, r_ptr, &index); } -/* zero return is an assignment error */ int RNA_property_collection_assign_int(PointerRNA *ptr, PropertyRNA *prop, const int key, @@ -4987,6 +4921,10 @@ static char *rna_path_token_in_brackets(const char **path, return buf; } +/** + * \return true when when the key in the path is correctly parsed and found in the collection + * or when the path is empty. + */ static bool rna_path_parse_collection_key(const char **path, PointerRNA *ptr, PropertyRNA *prop, @@ -5002,6 +4940,7 @@ static bool rna_path_parse_collection_key(const char **path, return true; } + bool found = false; if (**path == '[') { bool quoted; char *token; @@ -5016,7 +4955,7 @@ static bool rna_path_parse_collection_key(const char **path, /* check for "" to see if it is a string */ if (quoted) { if (RNA_property_collection_lookup_string(ptr, prop, token, r_nextptr)) { - /* pass */ + found = true; } else { r_nextptr->data = NULL; @@ -5029,7 +4968,7 @@ static bool rna_path_parse_collection_key(const char **path, return false; /* we can be sure the fixedbuf was used in this case */ } if (RNA_property_collection_lookup_int(ptr, prop, intkey, r_nextptr)) { - /* pass */ + found = true; } else { r_nextptr->data = NULL; @@ -5042,7 +4981,7 @@ static bool rna_path_parse_collection_key(const char **path, } else { if (RNA_property_collection_type_get(ptr, prop, r_nextptr)) { - /* pass */ + found = true; } else { /* ensure we quit on invalid values */ @@ -5050,7 +4989,7 @@ static bool rna_path_parse_collection_key(const char **path, } } - return true; + return found; } static bool rna_path_parse_array_index(const char **path, @@ -5326,17 +5265,6 @@ static bool rna_path_parse(PointerRNA *ptr, return true; } -/** - * Resolve the given RNA Path to find the pointer and/or property - * indicated by fully resolving the path. - * - * \warning Unlike \a RNA_path_resolve_property(), that one *will* try to follow RNAPointers, - * e.g. the path 'parent' applied to a RNAObject \a ptr will return the object.parent in \a r_ptr, - * and a NULL \a r_prop... - * - * \note Assumes all pointers provided are valid - * \return True if path can be resolved to a valid "pointer + property" OR "pointer only" - */ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop) { if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, true)) { @@ -5346,13 +5274,6 @@ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prop return r_ptr->data != NULL; } -/** - * Resolve the given RNA Path to find the pointer and/or property + array index - * indicated by fully resolving the path. - * - * \note Assumes all pointers provided are valid. - * \return True if path can be resolved to a valid "pointer + property" OR "pointer only" - */ bool RNA_path_resolve_full( PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { @@ -5363,26 +5284,12 @@ bool RNA_path_resolve_full( return r_ptr->data != NULL; } -/** - * A version of #RNA_path_resolve_full doesn't check the value of #PointerRNA.data. - * - * \note While it's correct to ignore the value of #PointerRNA.data - * most callers need to know if the resulting pointer was found and not null. - */ bool RNA_path_resolve_full_maybe_null( PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { return rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true); } -/** - * Resolve the given RNA Path to find both the pointer AND property - * indicated by fully resolving the path. - * - * This is a convenience method to avoid logic errors and ugly syntax. - * \note Assumes all pointers provided are valid - * \return True only if both a valid pointer and property are found after resolving the path - */ bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, @@ -5395,14 +5302,6 @@ bool RNA_path_resolve_property(PointerRNA *ptr, return r_ptr->data != NULL && *r_prop != NULL; } -/** - * Resolve the given RNA Path to find the pointer AND property (as well as the array index) - * indicated by fully resolving the path. - * - * This is a convenience method to avoid logic errors and ugly syntax. - * \note Assumes all pointers provided are valid - * \return True only if both a valid pointer and property are found after resolving the path - */ bool RNA_path_resolve_property_full( PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index) { @@ -5413,18 +5312,6 @@ bool RNA_path_resolve_property_full( return r_ptr->data != NULL && *r_prop != NULL; } -/** - * Resolve the given RNA Path to find both the pointer AND property - * indicated by fully resolving the path, and get the value of the Pointer property - * (or item of the collection). - * - * This is a convenience method to avoid logic errors and ugly syntax, - * it combines both \a RNA_path_resolve and #RNA_path_resolve_property in a single call. - * \note Assumes all pointers provided are valid. - * \param r_item_ptr: The final Pointer or Collection item value. - * You must check for its validity before use! - * \return True only if both a valid pointer and property are found after resolving the path - */ bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, @@ -5438,19 +5325,6 @@ bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr, return r_ptr->data != NULL && *r_prop != NULL; } -/** - * Resolve the given RNA Path to find both the pointer AND property (as well as the array index) - * indicated by fully resolving the path, - * and get the value of the Pointer property (or item of the collection). - * - * This is a convenience method to avoid logic errors and ugly syntax, - * it combines both \a RNA_path_resolve_full and - * \a RNA_path_resolve_property_full in a single call. - * \note Assumes all pointers provided are valid. - * \param r_item_ptr: The final Pointer or Collection item value. - * You must check for its validity before use! - * \return True only if both a valid pointer and property are found after resolving the path - */ bool RNA_path_resolve_property_and_item_pointer_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, @@ -5464,15 +5338,6 @@ bool RNA_path_resolve_property_and_item_pointer_full(PointerRNA *ptr, return r_ptr->data != NULL && *r_prop != NULL; } -/** - * Resolve the given RNA Path into a linked list of PropertyElemRNA's. - * - * To be used when complex operations over path are needed, like e.g. get relative paths, - * to avoid too much string operations. - * - * \return True if there was no error while resolving the path - * \note Assumes all pointers provided are valid - */ bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, ListBase *r_elements) { return rna_path_parse(ptr, path, NULL, NULL, NULL, NULL, r_elements, false); @@ -5723,16 +5588,6 @@ static char *rna_idp_path(PointerRNA *ptr, return path; } -/** - * Find the path from the structure referenced by the pointer to the runtime RNA-defined - * #IDProperty object. - * - * \note Does *not* handle pure user-defined IDProperties (a.k.a. custom properties). - * - * \param ptr: Reference to the object owning the custom property storage. - * \param needle: Custom property object to find. - * \return Relative path or NULL. - */ char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle) { IDProperty *haystack = RNA_struct_idprops(ptr, false); @@ -5759,13 +5614,6 @@ static char *rna_path_from_ID_to_idpgroup(const PointerRNA *ptr) return RNA_path_from_struct_to_idproperty(&id_ptr, ptr->data); } -/** - * Find the actual ID pointer and path from it to the given ID. - * - * \param id: ID reference to search the global owner for. - * \param[out] r_path: Path from the real ID to the initial ID. - * \return The ID pointer, or NULL in case of failure. - */ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path) { if (r_path) { @@ -5918,11 +5766,6 @@ static void rna_path_array_multi_string_from_flat_index(PointerRNA *ptr, } } -/** - * \param index_dim: The dimension to show, 0 disables. 1 for 1d array, 2 for 2d. etc. - * \param index: The *flattened* index to use when \a `index_dim > 0`, - * this is expanded when used with multi-dimensional arrays. - */ char *RNA_path_from_ID_to_property_index(PointerRNA *ptr, PropertyRNA *prop, int index_dim, @@ -5994,10 +5837,6 @@ char *RNA_path_from_real_ID_to_property_index( return path != NULL ? rna_prepend_real_ID_path(bmain, ptr->owner_id, path, r_real_id) : NULL; } -/** - * \return the path to given ptr/prop from the closest ancestor of given type, - * if any (else return NULL). - */ char *RNA_path_resolve_from_type_to_property(PointerRNA *ptr, PropertyRNA *prop, const StructRNA *type) @@ -6036,10 +5875,6 @@ char *RNA_path_resolve_from_type_to_property(PointerRNA *ptr, return path; } -/** - * Get the ID as a python representation, eg: - * bpy.data.foo["bar"] - */ char *RNA_path_full_ID_py(Main *bmain, ID *id) { const char *path; @@ -6075,10 +5910,6 @@ char *RNA_path_full_ID_py(Main *bmain, ID *id) path); } -/** - * Get the ID.struct as a python representation, eg: - * bpy.data.foo["bar"].some_struct - */ char *RNA_path_full_struct_py(Main *bmain, struct PointerRNA *ptr) { char *id_path; @@ -6107,10 +5938,6 @@ char *RNA_path_full_struct_py(Main *bmain, struct PointerRNA *ptr) return ret; } -/** - * Get the ID.struct.property as a python representation, eg: - * bpy.data.foo["bar"].some_struct.some_prop[10] - */ char *RNA_path_full_property_py_ex( Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback) { @@ -6164,10 +5991,6 @@ char *RNA_path_full_property_py(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, return RNA_path_full_property_py_ex(bmain, ptr, prop, index, false); } -/** - * Get the struct.property as a python representation, eg: - * some_struct.some_prop[10] - */ char *RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index) { char *data_path; @@ -6205,10 +6028,6 @@ char *RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index) return ret; } -/** - * Get the struct.property as a python representation, eg: - * some_prop[10] - */ char *RNA_path_property_py(const PointerRNA *UNUSED(ptr), PropertyRNA *prop, int index) { char *ret; @@ -6678,7 +6497,6 @@ bool RNA_property_is_idprop(const PropertyRNA *prop) return (prop->magic != RNA_MAGIC); } -/* mainly for the UI */ bool RNA_property_is_unlink(PropertyRNA *prop) { const int flag = RNA_property_flag(prop); @@ -6688,9 +6506,6 @@ bool RNA_property_is_unlink(PropertyRNA *prop) return (flag & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0; } -/* string representation of a property, python - * compatible but can be used for display too, - * context may be NULL */ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr) { DynStr *dynstr = BLI_dynstr_new(); @@ -6752,7 +6567,6 @@ char *RNA_pointer_as_string(bContext *C, return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop); } -/* context can be NULL */ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, const bool as_function, @@ -8115,7 +7929,6 @@ bool RNA_property_assign_default(PointerRNA *ptr, PropertyRNA *prop) } } -/* use RNA_warning macro which includes __func__ suffix */ void _RNA_warning(const char *format, ...) { va_list args; diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index be8972dbff3..35af92592e9 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -126,8 +126,6 @@ int RNA_property_override_flag(PropertyRNA *prop) return rna_ensure_property(prop)->flag_override; } -/** \note Does not take into account editable status, this has to be checked separately - * (using #RNA_property_editable_flag() usually). */ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop) { if (prop->magic == RNA_MAGIC) { @@ -170,7 +168,6 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop) return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0; } -/* Should only be used for custom properties */ bool RNA_property_overridable_library_set(PointerRNA *UNUSED(ptr), PropertyRNA *prop, const bool is_overridable) @@ -614,37 +611,27 @@ static bool rna_property_override_operation_apply(Main *bmain, } /* get and set the default values as appropriate for the various types */ - const bool sucess = override_apply(bmain, - ptr_dst, - ptr_src, - ptr_storage, - prop_dst, - prop_src, - prop_storage, - len_dst, - len_src, - len_storage, - ptr_item_dst, - ptr_item_src, - ptr_item_storage, - opop); - if (sucess) { + const bool success = override_apply(bmain, + ptr_dst, + ptr_src, + ptr_storage, + prop_dst, + prop_src, + prop_storage, + len_dst, + len_src, + len_storage, + ptr_item_dst, + ptr_item_src, + ptr_item_storage, + opop); + if (success) { RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst); } - return sucess; + return success; } -/** - * Check whether reference and local overridden data match (are the same), - * with respect to given restrictive sets of properties. - * If requested, will generate needed new property overrides, and/or restore values from reference. - * - * \param r_report_flags: If given, - * will be set with flags matching actions taken by the function on \a ptr_local. - * - * \return True if _resulting_ \a ptr_local does match \a ptr_reference. - */ bool RNA_struct_override_matches(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, @@ -928,10 +915,6 @@ bool RNA_struct_override_matches(Main *bmain, return matching; } -/** - * Store needed second operands into \a storage data-block - * for differential override operations. - */ bool RNA_struct_override_store(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, @@ -1076,7 +1059,12 @@ static void rna_porperty_override_collection_subitem_lookup( *r_ptr_item_storage = private_ptr_item_storage; } - if ((*r_ptr_item_dst)->type == NULL) { + /* Note that there is no reason to report in case no item is expected, i.e. in case subitem name + * and index are invalid. This can often happen when inserting new items (constraint, + * modifier...) in a collection that supports it. */ + if ((*r_ptr_item_dst)->type == NULL && + ((opop->subitem_reference_name != NULL && opop->subitem_reference_name[0] != '\0') || + opop->subitem_reference_index != -1)) { CLOG_INFO(&LOG, 2, "Failed to find destination sub-item '%s' (%d) of '%s' in new override data '%s'", @@ -1085,7 +1073,9 @@ static void rna_porperty_override_collection_subitem_lookup( op->rna_path, ptr_dst->owner_id->name); } - if ((*r_ptr_item_src)->type == NULL) { + if ((*r_ptr_item_src)->type == NULL && + ((opop->subitem_local_name != NULL && opop->subitem_local_name[0] != '\0') || + opop->subitem_local_index != -1)) { CLOG_INFO(&LOG, 2, "Failed to find source sub-item '%s' (%d) of '%s' in old override data '%s'", @@ -1195,10 +1185,6 @@ static void rna_property_override_apply_ex(Main *bmain, } } -/** - * Apply given \a override operations on \a ptr_dst, using \a ptr_src - * (and \a ptr_storage for differential ops) as source. - */ void RNA_struct_override_apply(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_src, diff --git a/source/blender/makesrna/intern/rna_access_internal.h b/source/blender/makesrna/intern/rna_access_internal.h index 73407123863..9f1be5bbd67 100644 --- a/source/blender/makesrna/intern/rna_access_internal.h +++ b/source/blender/makesrna/intern/rna_access_internal.h @@ -27,6 +27,13 @@ struct IDProperty; struct PropertyRNAOrID; +/** + * This function initializes a #PropertyRNAOrID with all required info, from a given #PropertyRNA + * and #PointerRNA data. It deals properly with the three cases + * (static RNA, runtime RNA, and #IDProperty). + * \warning given `ptr` #PointerRNA is assumed to be a valid data one here, calling code is + * responsible to ensure that. + */ void rna_property_rna_or_id_get(PropertyRNA *prop, PointerRNA *ptr, PropertyRNAOrID *r_prop_rna_or_id); diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 2aa09a30c75..96e37dfebbb 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -246,12 +246,60 @@ static void rna_Action_active_pose_marker_index_range( *max = max_ii(0, BLI_listbase_count(&act->markers) - 1); } -static void rna_Action_frame_range_get(PointerRNA *ptr, float *values) +static void rna_Action_frame_range_get(PointerRNA *ptr, float *r_values) +{ + BKE_action_get_frame_range((bAction *)ptr->owner_id, &r_values[0], &r_values[1]); +} + +static void rna_Action_frame_range_set(PointerRNA *ptr, const float *values) +{ + bAction *data = (bAction *)ptr->owner_id; + + data->flag |= ACT_FRAME_RANGE; + data->frame_start = values[0]; + data->frame_end = values[1]; + CLAMP_MIN(data->frame_end, data->frame_start); +} + +static void rna_Action_curve_frame_range_get(PointerRNA *ptr, float *values) { /* don't include modifiers because they too easily can have very large * ranges: MINAFRAMEF to MAXFRAMEF. */ calc_action_range((bAction *)ptr->owner_id, values, values + 1, false); } +static void rna_Action_use_frame_range_set(PointerRNA *ptr, bool value) +{ + bAction *data = (bAction *)ptr->owner_id; + + if (value) { + /* If the frame range is blank, initialize it by scanning F-Curves. */ + if ((data->frame_start == data->frame_end) && (data->frame_start == 0)) { + calc_action_range(data, &data->frame_start, &data->frame_end, false); + } + + data->flag |= ACT_FRAME_RANGE; + } + else { + data->flag &= ~ACT_FRAME_RANGE; + } +} + +static void rna_Action_start_frame_set(PointerRNA *ptr, float value) +{ + bAction *data = (bAction *)ptr->owner_id; + + data->frame_start = value; + CLAMP_MIN(data->frame_end, data->frame_start); +} + +static void rna_Action_end_frame_set(PointerRNA *ptr, float value) +{ + bAction *data = (bAction *)ptr->owner_id; + + data->frame_end = value; + CLAMP_MAX(data->frame_start, data->frame_end); +} + /* Used to check if an action (value pointer) * is suitable to be assigned to the ID-block that is ptr. */ bool rna_Action_id_poll(PointerRNA *ptr, PointerRNA value) @@ -834,17 +882,73 @@ static void rna_def_action(BlenderRNA *brna) rna_def_action_pose_markers(brna, prop); /* properties */ + prop = RNA_def_property(srna, "use_frame_range", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_FRAME_RANGE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Action_use_frame_range_set"); + RNA_def_property_ui_text( + prop, + "Manual Frame Range", + "Manually specify the intended playback frame range for the action " + "(this range is used by some tools, but does not affect animation evaluation)"); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CYCLIC); + RNA_def_property_ui_text( + prop, + "Cyclic Animation", + "The action is intended to be used as a cycle looping over its manually set " + "playback frame range (enabling this doesn't automatically make it loop)"); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_float_sdna(prop, NULL, "frame_start"); + RNA_def_property_float_funcs(prop, NULL, "rna_Action_start_frame_set", NULL); + RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 0); + RNA_def_property_ui_text( + prop, "Start Frame", "The start frame of the manually set intended playback range"); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + + prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_TIME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_float_sdna(prop, NULL, "frame_end"); + RNA_def_property_float_funcs(prop, NULL, "rna_Action_end_frame_set", NULL); + RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 100, 0); + RNA_def_property_ui_text( + prop, "End Frame", "The end frame of the manually set intended playback range"); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + + prop = RNA_def_float_vector( + srna, + "frame_range", + 2, + NULL, + 0, + 0, + "Frame Range", + "The intended playback frame range of this action, using the manually set range " + "if available, or the combined frame range of all F-Curves within this action " + "if not (assigning sets the manual frame range)", + 0, + 0); + RNA_def_property_float_funcs( + prop, "rna_Action_frame_range_get", "rna_Action_frame_range_set", NULL); + RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + prop = RNA_def_float_vector(srna, - "frame_range", + "curve_frame_range", 2, NULL, 0, 0, - "Frame Range", - "The final frame range of all F-Curves within this action", + "Curve Frame Range", + "The combined frame range of all F-Curves within this action", 0, 0); - RNA_def_property_float_funcs(prop, "rna_Action_frame_range_get", NULL, NULL); + RNA_def_property_float_funcs(prop, "rna_Action_curve_frame_range_get", NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* special "type" limiter - should not really be edited in general, diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 690506fa517..7a934443907 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -669,10 +669,10 @@ static void rna_Armature_transform(bArmature *arm, float mat[16]) #else -/* Settings for curved bbone settings - - * The posemode values get applied over the top of the editmode ones. */ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone, bool is_editbone) { + /* NOTE: The pose-mode values get applied over the top of the edit-mode ones. */ + # define RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone) \ { \ if (is_posebone) { \ diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index 5d83da170b5..e79cbc838d4 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -307,7 +307,7 @@ const EnumPropertyItem *rna_asset_library_reference_itemf(bContext *UNUSED(C), PropertyRNA *UNUSED(prop), bool *r_free) { - const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(); + const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(true); if (!items) { *r_free = false; } @@ -493,9 +493,6 @@ static void rna_def_asset_library_reference(BlenderRNA *brna) srna, "Asset Library Reference", "Identifier to refer to the asset library"); } -/** - * \note the UI text and updating has to be set by the caller. - */ PropertyRNA *rna_def_asset_library_reference_common(struct StructRNA *srna, const char *get, const char *set) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index bde348c1848..0c993660f39 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -3446,7 +3446,8 @@ static void rna_def_constraint_transform_cache(BlenderRNA *brna) RNA_define_lib_overridable(false); } -/* base struct for constraints */ +/* Define the base struct for constraints. */ + void RNA_def_constraint(BlenderRNA *brna) { StructRNA *srna; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 8c89162f571..6cca0c51988 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -141,8 +141,6 @@ const EnumPropertyItem rna_enum_beztriple_interpolation_mode_items[] = { static const EnumPropertyItem curve_type_items[] = { {CU_POLY, "POLY", 0, "Poly", ""}, {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, - {CU_BSPLINE, "BSPLINE", 0, "BSpline", ""}, - {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, {CU_NURBS, "NURBS", 0, "Ease", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -569,13 +567,13 @@ static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, Pointe static float rna_Curve_offset_get(PointerRNA *ptr) { Curve *cu = (Curve *)ptr->owner_id; - return cu->width - 1.0f; + return cu->offset - 1.0f; } static void rna_Curve_offset_set(PointerRNA *ptr, float value) { Curve *cu = (Curve *)ptr->owner_id; - cu->width = 1.0f + value; + cu->offset = 1.0f + value; } static int rna_Curve_body_length(PointerRNA *ptr); @@ -1656,14 +1654,14 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_bevel_resolution_update"); prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "width"); + RNA_def_property_float_sdna(prop, NULL, "offset"); RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3); RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL); RNA_def_property_ui_text(prop, "Offset", "Distance to move the curve parallel to its normals"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "ext1"); + RNA_def_property_float_sdna(prop, NULL, "extrude"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3); RNA_def_property_range(prop, 0.0, FLT_MAX); RNA_def_property_ui_text(prop, @@ -1673,7 +1671,7 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH); - RNA_def_property_float_sdna(prop, NULL, "ext2"); + RNA_def_property_float_sdna(prop, NULL, "bevel_radius"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3); RNA_def_property_ui_text( prop, "Bevel Depth", "Radius of the bevel geometry, not including extrusion"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index bd5ade36eaa..b17ca7d8d59 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -753,10 +753,6 @@ void RNA_define_verify_sdna(bool verify) DefRNA.verify = verify; } -/** - * Properties defined when this is enabled are lib-overridable by default (except for Pointer - * ones). - */ void RNA_define_lib_overridable(const bool make_overridable) { DefRNA.make_overridable = make_overridable; @@ -915,7 +911,6 @@ static StructDefRNA *rna_find_def_struct(StructRNA *srna) return NULL; } -/* Struct Definition */ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom) { StructRNA *srna; @@ -1243,9 +1238,6 @@ void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *id srna->identifier = identifier; } -/** - * Only used in one case when we name the struct for the purpose of useful error messages. - */ void RNA_def_struct_identifier_no_struct_map(StructRNA *srna, const char *identifier) { if (DefRNA.preprocess) { @@ -1532,13 +1524,6 @@ void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFla prop->flag_override &= ~flag; } -/** - * Add the property-tags passed as \a tags to \a prop (if valid). - * - * \note Multiple tags can be set by passing them within \a tags (using bitflags). - * \note Doesn't do any type-checking with the tags defined in the parent StructRNA - * of \a prop. This should be done before (e.g. see #WM_operatortype_prop_tag). - */ void RNA_def_property_tags(PropertyRNA *prop, int tags) { prop->tags |= tags; @@ -1616,12 +1601,10 @@ void RNA_def_property_array(PropertyRNA *prop, int length) } } -/* common args for defaults. */ const float rna_default_quaternion[4] = {1, 0, 0, 0}; const float rna_default_axis_angle[4] = {0, 0, 1, 0}; const float rna_default_scale_3d[3] = {1, 1, 1}; -/* common args for length */ const int rna_matrix_dimsize_3x3[] = {3, 3}; const int rna_matrix_dimsize_4x4[] = {4, 4}; const int rna_matrix_dimsize_4x2[] = {4, 2}; @@ -1692,17 +1675,6 @@ void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive) } } -/** - * The values hare are a little confusing: - * - * \param step: Used as the value to increase/decrease when clicking on number buttons, - * as well as scaling mouse input for click-dragging number buttons. - * For floats this is (step * UI_PRECISION_FLOAT_SCALE), why? - nobody knows. - * For ints, whole values are used. - * - * \param precision: The number of zeros to show - * (as a whole number - common range is 1 - 6), see UI_PRECISION_FLOAT_MAX - */ void RNA_def_property_ui_range( PropertyRNA *prop, double min, double max, double step, int precision) { @@ -2082,7 +2054,6 @@ void RNA_def_property_float_default(PropertyRNA *prop, float value) break; } } -/* array must remain valid after this function finishes */ void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array) { StructRNA *srna = DefRNA.laststruct; @@ -2920,11 +2891,6 @@ void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editabl } } -/** - * Set custom callbacks for override operations handling. - * - * \note \a diff callback will also be used by RNA comparison/equality functions. - */ void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, @@ -3813,7 +3779,6 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, return prop; } -/* same as above but sets 'PROP_ENUM_FLAG' before setting the default value */ PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, @@ -4320,7 +4285,6 @@ FunctionRNA *RNA_def_function_runtime(StructRNA *srna, const char *identifier, C return func; } -/* C return value only!, multiple RNA returns can be done with RNA_def_function_output */ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret) { if (ret->flag & PROP_DYNAMIC) { diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 82f3279146a..e06aac31124 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -28,6 +28,7 @@ #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" #include "DNA_mesh_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -144,6 +145,11 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { ICON_MOD_OFFSET, "Offset", "Change stroke location, rotation or scale"}, + {eGpencilModifierType_Shrinkwrap, + "SHRINKWRAP", + ICON_MOD_SHRINKWRAP, + "Shrinkwrap", + "Project the shape onto another object"}, {eGpencilModifierType_Smooth, "GP_SMOOTH", ICON_MOD_SMOOTH, "Smooth", "Smooth stroke"}, {eGpencilModifierType_Thick, "GP_THICK", @@ -269,6 +275,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr) return &RNA_LengthGpencilModifier; case eGpencilModifierType_Mirror: return &RNA_MirrorGpencilModifier; + case eGpencilModifierType_Shrinkwrap: + return &RNA_ShrinkwrapGpencilModifier; case eGpencilModifierType_Smooth: return &RNA_SmoothGpencilModifier; case eGpencilModifierType_Hook: @@ -360,6 +368,7 @@ RNA_GP_MOD_VGROUP_NAME_SET(WeightProx, vgname); RNA_GP_MOD_VGROUP_NAME_SET(WeightAngle, target_vgname); RNA_GP_MOD_VGROUP_NAME_SET(WeightAngle, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Lineart, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Shrinkwrap, vgname); # undef RNA_GP_MOD_VGROUP_NAME_SET @@ -392,6 +401,8 @@ RNA_GP_MOD_OBJECT_SET(Armature, object, OB_ARMATURE); RNA_GP_MOD_OBJECT_SET(Lattice, object, OB_LATTICE); RNA_GP_MOD_OBJECT_SET(Mirror, object, OB_EMPTY); RNA_GP_MOD_OBJECT_SET(WeightProx, object, OB_EMPTY); +RNA_GP_MOD_OBJECT_SET(Shrinkwrap, target, OB_MESH); +RNA_GP_MOD_OBJECT_SET(Shrinkwrap, aux_target, OB_MESH); # undef RNA_GP_MOD_OBJECT_SET @@ -685,6 +696,16 @@ static void rna_TextureGpencilModifier_material_set(PointerRNA *ptr, rna_GpencilModifier_material_set(ptr, value, ma_target, reports); } +static void rna_ShrinkwrapGpencilModifier_material_set(PointerRNA *ptr, + PointerRNA value, + struct ReportList *reports) +{ + ShrinkwrapGpencilModifierData *tmd = (ShrinkwrapGpencilModifierData *)ptr->data; + Material **ma_target = &tmd->material; + + rna_GpencilModifier_material_set(ptr, value, ma_target, reports); +} + static void rna_Lineart_start_level_set(PointerRNA *ptr, int value) { LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)ptr->data; @@ -756,6 +777,18 @@ static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char BKE_animdata_fix_paths_rename_all(NULL, prefix, oldname, ds->name); } +static int rna_ShrinkwrapGpencilModifier_face_cull_get(PointerRNA *ptr) +{ + ShrinkwrapGpencilModifierData *swm = (ShrinkwrapGpencilModifierData *)ptr->data; + return swm->shrink_opts & MOD_SHRINKWRAP_CULL_TARGET_MASK; +} + +static void rna_ShrinkwrapGpencilModifier_face_cull_set(struct PointerRNA *ptr, int value) +{ + ShrinkwrapGpencilModifierData *swm = (ShrinkwrapGpencilModifierData *)ptr->data; + swm->shrink_opts = (swm->shrink_opts & ~MOD_SHRINKWRAP_CULL_TARGET_MASK) | value; +} + #else static void rna_def_modifier_gpencilnoise(BlenderRNA *brna) @@ -3455,6 +3488,43 @@ static void rna_def_modifier_gpencillength(BlenderRNA *brna) RNA_def_property_ui_text(prop, "End Factor", "Absolute added length to the end of each stroke"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "random_start_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rand_start_fac"); + RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 1); + RNA_def_property_ui_text( + prop, "Random Start Factor", "Size of random length added to the start of each stroke"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "random_end_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rand_end_fac"); + RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 1); + RNA_def_property_ui_text( + prop, "Random End Factor", "Size of random length added to the end of each stroke"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "random_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rand_offset"); + RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 3); + RNA_def_property_ui_text( + prop, "Random Noise Offset", "Smoothly offset each stroke's random value"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_random", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LENGTH_USE_RANDOM); + RNA_def_property_ui_text(prop, "Random", "Use random values over time"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); + RNA_def_property_ui_text(prop, "Seed", "Random seed"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "step"); + RNA_def_property_range(prop, 1, 100); + RNA_def_property_ui_text( + prop, "Step", "Number of frames before recalculate random values again"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "overshoot_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "overshoot_fac"); RNA_def_property_range(prop, 0.0f, 1.0f); @@ -3683,6 +3753,194 @@ static void rna_def_modifier_gpencildash(BlenderRNA *brna) RNA_define_lib_overridable(false); } +static void rna_def_modifier_gpencilshrinkwrap(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShrinkwrapGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, + "Shrinkwrap Modifier", + "Shrink wrapping modifier to shrink wrap and object to a target"); + RNA_def_struct_sdna(srna, "ShrinkwrapGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SHRINKWRAP); + + RNA_define_lib_overridable(true); + + prop = RNA_def_property(srna, "wrap_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shrink_type"); + RNA_def_property_enum_items(prop, rna_enum_shrinkwrap_type_items); + RNA_def_property_ui_text(prop, "Wrap Method", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "wrap_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shrink_mode"); + RNA_def_property_enum_items(prop, rna_enum_modifier_shrinkwrap_mode_items); + RNA_def_property_ui_text( + prop, "Snap Mode", "Select how vertices are constrained to the target surface"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "cull_face", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shrink_opts"); + RNA_def_property_enum_items(prop, rna_enum_shrinkwrap_face_cull_items); + RNA_def_property_enum_funcs(prop, + "rna_ShrinkwrapGpencilModifier_face_cull_get", + "rna_ShrinkwrapGpencilModifier_face_cull_set", + NULL); + RNA_def_property_ui_text( + prop, + "Face Cull", + "Stop vertices from projecting to a face on the target when facing towards/away"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Target", "Mesh target to shrink to"); + RNA_def_property_pointer_funcs( + prop, NULL, "rna_ShrinkwrapGpencilModifier_target_set", NULL, "rna_Mesh_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "auxiliary_target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "aux_target"); + RNA_def_property_ui_text(prop, "Auxiliary Target", "Additional mesh target to shrink to"); + RNA_def_property_pointer_funcs( + prop, NULL, "rna_ShrinkwrapGpencilModifier_aux_target_set", NULL, "rna_Mesh_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "keep_dist"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, -100, 100, 1, 2); + RNA_def_property_ui_text(prop, "Offset", "Distance to keep from the target"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "project_limit", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "proj_limit"); + 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_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_project_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "proj_axis", MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS); + RNA_def_property_ui_text(prop, "X", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_project_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "proj_axis", MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS); + RNA_def_property_ui_text(prop, "Y", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_project_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "proj_axis", MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS); + RNA_def_property_ui_text(prop, "Z", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "subsurf_levels", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "subsurf_levels"); + RNA_def_property_range(prop, 0, 6); + RNA_def_property_ui_range(prop, 0, 6, 1, -1); + RNA_def_property_ui_text( + prop, + "Subdivision Levels", + "Number of subdivisions that must be performed before extracting vertices' " + "positions and normals"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_negative_direction", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shrink_opts", MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR); + RNA_def_property_ui_text( + prop, "Negative", "Allow vertices to move in the negative direction of axis"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_positive_direction", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shrink_opts", MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR); + RNA_def_property_ui_text( + prop, "Positive", "Allow vertices to move in the positive direction of axis"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_invert_cull", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shrink_opts", MOD_SHRINKWRAP_INVERT_CULL_TARGET); + RNA_def_property_ui_text( + prop, "Invert Cull", "When projecting in the negative direction invert the face cull mode"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layername"); + RNA_def_property_ui_text(prop, "Layer", "Layer name"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, + NULL, + "rna_ShrinkwrapGpencilModifier_material_set", + NULL, + "rna_GpencilModifier_material_poll"); + RNA_def_property_ui_text(prop, "Material", "Material used for filtering effect"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShrinkwrapGpencilModifier_vgname_set"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "pass_index"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SHRINKWRAP_INVERT_LAYER); + RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_materials", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SHRINKWRAP_INVERT_MATERIAL); + RNA_def_property_ui_text(prop, "Inverse Materials", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SHRINKWRAP_INVERT_PASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SHRINKWRAP_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Inverse VertexGroup", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "layer_pass"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Pass", "Layer pass index"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SHRINKWRAP_INVERT_LAYERPASS); + RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "smooth_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "smooth_factor"); + RNA_def_property_range(prop, 0, 1); + RNA_def_property_ui_text(prop, "Smooth Factor", "Amount of smoothing to apply"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "smooth_step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "smooth_step"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_text( + prop, "Step", "Number of times to apply smooth (high numbers can reduce FPS)"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + RNA_define_lib_overridable(false); +} + void RNA_def_greasepencil_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -3772,6 +4030,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna) rna_def_modifier_gpencillineart(brna); rna_def_modifier_gpencillength(brna); rna_def_modifier_gpencildash(brna); + rna_def_modifier_gpencilshrinkwrap(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 4b52ceb6241..7d2697c8770 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -213,11 +213,17 @@ static void rna_Image_scale(Image *image, ReportList *reports, int width, int he } } -static int rna_Image_gl_load(Image *image, ReportList *reports, int frame) +static int rna_Image_gl_load( + Image *image, ReportList *reports, int frame, int layer_index, int pass_index) { ImageUser iuser; BKE_imageuser_default(&iuser); iuser.framenr = frame; + iuser.layer = layer_index; + iuser.pass = pass_index; + if (image->rr != NULL) { + BKE_image_multilayer_index(image->rr, &iuser); + } GPUTexture *tex = BKE_image_get_gpu_texture(image, &iuser, NULL); @@ -230,14 +236,15 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame) return 0; /* GL_NO_ERROR */ } -static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame) +static int rna_Image_gl_touch( + Image *image, ReportList *reports, int frame, int layer_index, int pass_index) { int error = 0; /* GL_NO_ERROR */ BKE_image_tag_time(image); if (image->gputexture[TEXTARGET_2D][0] == NULL) { - error = rna_Image_gl_load(image, reports, frame); + error = rna_Image_gl_load(image, reports, frame, layer_index, pass_index); } return error; @@ -332,6 +339,24 @@ void RNA_api_image(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int( func, "frame", 0, 0, INT_MAX, "Frame", "Frame of image sequence or movie", 0, INT_MAX); + RNA_def_int(func, + "layer_index", + 0, + 0, + INT_MAX, + "Layer", + "Index of layer that should be loaded", + 0, + INT_MAX); + RNA_def_int(func, + "pass_index", + 0, + 0, + INT_MAX, + "Pass", + "Index of pass that should be loaded", + 0, + INT_MAX); /* return value */ parm = RNA_def_int( func, "error", 0, -INT_MAX, INT_MAX, "Error", "OpenGL error value", -INT_MAX, INT_MAX); @@ -346,6 +371,24 @@ void RNA_api_image(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int( func, "frame", 0, 0, INT_MAX, "Frame", "Frame of image sequence or movie", 0, INT_MAX); + RNA_def_int(func, + "layer_index", + 0, + 0, + INT_MAX, + "Layer", + "Index of layer that should be loaded", + 0, + INT_MAX); + RNA_def_int(func, + "pass_index", + 0, + 0, + INT_MAX, + "Pass", + "Index of pass that should be loaded", + 0, + INT_MAX); /* return value */ parm = RNA_def_int( func, "error", 0, -INT_MAX, INT_MAX, "Error", "OpenGL error value", -INT_MAX, INT_MAX); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index fd6664ff0de..c1989a5b10d 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -251,6 +251,9 @@ bool rna_AnimaData_override_apply(struct Main *bmain, void rna_def_animviz_common(struct StructRNA *srna); void rna_def_motionpath_common(struct StructRNA *srna); +/** + * Settings for curved bbone settings. + */ void rna_def_bone_curved_common(struct StructRNA *srna, bool is_posebone, bool is_editbone); void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable); @@ -268,6 +271,9 @@ void rna_def_texpaint_slots(struct BlenderRNA *brna, struct StructRNA *srna); void rna_def_view_layer_common(struct BlenderRNA *brna, struct StructRNA *srna, const bool scene); int rna_AssetMetaData_editable(struct PointerRNA *ptr, const char **r_info); +/** + * \note the UI text and updating has to be set by the caller. + */ PropertyRNA *rna_def_asset_library_reference_common(struct StructRNA *srna, const char *get, const char *set); @@ -276,6 +282,9 @@ const EnumPropertyItem *rna_asset_library_reference_itemf(struct bContext *C, struct PropertyRNA *prop, bool *r_free); +/** + * Common properties for Action/Bone Groups - related to color. + */ void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb); @@ -509,8 +518,16 @@ extern StructRNA RNA_PropertyGroupItem; extern StructRNA RNA_PropertyGroup; #endif +/** + * This function only returns an #IDProperty, + * or NULL (in case IDProp could not be found, or prop is a real RNA property). + */ struct IDProperty *rna_idproperty_check(struct PropertyRNA **prop, struct PointerRNA *ptr) ATTR_WARN_UNUSED_RESULT; +/** + * This function always return the valid, real data pointer, be it a regular RNA property one, + * or an #IDProperty one. + */ struct PropertyRNA *rna_ensure_property_realdata(struct PropertyRNA **prop, struct PointerRNA *ptr) ATTR_WARN_UNUSED_RESULT; struct PropertyRNA *rna_ensure_property(struct PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c index 8cd1ac0d963..93e8e4bc31e 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -949,8 +949,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Period", "Period of the noise"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "seed"); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Seed", "Seed for the noise generation"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); @@ -1051,8 +1052,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Period", "Period of the noise"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "seed"); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Seed", "Seed for the noise generation"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); @@ -1191,8 +1193,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Period", "Period of the noise"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "seed"); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Seed", "Seed for the noise generation"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); @@ -1306,8 +1309,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna) srna, "Sinus Displacement", "Add sinus displacement to stroke backbone geometry"); rna_def_geometry_modifier(srna); - prop = RNA_def_property(srna, "wavelength", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "wavelength", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "wavelength"); + RNA_def_property_range(prop, 0.0001f, FLT_MAX); RNA_def_property_ui_text(prop, "Wavelength", "Wavelength of the sinus displacement"); RNA_def_property_update(prop, NC_LINESTYLE, "rna_LineStyle_update"); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 464abc6b543..a162aa26b78 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -56,9 +56,10 @@ static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), bool value) } } -static bool rna_Main_is_saved_get(PointerRNA *UNUSED(ptr)) +static bool rna_Main_is_saved_get(PointerRNA *ptr) { - return G.relbase_valid; + const Main *bmain = (Main *)ptr->data; + return (bmain->filepath[0] != '\0'); } static bool rna_Main_is_dirty_get(PointerRNA *ptr) @@ -76,20 +77,20 @@ static bool rna_Main_is_dirty_get(PointerRNA *ptr) static void rna_Main_filepath_get(PointerRNA *ptr, char *value) { Main *bmain = (Main *)ptr->data; - BLI_strncpy(value, bmain->name, sizeof(bmain->name)); + BLI_strncpy(value, bmain->filepath, sizeof(bmain->filepath)); } static int rna_Main_filepath_length(PointerRNA *ptr) { Main *bmain = (Main *)ptr->data; - return strlen(bmain->name); + return strlen(bmain->filepath); } # if 0 static void rna_Main_filepath_set(PointerRNA *ptr, const char *value) { Main *bmain = (Main *)ptr->data; - BLI_strncpy(bmain->name, value, sizeof(bmain->name)); + STRNCPY(bmain->filepath, value); } # endif diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 9ad6771cda3..d46ae13b482 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -381,6 +381,42 @@ const EnumPropertyItem rna_enum_modifier_shrinkwrap_mode_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_shrinkwrap_type_items[] = { + {MOD_SHRINKWRAP_NEAREST_SURFACE, + "NEAREST_SURFACEPOINT", + 0, + "Nearest Surface Point", + "Shrink the mesh to the nearest target surface"}, + {MOD_SHRINKWRAP_PROJECT, + "PROJECT", + 0, + "Project", + "Shrink the mesh to the nearest target surface along a given axis"}, + {MOD_SHRINKWRAP_NEAREST_VERTEX, + "NEAREST_VERTEX", + 0, + "Nearest Vertex", + "Shrink the mesh to the nearest target vertex"}, + {MOD_SHRINKWRAP_TARGET_PROJECT, + "TARGET_PROJECT", + 0, + "Target Normal Project", + "Shrink the mesh to the nearest target surface " + "along the interpolated vertex normals of the target"}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_shrinkwrap_face_cull_items[] = { + {0, "OFF", 0, "Off", "No culling"}, + {MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE, + "FRONT", + 0, + "Front", + "No projection when in front of the face"}, + {MOD_SHRINKWRAP_CULL_TARGET_BACKFACE, "BACK", 0, "Back", "No projection when behind the face"}, + {0, NULL, 0, NULL, NULL}, +}; + #ifndef RNA_RUNTIME /* use eWarp_Falloff_*** & eHook_Falloff_***, they're in sync */ static const EnumPropertyItem modifier_warp_falloff_items[] = { @@ -4184,46 +4220,6 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem shrink_type_items[] = { - {MOD_SHRINKWRAP_NEAREST_SURFACE, - "NEAREST_SURFACEPOINT", - 0, - "Nearest Surface Point", - "Shrink the mesh to the nearest target surface"}, - {MOD_SHRINKWRAP_PROJECT, - "PROJECT", - 0, - "Project", - "Shrink the mesh to the nearest target surface along a given axis"}, - {MOD_SHRINKWRAP_NEAREST_VERTEX, - "NEAREST_VERTEX", - 0, - "Nearest Vertex", - "Shrink the mesh to the nearest target vertex"}, - {MOD_SHRINKWRAP_TARGET_PROJECT, - "TARGET_PROJECT", - 0, - "Target Normal Project", - "Shrink the mesh to the nearest target surface " - "along the interpolated vertex normals of the target"}, - {0, NULL, 0, NULL, NULL}, - }; - - static const EnumPropertyItem shrink_face_cull_items[] = { - {0, "OFF", 0, "Off", "No culling"}, - {MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE, - "FRONT", - 0, - "Front", - "No projection when in front of the face"}, - {MOD_SHRINKWRAP_CULL_TARGET_BACKFACE, - "BACK", - 0, - "Back", - "No projection when behind the face"}, - {0, NULL, 0, NULL, NULL}, - }; - srna = RNA_def_struct(brna, "ShrinkwrapModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Shrinkwrap Modifier", @@ -4235,7 +4231,7 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) prop = RNA_def_property(srna, "wrap_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shrinkType"); - RNA_def_property_enum_items(prop, shrink_type_items); + RNA_def_property_enum_items(prop, rna_enum_shrinkwrap_type_items); RNA_def_property_ui_text(prop, "Wrap Method", ""); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -4248,7 +4244,7 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) prop = RNA_def_property(srna, "cull_face", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shrinkOpts"); - RNA_def_property_enum_items(prop, shrink_face_cull_items); + RNA_def_property_enum_items(prop, rna_enum_shrinkwrap_face_cull_items); RNA_def_property_enum_funcs( prop, "rna_ShrinkwrapModifier_face_cull_get", "rna_ShrinkwrapModifier_face_cull_set", NULL); RNA_def_property_ui_text( diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index b19836a7f12..230133a8f9d 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -885,6 +885,8 @@ static void rna_def_nlatrack(BlenderRNA *brna) RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_ui_text(prop, "NLA Strips", "NLA Strips on this NLA-track"); + rna_api_nlatrack_strips(brna, prop); + prop = RNA_def_boolean(srna, "is_override_data", false, @@ -894,8 +896,6 @@ static void rna_def_nlatrack(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", NLATRACK_OVERRIDELIBRARY_LOCAL); - rna_api_nlatrack_strips(brna, prop); - RNA_define_lib_overridable(true); /* name property */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index aef3823338b..df0271d81d5 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -39,6 +39,7 @@ #include "BKE_animsys.h" #include "BKE_attribute.h" #include "BKE_cryptomatte.h" +#include "BKE_geometry_set.h" #include "BKE_image.h" #include "BKE_node.h" #include "BKE_texture.h" @@ -304,36 +305,68 @@ const EnumPropertyItem rna_enum_node_boolean_math_items[] = { }; const EnumPropertyItem rna_enum_node_float_compare_items[] = { - {NODE_FLOAT_COMPARE_LESS_THAN, + {NODE_COMPARE_LESS_THAN, "LESS_THAN", 0, "Less Than", "True when the first input is smaller than second input"}, - {NODE_FLOAT_COMPARE_LESS_EQUAL, + {NODE_COMPARE_LESS_EQUAL, "LESS_EQUAL", 0, "Less Than or Equal", "True when the first input is smaller than the second input or equal"}, - {NODE_FLOAT_COMPARE_GREATER_THAN, + {NODE_COMPARE_GREATER_THAN, "GREATER_THAN", 0, "Greater Than", "True when the first input is greater than the second input"}, - {NODE_FLOAT_COMPARE_GREATER_EQUAL, + {NODE_COMPARE_GREATER_EQUAL, "GREATER_EQUAL", 0, "Greater Than or Equal", "True when the first input is greater than the second input or equal"}, - {NODE_FLOAT_COMPARE_EQUAL, - "EQUAL", + {NODE_COMPARE_EQUAL, "EQUAL", 0, "Equal", "True when both inputs are approximately equal"}, + {NODE_COMPARE_NOT_EQUAL, + "NOT_EQUAL", + 0, + "Not Equal", + "True when both inputs are not approximately equal"}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_node_compare_operation_items[] = { + {NODE_COMPARE_LESS_THAN, + "LESS_THAN", + 0, + "Less Than", + "True when the first input is smaller than second input"}, + {NODE_COMPARE_LESS_EQUAL, + "LESS_EQUAL", + 0, + "Less Than or Equal", + "True when the first input is smaller than the second input or equal"}, + {NODE_COMPARE_GREATER_THAN, + "GREATER_THAN", 0, - "Equal", - "True when both inputs are approximately equal"}, - {NODE_FLOAT_COMPARE_NOT_EQUAL, + "Greater Than", + "True when the first input is greater than the second input"}, + {NODE_COMPARE_GREATER_EQUAL, + "GREATER_EQUAL", + 0, + "Greater Than or Equal", + "True when the first input is greater than the second input or equal"}, + {NODE_COMPARE_EQUAL, "EQUAL", 0, "Equal", "True when both inputs are approximately equal"}, + {NODE_COMPARE_NOT_EQUAL, "NOT_EQUAL", 0, "Not Equal", "True when both inputs are not approximately equal"}, + {NODE_COMPARE_COLOR_BRIGHTER, + "BRIGHTER", + 0, + "Brighter", + "True when the first input is brighter"}, + {NODE_COMPARE_COLOR_DARKER, "DARKER", 0, "Darker", "True when the first input is darker"}, {0, NULL, 0, NULL, NULL}, }; @@ -1235,10 +1268,15 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, ntreeTexCheckCyclics(ntree); } - ntreeUpdateTree(CTX_data_main(C), ntree); + Main *bmain = CTX_data_main(C); + ntreeUpdateTree(bmain, ntree); nodeUpdate(ntree, node); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); + if (node->type == GEO_NODE_INPUT_SCENE_TIME) { + DEG_relations_tag_update(bmain); + } + return node; } @@ -1853,7 +1891,7 @@ static void rna_Node_draw_buttons_ext(struct uiLayout *layout, bContext *C, Poin RNA_parameter_list_free(&list); } -static void rna_Node_draw_label(bNodeTree *ntree, bNode *node, char *label, int maxlen) +static void rna_Node_draw_label(const bNodeTree *ntree, const bNode *node, char *label, int maxlen) { extern FunctionRNA rna_Node_draw_label_func; @@ -1865,7 +1903,7 @@ static void rna_Node_draw_label(bNodeTree *ntree, bNode *node, char *label, int func = &rna_Node_draw_label_func; /* RNA_struct_find_function(&ptr, "draw_label"); */ - RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); + RNA_pointer_create((ID *)&ntree->id, &RNA_Node, (bNode *)node, &ptr); RNA_parameter_list_create(&list, &ptr, func); node->typeinfo->rna_ext.call(NULL, &ptr, func, &list); @@ -2069,10 +2107,76 @@ static const EnumPropertyItem *rna_GeometryNodeSwitch_type_itemf(bContext *UNUSE return itemf_function_check(node_socket_data_type_items, switch_type_supported); } +static bool compare_type_supported(const EnumPropertyItem *item) +{ + return ELEM(item->value, SOCK_FLOAT, SOCK_INT, SOCK_VECTOR, SOCK_STRING, SOCK_RGBA); +} + +static bool compare_main_operation_supported(const EnumPropertyItem *item) +{ + return !ELEM(item->value, NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER); +} + +static bool compare_rgba_operation_supported(const EnumPropertyItem *item) +{ + return ELEM(item->value, + NODE_COMPARE_EQUAL, + NODE_COMPARE_NOT_EQUAL, + NODE_COMPARE_COLOR_BRIGHTER, + NODE_COMPARE_COLOR_DARKER); +} + +static bool compare_string_operation_supported(const EnumPropertyItem *item) +{ + return ELEM(item->value, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL); +} + +static bool compare_other_operation_supported(const EnumPropertyItem *UNUSED(item)) +{ + return false; +} + +static const EnumPropertyItem *rna_FunctionNodeCompare_type_itemf(bContext *UNUSED(C), + PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), + bool *r_free) +{ + *r_free = true; + return itemf_function_check(node_socket_data_type_items, compare_type_supported); +} + +static const EnumPropertyItem *rna_FunctionNodeCompare_operation_itemf(bContext *UNUSED(C), + PointerRNA *ptr, + PropertyRNA *UNUSED(prop), + bool *r_free) +{ + *r_free = true; + bNode *node = ptr->data; + NodeFunctionCompare *data = (NodeFunctionCompare *)node->storage; + + if (ELEM(data->data_type, SOCK_FLOAT, SOCK_INT, SOCK_VECTOR)) { + return itemf_function_check(rna_enum_node_compare_operation_items, + compare_main_operation_supported); + } + else if (data->data_type == SOCK_STRING) { + return itemf_function_check(rna_enum_node_compare_operation_items, + compare_string_operation_supported); + } + else if (data->data_type == SOCK_RGBA) { + return itemf_function_check(rna_enum_node_compare_operation_items, + compare_rgba_operation_supported); + } + else { + return itemf_function_check(rna_enum_node_compare_operation_items, + compare_other_operation_supported); + } +} + static bool attribute_clamp_type_supported(const EnumPropertyItem *item) { return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_INT32, CD_PROP_COLOR); } + static const EnumPropertyItem *rna_GeometryNodeAttributeClamp_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), @@ -2149,6 +2253,30 @@ static void rna_GeometryNodeAttributeRandomize_data_type_update(Main *bmain, rna_Node_socket_update(bmain, scene, ptr); } +static void rna_GeometryNodeCompare_data_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNode *node = ptr->data; + NodeFunctionCompare *node_storage = (NodeFunctionCompare *)node->storage; + + if (node_storage->data_type == SOCK_RGBA && !ELEM(node_storage->operation, + NODE_COMPARE_EQUAL, + NODE_COMPARE_NOT_EQUAL, + NODE_COMPARE_COLOR_BRIGHTER, + NODE_COMPARE_COLOR_DARKER)) { + node_storage->operation = NODE_COMPARE_EQUAL; + } + else if (node_storage->data_type == SOCK_STRING && + !ELEM(node_storage->operation, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL)) { + node_storage->operation = NODE_COMPARE_EQUAL; + } + else if (node_storage->data_type != SOCK_RGBA && + ELEM(node_storage->operation, NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER)) { + node_storage->operation = NODE_COMPARE_EQUAL; + } + + rna_Node_socket_update(bmain, scene, ptr); +} + static bool attribute_convert_type_supported(const EnumPropertyItem *item) { return ELEM(item->value, @@ -3036,8 +3164,11 @@ static void rna_NodeSocketInterface_register_properties(bNodeTree *ntree, RNA_parameter_list_free(&list); } -static void rna_NodeSocketInterface_init_socket( - bNodeTree *ntree, bNodeSocket *stemp, bNode *node, bNodeSocket *sock, const char *data_path) +static void rna_NodeSocketInterface_init_socket(bNodeTree *ntree, + const bNodeSocket *interface_socket, + bNode *node, + bNodeSocket *sock, + const char *data_path) { extern FunctionRNA rna_NodeSocketInterface_init_socket_func; @@ -3045,11 +3176,11 @@ static void rna_NodeSocketInterface_init_socket( ParameterList list; FunctionRNA *func; - if (!stemp->typeinfo) { + if (!interface_socket->typeinfo) { return; } - RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, stemp, &ptr); + RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, (bNodeSocket *)interface_socket, &ptr); RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr); RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sock_ptr); // RNA_struct_find_function(&ptr, "init_socket"); @@ -3059,13 +3190,13 @@ static void rna_NodeSocketInterface_init_socket( RNA_parameter_set_lookup(&list, "node", &node_ptr); RNA_parameter_set_lookup(&list, "socket", &sock_ptr); RNA_parameter_set_lookup(&list, "data_path", &data_path); - stemp->typeinfo->ext_interface.call(NULL, &ptr, func, &list); + interface_socket->typeinfo->ext_interface.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } static void rna_NodeSocketInterface_from_socket(bNodeTree *ntree, - bNodeSocket *stemp, + bNodeSocket *interface_socket, bNode *node, bNodeSocket *sock) { @@ -3075,11 +3206,11 @@ static void rna_NodeSocketInterface_from_socket(bNodeTree *ntree, ParameterList list; FunctionRNA *func; - if (!stemp->typeinfo) { + if (!interface_socket->typeinfo) { return; } - RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, stemp, &ptr); + RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, interface_socket, &ptr); RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr); RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sock_ptr); // RNA_struct_find_function(&ptr, "from_socket"); @@ -3088,7 +3219,7 @@ static void rna_NodeSocketInterface_from_socket(bNodeTree *ntree, RNA_parameter_list_create(&list, &ptr, func); RNA_parameter_set_lookup(&list, "node", &node_ptr); RNA_parameter_set_lookup(&list, "socket", &sock_ptr); - stemp->typeinfo->ext_interface.call(NULL, &ptr, func, &list); + interface_socket->typeinfo->ext_interface.call(NULL, &ptr, func, &list); RNA_parameter_list_free(&list); } @@ -4823,18 +4954,32 @@ static void def_clamp(StructRNA *srna) static void def_map_range(StructRNA *srna) { + static const EnumPropertyItem rna_enum_data_type_items[] = { + {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"}, + {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"}, + {0, NULL, 0, NULL, NULL}, + }; + + RNA_def_struct_sdna_from(srna, "NodeMapRange", "storage"); + PropertyRNA *prop; prop = RNA_def_property(srna, "clamp", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); + RNA_def_property_boolean_sdna(prop, NULL, "clamp", 1); RNA_def_property_ui_text(prop, "Clamp", "Clamp the result to the target range [To Min, To Max]"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "interpolation_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "custom2"); + RNA_def_property_enum_sdna(prop, NULL, "interpolation_type"); RNA_def_property_enum_items(prop, rna_enum_node_map_range_items); RNA_def_property_ui_text(prop, "Interpolation Type", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); + + prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "data_type"); + RNA_def_property_enum_items(prop, rna_enum_data_type_items); + RNA_def_property_ui_text(prop, "Data Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); } static void def_math(StructRNA *srna) @@ -4864,15 +5009,57 @@ static void def_boolean_math(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } -static void def_float_compare(StructRNA *srna) +static void def_compare(StructRNA *srna) { + + static const EnumPropertyItem mode_items[] = { + {NODE_COMPARE_MODE_ELEMENT, + "ELEMENT", + 0, + "Element-Wise", + "Compare each element of the input vectors"}, + {NODE_COMPARE_MODE_LENGTH, "LENGTH", 0, "Length", "Compare the length of the input vectors"}, + {NODE_COMPARE_MODE_AVERAGE, + "AVERAGE", + 0, + "Average", + "Compare the average of the input vectors elements"}, + {NODE_COMPARE_MODE_DOT_PRODUCT, + "DOT_PRODUCT", + 0, + "Dot Product", + "Compare the dot products of the input vectors"}, + {NODE_COMPARE_MODE_DIRECTION, + "DIRECTION", + 0, + "Direction", + "Compare the direction of the input vectors"}, + {0, NULL, 0, NULL, NULL}, + }; + PropertyRNA *prop; + RNA_def_struct_sdna_from(srna, "NodeFunctionCompare", "storage"); + prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, rna_enum_node_float_compare_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_FunctionNodeCompare_operation_itemf"); + RNA_def_property_enum_items(prop, rna_enum_node_compare_operation_items); + RNA_def_property_enum_default(prop, NODE_COMPARE_EQUAL); RNA_def_property_ui_text(prop, "Operation", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); + + prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_FunctionNodeCompare_type_itemf"); + RNA_def_property_enum_items(prop, node_socket_data_type_items); + RNA_def_property_enum_default(prop, SOCK_FLOAT); + RNA_def_property_ui_text(prop, "Input Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_GeometryNodeCompare_data_type_update"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_default(prop, NODE_COMPARE_MODE_ELEMENT); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } static void def_float_to_int(StructRNA *srna) @@ -9166,6 +9353,16 @@ static void def_geo_boolean(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } +static void def_geo_attribute_domain_size(StructRNA *srna) +{ + PropertyRNA *prop = RNA_def_property(srna, "component", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, rna_enum_geometry_component_type_items); + RNA_def_property_enum_default(prop, GEO_COMPONENT_TYPE_MESH); + RNA_def_property_ui_text(prop, "Component", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); +} + static void def_geo_curve_primitive_bezier_segment(StructRNA *srna) { static const EnumPropertyItem mode_items[] = { @@ -9578,7 +9775,7 @@ static void def_geo_attribute_attribute_compare(StructRNA *srna) prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_node_float_compare_items); - RNA_def_property_enum_default(prop, NODE_FLOAT_COMPARE_GREATER_THAN); + RNA_def_property_enum_default(prop, NODE_COMPARE_GREATER_THAN); RNA_def_property_ui_text(prop, "Operation", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); @@ -11092,6 +11289,17 @@ static void def_geo_viewer(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_GeometryNode_socket_update"); } +static void def_geo_realize_instances(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "legacy_behavior", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", GEO_NODE_REALIZE_INSTANCES_LEGACY_BEHAVIOR); + RNA_def_property_ui_text( + prop, "Legacy Behavior", "Behave like before instance attributes existed"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_GeometryNode_socket_update"); +} + /* -------------------------------------------------------------------------- */ static void rna_def_shader_node(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 87173adc38f..76bfea00a79 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -869,7 +869,6 @@ static void rna_PoseChannel_custom_shape_transform_set(PointerRNA *ptr, #else -/* common properties for Action/Bone Groups - related to color */ void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const char *update_cb) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index e5009305fe5..285f6365ea1 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1941,6 +1941,8 @@ int rna_property_override_diff_default(Main *bmain, idx_a - 1); # endif op = NULL; + + equals = false; } else if (is_id || is_valid_for_diffing) { if (equals || do_create) { diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index c69a69290f9..5f1d9c5a5ce 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3425,7 +3425,8 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop, "Cycle-Aware Keying", "For channels with cyclic extrapolation, keyframe insertion is automatically " - "remapped inside the cycle time range, and keeps ends in sync"); + "remapped inside the cycle time range, and keeps ends in sync. Curves newly added to " + "actions with a Manual Frame Range and Cyclic Animation are automatically made cyclic"); /* Keyframing */ prop = RNA_def_property(srna, "keyframe_type", PROP_ENUM, PROP_NONE); @@ -5582,7 +5583,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {FFMPEG_MPEG2, "MPEG2", 0, "MPEG-2", ""}, {FFMPEG_MPEG4, "MPEG4", 0, "MPEG-4", ""}, {FFMPEG_AVI, "AVI", 0, "AVI", ""}, - {FFMPEG_MOV, "QUICKTIME", 0, "Quicktime", ""}, + {FFMPEG_MOV, "QUICKTIME", 0, "QuickTime", ""}, {FFMPEG_DV, "DV", 0, "DV", ""}, {FFMPEG_OGG, "OGG", 0, "Ogg", ""}, {FFMPEG_MKV, "MKV", 0, "Matroska", ""}, diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index f92043995dd..9be66a6553b 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -2272,7 +2272,8 @@ static void rna_def_filter_video(StructRNA *srna) prop = RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_REVERSE_FRAMES); RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse frame order"); - RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update"); + RNA_def_property_update( + prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update"); prop = RNA_def_property(srna, "color_multiply", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "mul"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e7bcd387eaf..16e9a6208fb 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -73,6 +73,30 @@ #include "RNA_enum_types.h" +const EnumPropertyItem rna_enum_geometry_component_type_items[] = { + {GEO_COMPONENT_TYPE_MESH, + "MESH", + ICON_MESH_DATA, + "Mesh", + "Mesh component containing point, corner, edge and face data"}, + {GEO_COMPONENT_TYPE_POINT_CLOUD, + "POINTCLOUD", + ICON_POINTCLOUD_DATA, + "Point Cloud", + "Point cloud component containing only point data"}, + {GEO_COMPONENT_TYPE_CURVE, + "CURVE", + ICON_CURVE_DATA, + "Curve", + "Curve component containing spline and control point data"}, + {GEO_COMPONENT_TYPE_INSTANCES, + "INSTANCES", + ICON_EMPTY_AXIS, + "Instances", + "Instances of objects or collections"}, + {0, NULL, 0, NULL, NULL}, +}; + const EnumPropertyItem rna_enum_space_type_items[] = { /* empty must be here for python, is skipped for UI */ {SPACE_EMPTY, "EMPTY", ICON_NONE, "Empty", ""}, @@ -7110,6 +7134,18 @@ static void rna_def_space_node_overlay(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Show Wire Colors", "Color node links based on their connected sockets"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); + + prop = RNA_def_property(srna, "show_timing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", SN_OVERLAY_SHOW_TIMINGS); + RNA_def_property_boolean_default(prop, false); + RNA_def_property_ui_text(prop, "Show Timing", "Display each node's last execution time"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); + + prop = RNA_def_property(srna, "show_context_path", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", SN_OVERLAY_SHOW_PATH); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Show Tree Path", "Display breadcrumbs for the editor's context"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); } static void rna_def_space_node(BlenderRNA *brna) @@ -7826,30 +7862,6 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) PropertyRNA *prop; StructRNA *srna; - static const EnumPropertyItem geometry_component_type_items[] = { - {GEO_COMPONENT_TYPE_MESH, - "MESH", - ICON_MESH_DATA, - "Mesh", - "Mesh component containing point, corner, edge and face data"}, - {GEO_COMPONENT_TYPE_POINT_CLOUD, - "POINTCLOUD", - ICON_POINTCLOUD_DATA, - "Point Cloud", - "Point cloud component containing only point data"}, - {GEO_COMPONENT_TYPE_CURVE, - "CURVE", - ICON_CURVE_DATA, - "Curve", - "Curve component containing spline and control point data"}, - {GEO_COMPONENT_TYPE_INSTANCES, - "INSTANCES", - ICON_EMPTY_AXIS, - "Instances", - "Instances of objects or collections"}, - {0, NULL, 0, NULL, NULL}, - }; - static const EnumPropertyItem object_eval_state_items[] = { {SPREADSHEET_OBJECT_EVAL_STATE_EVALUATED, "EVALUATED", @@ -7908,7 +7920,7 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); prop = RNA_def_property(srna, "geometry_component_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, geometry_component_type_items); + RNA_def_property_enum_items(prop, rna_enum_geometry_component_type_items); RNA_def_property_ui_text( prop, "Geometry Component", "Part of the geometry to display data from"); RNA_def_property_update(prop, diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index 83c1efd55bc..0920fe6679a 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -84,8 +84,8 @@ void RNA_api_texture(StructRNA *srna) NULL, -FLT_MAX, FLT_MAX, - "The result of the texture where (x,y,z,w) are (red, green, blue, intensity). For greyscale " - "textures, often intensity only will be used", + "The result of the texture where (x,y,z,w) are (red, green, blue, intensity). " + "For grayscale textures, often intensity only will be used", NULL, -1e4, 1e4); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 1cb1397a0ed..8c128292fd7 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -142,9 +142,10 @@ static const EnumPropertyItem event_ndof_type_items[] = { }; #endif /* RNA_RUNTIME */ -/* not returned: CAPSLOCKKEY, UNKNOWNKEY */ const EnumPropertyItem rna_enum_event_type_items[] = { - /* Note we abuse 'tooltip' message here to store a 'compact' form of some (too) long names. */ + /* - Note we abuse 'tooltip' message here to store a 'compact' form of some (too) long names. + * - Intentionally excluded: #CAPSLOCKKEY, #UNKNOWNKEY. + */ {0, "NONE", 0, "", ""}, {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", "LMB"}, {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", "MMB"}, |