diff options
Diffstat (limited to 'source/blender/makesrna')
50 files changed, 1835 insertions, 695 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index ddc010f27a1..a7eacb03a63 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -159,10 +159,10 @@ 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. + * Get the tags set for \a prop as int bit-field. * \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. + * the only way to set tags. Hence, at this point we assume the tag bit-field to be valid. */ int RNA_property_tags(PropertyRNA *prop); bool RNA_property_builtin(PropertyRNA *prop); diff --git a/source/blender/makesrna/RNA_enum_items.h b/source/blender/makesrna/RNA_enum_items.h index 61c5c1a6c72..1604bd97ed4 100644 --- a/source/blender/makesrna/RNA_enum_items.h +++ b/source/blender/makesrna/RNA_enum_items.h @@ -19,6 +19,7 @@ DEF_ENUM(rna_enum_object_empty_drawtype_items) DEF_ENUM(rna_enum_object_gpencil_type_items) DEF_ENUM(rna_enum_metaelem_type_items) +DEF_ENUM(rna_enum_color_space_convert_default_items) DEF_ENUM(rna_enum_proportional_falloff_items) DEF_ENUM(rna_enum_proportional_falloff_curve_only_items) DEF_ENUM(rna_enum_snap_source_items) @@ -210,6 +211,7 @@ DEF_ENUM(rna_enum_attribute_type_items) DEF_ENUM(rna_enum_color_attribute_type_items) DEF_ENUM(rna_enum_attribute_type_with_auto_items) DEF_ENUM(rna_enum_attribute_domain_items) +DEF_ENUM(rna_enum_attribute_domain_only_mesh_items) DEF_ENUM(rna_enum_attribute_curves_domain_items) DEF_ENUM(rna_enum_color_attribute_domain_items) DEF_ENUM(rna_enum_attribute_domain_without_corner_items) @@ -229,6 +231,7 @@ DEF_ENUM(rna_enum_transform_orientation_items) DEF_ENUM(rna_enum_velocity_unit_items) DEF_ENUM(rna_enum_curves_types) +DEF_ENUM(rna_enum_curve_normal_modes) /* Not available to RNA pre-processing (`makesrna`). * Defined in editors for example. */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 5346228050a..b9556a411cf 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -120,7 +120,7 @@ typedef enum PropertyScaleType { /** * \note Also update enums in bpy_props.c and rna_rna.c when adding items here. - * Watch it: these values are written to files as part of node socket button subtypes! + * Watch it: these values are written to files as part of node socket button sub-types! */ typedef enum PropertySubType { PROP_NONE = 0, @@ -179,7 +179,7 @@ typedef enum PropertySubType { /* Make sure enums are updated with these */ /* HIGHEST FLAG IN USE: 1 << 31 - * FREE FLAGS: 2, 9, 11, 13, 14, 15. */ + * FREE FLAGS: 9, 11, 13, 14, 15. */ typedef enum PropertyFlag { /** * Editable means the property is editable in the user @@ -299,6 +299,12 @@ typedef enum PropertyFlag { * properties which denotes whether modifier panel is collapsed or not. */ PROP_NO_DEG_UPDATE = (1 << 30), + + /** + * Filepaths that refer to output get a special treatment such + * as having the +/- operators available in the file browser. + **/ + PROP_PATH_OUTPUT = (1 << 2), } PropertyFlag; /** @@ -355,7 +361,7 @@ typedef enum ParameterFlag { /** * This allows for non-breaking API updates, * when adding non-critical new parameter to a callback function. - * This way, old py code defining funcs without that parameter would still work. + * This way, old Python code defining functions without that parameter would still work. * WARNING: any parameter after the first PYFUNC_OPTIONAL one will be considered as optional! * \note only for input parameters! */ @@ -719,7 +725,7 @@ typedef enum StructFlag { STRUCT_CONTAINS_DATABLOCK_IDPROPERTIES = (1 << 8), /** Added to type-map #BlenderRNA.structs_map */ STRUCT_PUBLIC_NAMESPACE = (1 << 9), - /** All subtypes are added too. */ + /** All sub-types are added too. */ STRUCT_PUBLIC_NAMESPACE_INHERIT = (1 << 10), /** * When the #PointerRNA.owner_id is NULL, this signifies the property should be accessed diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 7e6e3bcf90e..5c2bdc214d1 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -185,10 +185,33 @@ set(SRC ) set(INC - ../../../../intern/clog - - # Needed for defaults forward declarations. + . + .. + ../../blenfont + ../../blenkernel + ../../blenlib ../../blenloader + ../../blentranslation + ../../bmesh + ../../depsgraph + ../../draw + ../../gpu + ../../ikplugin + ../../imbuf + ../../makesdna + ../../modifiers + ../../nodes + ../../sequencer + ../../simulation + ../../windowmanager + ../../editors/include + ../../render + ../../../../intern/clog + ../../../../intern/cycles/blender + ../../../../intern/atomic + ../../../../intern/guardedalloc + ../../../../intern/memutil + ../../../../intern/mantaflow/extern ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern @@ -369,38 +392,12 @@ if(WITH_GMP) endif() # Build makesrna executable -blender_include_dirs( - . - .. - ../../blenfont - ../../blenkernel - ../../blenlib - ../../blentranslation - ../../bmesh - ../../depsgraph - ../../draw - ../../gpu - ../../ikplugin - ../../imbuf - ../../makesdna - ../../modifiers - ../../nodes/ - ../../sequencer - ../../simulation - ../../windowmanager - ../../editors/include - ../../render - ../../../../intern/cycles/blender - ../../../../intern/atomic - ../../../../intern/guardedalloc - ../../../../intern/memutil - ../../../../intern/mantaflow/extern -) - add_cc_flags_custom_test(makesrna) add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC}) setup_platform_linker_flags(makesrna) +blender_target_include_dirs(makesrna ${INC}) +blender_target_include_dirs_sys(makesrna ${INC_SYS}) target_link_libraries(makesrna bf_dna) target_link_libraries(makesrna bf_dna_blenlib) @@ -409,8 +406,9 @@ if(WIN32 AND NOT UNIX) target_link_libraries(makesrna ${PTHREADS_LIBRARIES}) endif() -# Output rna_*_gen.c -# note (linux only): with crashes try add this after COMMAND: valgrind --leak-check=full --track-origins=yes +# Output `rna_*_gen.c`. +# NOTE: (Linux only): with crashes try add this after COMMAND: +# `valgrind --leak-check=full --track-origins=yes` add_custom_command( OUTPUT ${GENSRC} COMMAND "$<TARGET_FILE:makesrna>" ${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/../ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index a7b8488c371..3592ecd84c8 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -564,7 +564,7 @@ static int rna_enum_bitmask(PropertyRNA *prop) static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp) { - return ((prop->type == PROP_FLOAT) && (ELEM(prop->subtype, PROP_COLOR, PROP_COLOR_GAMMA)) && + return ((prop->type == PROP_FLOAT) && ELEM(prop->subtype, PROP_COLOR, PROP_COLOR_GAMMA) && (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0)); } @@ -3904,7 +3904,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } case PROP_BOOLEAN: { BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop; - unsigned int i; + uint i; if (prop->arraydimension && prop->totarraylength) { fprintf(f, @@ -3932,7 +3932,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } case PROP_INT: { IntPropertyRNA *iprop = (IntPropertyRNA *)prop; - unsigned int i; + uint i; if (prop->arraydimension && prop->totarraylength) { fprintf(f, @@ -3960,7 +3960,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } case PROP_FLOAT: { FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop; - unsigned int i; + uint i; if (prop->arraydimension && prop->totarraylength) { fprintf(f, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index d31a312816a..b2c57846a08 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -1140,7 +1140,7 @@ static void rna_ImagePreview_size_set(PointerRNA *ptr, const int *values, enum e BKE_previewimg_clear_single(prv_img, size); if (values[0] && values[1]) { - prv_img->rect[size] = MEM_callocN(values[0] * values[1] * sizeof(unsigned int), "prv_rect"); + prv_img->rect[size] = MEM_callocN(values[0] * values[1] * sizeof(uint), "prv_rect"); prv_img->w[size] = values[0]; prv_img->h[size] = values[1]; @@ -1178,7 +1178,7 @@ static void rna_ImagePreview_pixels_get(PointerRNA *ptr, int *values, enum eIcon BKE_previewimg_ensure(prv_img, size); - memcpy(values, prv_img->rect[size], prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int)); + memcpy(values, prv_img->rect[size], prv_img->w[size] * prv_img->h[size] * sizeof(uint)); } static void rna_ImagePreview_pixels_set(PointerRNA *ptr, const int *values, enum eIconSizes size) @@ -1190,7 +1190,7 @@ static void rna_ImagePreview_pixels_set(PointerRNA *ptr, const int *values, enum BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); } - memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int)); + memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(uint)); prv_img->flag[size] |= PRV_USER_EDITED; } @@ -1201,7 +1201,7 @@ static int rna_ImagePreview_pixels_float_get_length(const PointerRNA *ptr, ID *id = ptr->owner_id; PreviewImage *prv_img = (PreviewImage *)ptr->data; - BLI_assert(sizeof(unsigned int) == 4); + BLI_assert(sizeof(uint) == 4); if (id != NULL) { BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); @@ -1219,11 +1219,11 @@ static void rna_ImagePreview_pixels_float_get(PointerRNA *ptr, float *values, en ID *id = ptr->owner_id; PreviewImage *prv_img = (PreviewImage *)ptr->data; - unsigned char *data = (unsigned char *)prv_img->rect[size]; + uchar *data = (uchar *)prv_img->rect[size]; const size_t len = prv_img->w[size] * prv_img->h[size] * 4; size_t i; - BLI_assert(sizeof(unsigned int) == 4); + BLI_assert(sizeof(uint) == 4); if (id != NULL) { BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); @@ -1243,11 +1243,11 @@ static void rna_ImagePreview_pixels_float_set(PointerRNA *ptr, ID *id = ptr->owner_id; PreviewImage *prv_img = (PreviewImage *)ptr->data; - unsigned char *data = (unsigned char *)prv_img->rect[size]; + uchar *data = (uchar *)prv_img->rect[size]; const size_t len = prv_img->w[size] * prv_img->h[size] * 4; size_t i; - BLI_assert(sizeof(unsigned int) == 4); + BLI_assert(sizeof(uint) == 4); if (id != NULL) { BLI_assert(prv_img == BKE_previewimg_id_ensure(id)); @@ -1392,6 +1392,19 @@ static void rna_Library_version_get(PointerRNA *ptr, int *value) value[2] = lib->subversionfile; } +static void rna_Library_reload(Library *lib, bContext *C, ReportList *reports) +{ +# ifdef WITH_PYTHON + BPy_BEGIN_ALLOW_THREADS; +# endif + + WM_lib_reload(lib, C, reports); + +# ifdef WITH_PYTHON + BPy_END_ALLOW_THREADS; +# endif +} + #else static void rna_def_ID_properties(BlenderRNA *brna) @@ -2239,7 +2252,7 @@ static void rna_def_library(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_THICK_WRAP); - func = RNA_def_function(srna, "reload", "WM_lib_reload"); + func = RNA_def_function(srna, "reload", "rna_Library_reload"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Reload this library and all its linked data-blocks"); } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 835265b1986..2609c76f3b1 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -777,10 +777,10 @@ bool RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test) return found; } -unsigned int RNA_struct_count_properties(StructRNA *srna) +uint RNA_struct_count_properties(StructRNA *srna) { PointerRNA struct_ptr; - unsigned int counter = 0; + uint counter = 0; RNA_pointer_create(NULL, srna, NULL, &struct_ptr); @@ -1135,7 +1135,7 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index) int RNA_property_array_item_index(PropertyRNA *prop, char name) { - /* Don't use custom property subtypes in RNA path lookup. */ + /* Don't use custom property sub-types in RNA path lookup. */ PropertySubType subtype = rna_ensure_property(prop)->subtype; /* get index based on string name/alias */ @@ -1744,9 +1744,9 @@ int RNA_enum_from_value(const EnumPropertyItem *item, const int value) return -1; } -unsigned int RNA_enum_items_count(const EnumPropertyItem *item) +uint RNA_enum_items_count(const EnumPropertyItem *item) { - unsigned int i = 0; + uint i = 0; while (item->identifier) { item++; @@ -3620,7 +3620,7 @@ void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop) BLI_assert(RNA_property_type(prop) == PROP_POINTER); - if ((/*idprop=*/rna_idproperty_check(&prop, ptr))) { + if (/*idprop=*/rna_idproperty_check(&prop, ptr)) { /* already exists */ } else if (prop->flag & PROP_IDPROPERTY) { @@ -5951,7 +5951,7 @@ void RNA_parameter_list_begin(ParameterList *parms, ParameterIterator *iter) if (iter->valid) { iter->size = rna_parameter_size(iter->parm); - iter->data = (((char *)iter->parms->data)); /* +iter->offset, always 0 */ + iter->data = ((char *)iter->parms->data); /* +iter->offset, always 0 */ } } diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 808578b4746..0b8412367bf 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -27,6 +27,7 @@ #ifdef DEBUG_OVERRIDE_TIMEIT # include "PIL_time_utildefines.h" +# include <stdio.h> #endif #include "BKE_armature.h" diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 4f07cb235fa..fa2ef98d3df 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -1207,6 +1207,7 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) prop, "rna_NlaTrack_active_get", "rna_NlaTrack_active_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Track", "Active NLA Track"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ACTION); /* XXX: should (but doesn't) update the active track in the NLA window */ RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index f83ec0dc09b..a2386205013 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -38,6 +38,13 @@ # include "DEG_depsgraph.h" # include "DEG_depsgraph_build.h" +static void rna_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + ID *id = ptr->owner_id; + + DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE); +} + static void rna_Armature_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->owner_id; @@ -1122,7 +1129,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_define_lib_overridable(false); } -/* err... bones should not be directly edited (only editbones should be...) */ +/* Err... bones should not be directly edited (only edit-bones should be...). */ static void rna_def_bone(BlenderRNA *brna) { StructRNA *srna; @@ -1365,6 +1372,7 @@ static void rna_def_armature_bones(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Bone", "Armature's active bone"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_bone_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_Armature_update"); /* TODO: redraw. */ /* RNA_def_property_collection_active(prop, prop_act); */ @@ -1389,7 +1397,7 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_sdna(prop, NULL, "act_edbone"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone"); - // RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update"); + RNA_def_property_update(prop, 0, "rna_Armature_update"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL, NULL); /* TODO: redraw. */ diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index a9f52e5c7d9..062f49b847b 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -476,6 +476,12 @@ static void rna_def_asset_handle(BlenderRNA *brna) rna_def_asset_handle_api(srna); } +static void rna_def_asset_catalog_path(BlenderRNA *brna) +{ + StructRNA *srna = RNA_def_struct(brna, "AssetCatalogPath", NULL); + RNA_def_struct_ui_text(srna, "Catalog Path", ""); +} + static void rna_def_asset_library_reference(BlenderRNA *brna) { StructRNA *srna = RNA_def_struct(brna, "AssetLibraryReference", NULL); @@ -502,6 +508,7 @@ void RNA_def_asset(BlenderRNA *brna) rna_def_asset_data(brna); rna_def_asset_library_reference(brna); rna_def_asset_handle(brna); + rna_def_asset_catalog_path(brna); RNA_define_animate_sdna(true); } diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index 5e17f22ecf5..e1b6fb429a7 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -21,6 +21,8 @@ #include "BKE_attribute.h" #include "BKE_customdata.h" +#include "BLT_translation.h" + #include "WM_types.h" const EnumPropertyItem rna_enum_attribute_type_items[] = { @@ -81,6 +83,14 @@ const EnumPropertyItem rna_enum_attribute_domain_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_attribute_domain_only_mesh_items[] = { + {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, + {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, + {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"}, + {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", "Attribute on mesh face corner"}, + {0, NULL, 0, NULL, NULL}, +}; + const EnumPropertyItem rna_enum_attribute_domain_without_corner_items[] = { {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, @@ -194,7 +204,7 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, int totitem = 0, a; static EnumPropertyItem mesh_vertex_domain_item = { - ATTR_DOMAIN_POINT, "POINT", 0, "Vertex", "Attribute per point/vertex"}; + ATTR_DOMAIN_POINT, "POINT", 0, N_("Vertex"), N_("Attribute per point/vertex")}; for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) { domain_item = &rna_enum_attribute_domain_items[a]; @@ -321,6 +331,36 @@ static void rna_ByteColorAttributeValue_color_set(PointerRNA *ptr, const float * linearrgb_to_srgb_uchar4(&mlcol->r, values); } +static void rna_ByteColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values) +{ + MLoopCol *col = (MLoopCol *)ptr->data; + values[0] = col->r / 255.0f; + values[1] = col->g / 255.0f; + values[2] = col->b / 255.0f; + values[3] = col->a / 255.0f; +} + +static void rna_ByteColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values) +{ + MLoopCol *col = (MLoopCol *)ptr->data; + col->r = round_fl_to_uchar_clamp(values[0] * 255.0f); + col->g = round_fl_to_uchar_clamp(values[1] * 255.0f); + col->b = round_fl_to_uchar_clamp(values[2] * 255.0f); + col->a = round_fl_to_uchar_clamp(values[3] * 255.0f); +} + +static void rna_FloatColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values) +{ + MPropCol *col = (MPropCol *)ptr->data; + linearrgb_to_srgb_v4(values, col->color); +} + +static void rna_FloatColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values) +{ + MPropCol *col = (MPropCol *)ptr->data; + srgb_to_linearrgb_v4(col->color, values); +} + /* Int8 Attribute. */ static int rna_ByteIntAttributeValue_get(PointerRNA *ptr) @@ -715,6 +755,16 @@ static void rna_def_attribute_float_color(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "color"); RNA_def_property_array(prop, 4); RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); + + prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR); + RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space"); + RNA_def_property_float_sdna(prop, NULL, "color"); + RNA_def_property_array(prop, 4); + RNA_def_property_float_funcs(prop, + "rna_FloatColorAttributeValue_color_srgb_get", + "rna_FloatColorAttributeValue_color_srgb_set", + NULL); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); } static void rna_def_attribute_byte_color(BlenderRNA *brna) @@ -756,6 +806,16 @@ static void rna_def_attribute_byte_color(BlenderRNA *brna) NULL); RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space"); RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); + + prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 4); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_funcs(prop, + "rna_ByteColorAttributeValue_color_srgb_get", + "rna_ByteColorAttributeValue_color_srgb_set", + NULL); + RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space"); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); } static void rna_def_attribute_int(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 789a8b381b6..ce51b52de39 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -92,6 +92,19 @@ static const EnumPropertyItem rna_enum_brush_texture_slot_map_texture_mode_items #endif /* clang-format off */ +/* Note: we don't actually turn these into a single enum bit-mask property, + * instead we construct individual boolean properties. */ +const EnumPropertyItem RNA_automasking_flags[] = { + {BRUSH_AUTOMASKING_TOPOLOGY, "use_automasking_topology", 0,"Topology", "Affect only vertices connected to the active vertex under the brush"}, + {BRUSH_AUTOMASKING_FACE_SETS, "use_automasking_face_sets", 0,"Face Sets", "Affect only vertices that share Face Sets with the active vertex"}, + {BRUSH_AUTOMASKING_BOUNDARY_EDGES, "use_automasking_boundary_edges", 0,"Mesh Boundary Auto-Masking", "Do not affect non manifold boundary edges"}, + {BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS, "use_automasking_boundary_face_sets", 0,"Face Sets Boundary Automasking", "Do not affect vertices that belong to a Face Set boundary"}, + {BRUSH_AUTOMASKING_CAVITY_NORMAL, "use_automasking_cavity", 0,"Cavity Mask", "Do not affect vertices on peaks, based on the surface curvature"}, + {BRUSH_AUTOMASKING_CAVITY_INVERTED, "use_automasking_cavity_inverted", 0,"Inverted Cavity Mask", "Do not affect vertices within crevices, based on the surface curvature"}, + {BRUSH_AUTOMASKING_CAVITY_USE_CURVE, "use_automasking_custom_cavity_curve", 0,"Custom Cavity Curve", "Use custom curve"}, + {0, NULL, 0, NULL, NULL} +}; + const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = { {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""}, {SCULPT_TOOL_DRAW_SHARP, "DRAW_SHARP", ICON_BRUSH_SCULPT_DRAW, "Draw Sharp", ""}, @@ -286,6 +299,11 @@ static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = { {GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Edit Lines", "Use edit lines as fill boundary limits"}, {0, NULL, 0, NULL, NULL}}; +static EnumPropertyItem rna_enum_gpencil_fill_extend_modes_items[] = { + {GP_FILL_EMODE_EXTEND, "EXTEND", 0, "Extend", "Extend strokes in straight lines"}, + {GP_FILL_EMODE_RADIUS, "RADIUS", 0, "Radius", "Connect endpoints that are close together"}, + {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem rna_enum_gpencil_fill_layers_modes_items[] = { {GP_FILL_GPLMODE_VISIBLE, "VISIBLE", 0, "Visible", "Visible layers"}, {GP_FILL_GPLMODE_ACTIVE, "ACTIVE", 0, "Active", "Only active layer"}, @@ -972,7 +990,9 @@ static void rna_BrushGpencilSettings_default_eraser_update(Main *bmain, static void rna_BrushGpencilSettings_use_material_pin_update(bContext *C, PointerRNA *ptr) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); Brush *brush = (Brush *)ptr->owner_id; @@ -1077,6 +1097,32 @@ static const EnumPropertyItem *rna_BrushTextureSlot_map_mode_itemf(bContext *C, # undef rna_enum_brush_texture_slot_map_sculpt_mode_items } +static void rna_Brush_automasking_invert_cavity_set(PointerRNA *ptr, bool val) +{ + Brush *brush = (Brush *)ptr->data; + + if (val) { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + brush->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_INVERTED; + } + else { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + } +} + +static void rna_Brush_automasking_cavity_set(PointerRNA *ptr, bool val) +{ + Brush *brush = (Brush *)ptr->data; + + if (val) { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + brush->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_NORMAL; + } + else { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + } +} + #else static void rna_def_brush_texture_slot(BlenderRNA *brna) @@ -1484,14 +1530,6 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* fill leak size */ - prop = RNA_def_property(srna, "fill_leak", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "fill_leak"); - RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_text(prop, "Leak Size", "Size in pixels to consider the leak closed"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); - /* fill factor size */ prop = RNA_def_property(srna, "fill_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fill_factor"); @@ -1643,7 +1681,14 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_float_default(prop, 0.0f); RNA_def_property_ui_text( - prop, "Stroke Extension", "Strokes end extension for closing gaps, use zero to disable"); + prop, "Closure Size", "Strokes end extension for closing gaps, use zero to disable"); + RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); + + prop = RNA_def_property(srna, "fill_extend_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "fill_extend_mode"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_extend_modes_items); + RNA_def_property_ui_text( + prop, "Closure Mode", "Types of stroke extensions used for closing gaps"); RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0); /* Number of pixels to dilate fill area. Negative values contract the filled area. */ @@ -1874,26 +1919,6 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_stroke", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, NULL, "sculpt_mode_flag", GP_SCULPT_FLAGMODE_AUTOMASK_STROKE); - RNA_def_property_ui_text(prop, "Auto-Masking Strokes", "Mask strokes below brush cursor"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - - prop = RNA_def_property(srna, "use_automasking_layer", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "sculpt_mode_flag", GP_SCULPT_FLAGMODE_AUTOMASK_LAYER); - RNA_def_property_ui_text(prop, "Auto-Masking Layer", "Mask strokes using active layer"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - - prop = RNA_def_property(srna, "use_automasking_material", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, NULL, "sculpt_mode_flag", GP_SCULPT_FLAGMODE_AUTOMASK_MATERIAL); - RNA_def_property_ui_text(prop, "Auto-Masking Material", "Mask strokes using active material"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - /* Material */ prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Material"); @@ -1921,7 +1946,14 @@ static void rna_def_gpencil_options(BlenderRNA *brna) prop = RNA_def_property(srna, "show_fill_extend", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_EXTENDLINES); RNA_def_property_boolean_default(prop, true); - RNA_def_property_ui_text(prop, "Show Extend Lines", "Show help lines for stroke extension"); + RNA_def_property_ui_text(prop, "Visual Aids", "Show help lines for stroke extension"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + + prop = RNA_def_property(srna, "use_collide_strokes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_STROKE_COLLIDE); + RNA_def_property_boolean_default(prop, false); + RNA_def_property_ui_text( + prop, "Strokes Collision", "Check if extend lines collide with strokes"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE); @@ -3172,32 +3204,67 @@ static void rna_def_brush(BlenderRNA *brna) "When locked keep using the plane origin of surface where stroke was initiated"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_topology", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_TOPOLOGY); - RNA_def_property_ui_text(prop, - "Topology Auto-Masking", - "Affect only vertices connected to the active vertex under the brush"); + const EnumPropertyItem *entry = RNA_automasking_flags; + do { + prop = RNA_def_property(srna, entry->identifier, PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", entry->value); + RNA_def_property_ui_text(prop, entry->name, entry->description); + + if (entry->value == BRUSH_AUTOMASKING_CAVITY_NORMAL) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Brush_automasking_cavity_set"); + } + else if (entry->value == BRUSH_AUTOMASKING_CAVITY_INVERTED) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Brush_automasking_invert_cavity_set"); + } + + RNA_def_property_update(prop, 0, "rna_Brush_update"); + } while ((++entry)->identifier); + + prop = RNA_def_property(srna, "automasking_cavity_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "automasking_cavity_factor"); + RNA_def_property_ui_text(prop, "Cavity Factor", "The contrast of the cavity mask"); + RNA_def_property_range(prop, 0.0f, 5.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Auto-Masking", - "Affect only vertices that share Face Sets with the active vertex"); + prop = RNA_def_property(srna, "automasking_cavity_blur_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "automasking_cavity_blur_steps"); + RNA_def_property_int_default(prop, 0); + RNA_def_property_ui_text(prop, "Blur Steps", "The number of times the cavity mask is blurred"); + RNA_def_property_range(prop, 0, 25); + RNA_def_property_ui_range(prop, 0, 10, 1, 1); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop = RNA_def_property(srna, "automasking_cavity_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "automasking_cavity_curve"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Cavity Curve", "Curve used for the sensitivity"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_boundary_edges", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_EDGES); + prop = RNA_def_property(srna, "use_automasking_start_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BRUSH_NORMAL); RNA_def_property_ui_text( - prop, "Mesh Boundary Auto-Masking", "Do not affect non manifold boundary edges"); + prop, + "Area Normal", + "Affect only vertices with a similar normal to where the stroke starts"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_boundary_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Boundary Automasking", - "Do not affect vertices that belong to a Face Set boundary"); + prop = RNA_def_property(srna, "use_automasking_view_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_VIEW_NORMAL); + RNA_def_property_ui_text( + prop, "View Normal", "Affect only vertices with a normal that faces the viewer"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop = RNA_def_property(srna, "use_automasking_view_occlusion", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_VIEW_OCCLUSION); + RNA_def_property_ui_text( + prop, + "Occlusion", + "Only affect vertices that are not occluded by other faces. (Slower performance)"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop = RNA_def_property(srna, "use_scene_spacing", PROP_ENUM, PROP_NONE); @@ -3529,6 +3596,10 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Use Vertex", "Use this brush in grease pencil vertex color mode"); + prop = RNA_def_property(srna, "use_paint_sculpt_curves", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_SCULPT_CURVES); + RNA_def_property_ui_text(prop, "Use Sculpt", "Use this brush in sculpt curves mode"); + /* texture */ prop = RNA_def_property(srna, "texture_slot", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "BrushTextureSlot"); @@ -3572,13 +3643,13 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mask Texture Overlay Alpha", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "add_col"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Add Color", "Color of cursor when adding"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "cursor_color_subtract", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "cursor_color_subtract", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "sub_col"); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Subtract Color", "Color of cursor when subtracting"); diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c index 84ddea368e7..833495dce7a 100644 --- a/source/blender/makesrna/intern/rna_collection.c +++ b/source/blender/makesrna/intern/rna_collection.c @@ -599,6 +599,11 @@ void RNA_def_collections(BlenderRNA *brna) 0, "No Intersection", "Include this collection but do not generate intersection lines"}, + {COLLECTION_LRT_FORCE_INTERSECTION, + "FORCE_INTERSECTION", + 0, + "Force Intersection", + "Generate intersection lines even with objects that disabled intersection"}, {0, NULL, 0, NULL, NULL}}; prop = RNA_def_property(srna, "lineart_usage", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index b68d87587e7..2ba82da09bb 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -15,11 +15,22 @@ #include "BKE_node_tree_update.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" #include "WM_api.h" #include "WM_types.h" +const EnumPropertyItem rna_enum_color_space_convert_default_items[] = { + {0, + "NONE", + 0, + "None", + "Do not perform any color transform on load, treat colors as in scene linear space " + "already"}, + {0, NULL, 0, NULL, NULL}, +}; + #ifdef RNA_RUNTIME # include "RNA_access.h" @@ -1190,16 +1201,6 @@ static void rna_def_colormanage(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; - static const EnumPropertyItem color_space_items[] = { - {0, - "NONE", - 0, - "None", - "Do not perform any color transform on load, treat colors as in scene linear space " - "already"}, - {0, NULL, 0, NULL, NULL}, - }; - /* ** Display Settings ** */ srna = RNA_def_struct(brna, "ColorManagedDisplaySettings", NULL); RNA_def_struct_path_func(srna, "rna_ColorManagedDisplaySettings_path"); @@ -1279,7 +1280,7 @@ static void rna_def_colormanage(BlenderRNA *brna) prop = RNA_def_property(srna, "name", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_items(prop, rna_enum_color_space_convert_default_items); RNA_def_property_enum_funcs(prop, "rna_ColorManagedColorspaceSettings_colorspace_get", "rna_ColorManagedColorspaceSettings_colorspace_set", @@ -1309,7 +1310,7 @@ static void rna_def_colormanage(BlenderRNA *brna) prop = RNA_def_property(srna, "name", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_items(prop, rna_enum_color_space_convert_default_items); RNA_def_property_enum_funcs(prop, "rna_ColorManagedColorspaceSettings_colorspace_get", "rna_ColorManagedColorspaceSettings_colorspace_set", diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 3a90d631c63..126300f0425 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1947,22 +1947,23 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop = RNA_def_property(srna, "order_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orderu"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_range(prop, 2, 6); - RNA_def_property_ui_text( - prop, - "Order U", - "NURBS order in the U direction (for splines and surfaces, higher values " - "let points influence a greater area)"); + RNA_def_property_range(prop, 2, 64); + RNA_def_property_ui_range(prop, 2, 6, 1, -1); + RNA_def_property_ui_text(prop, + "Order U", + "NURBS order in the U direction. Higher values make each point " + "influence a greater area, but have worse performance"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u"); prop = RNA_def_property(srna, "order_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orderv"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_range(prop, 2, 6); + RNA_def_property_range(prop, 2, 64); + RNA_def_property_ui_range(prop, 2, 6, 1, -1); RNA_def_property_ui_text(prop, "Order V", - "NURBS order in the V direction (for surfaces only, higher values " - "let points influence a greater area)"); + "NURBS order in the V direction. Higher values make each point " + "influence a greater area, but have worse performance"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v"); prop = RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_curves.c b/source/blender/makesrna/intern/rna_curves.c index 17290d1c582..a01a2bcb8cd 100644 --- a/source/blender/makesrna/intern/rna_curves.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -26,6 +26,12 @@ const EnumPropertyItem rna_enum_curves_types[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_curve_normal_modes[] = { + {NORMAL_MODE_MINIMUM_TWIST, "MINIMUM_TWIST", ICON_NONE, "Minimum Twist", ""}, + {NORMAL_MODE_Z_UP, "Z_UP", ICON_NONE, "Z Up", ""}, + {0, NULL, 0, NULL, NULL}, +}; + #ifdef RNA_RUNTIME # include "BLI_math_vector.h" @@ -60,12 +66,23 @@ static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter, NULL); } +static float (*get_curves_positions(Curves *curves))[3] +{ + return (float(*)[3])CustomData_get_layer_named( + &curves->geometry.point_data, CD_PROP_FLOAT3, "position"); +} + +static const float (*get_curves_positions_const(const Curves *curves))[3] +{ + return (const float(*)[3])CustomData_get_layer_named( + &curves->geometry.point_data, CD_PROP_FLOAT3, "position"); +} + static int rna_CurvePoint_index_get_const(const PointerRNA *ptr) { const Curves *curves = rna_curves(ptr); const float(*co)[3] = ptr->data; - const float(*positions)[3] = (const float(*)[3])CustomData_get_layer_named( - &curves->geometry.point_data, CD_PROP_FLOAT3, "position"); + const float(*positions)[3] = get_curves_positions_const(curves); return (int)(co - positions); } @@ -75,13 +92,27 @@ static int rna_Curves_position_data_length(PointerRNA *ptr) return curves->geometry.point_num; } +int rna_Curves_position_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + Curves *curves = rna_curves(ptr); + if (index < 0 || index >= curves->geometry.point_num) { + return false; + } + r_ptr->owner_id = &curves->id; + r_ptr->type = &RNA_FloatVectorAttributeValue; + r_ptr->data = &get_curves_positions(curves)[index]; + return true; +} + static void rna_Curves_position_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - const Curves *curves = rna_curves(ptr); - const float(*positions)[3] = (const float(*)[3])CustomData_get_layer_named( - &curves->geometry.point_data, CD_PROP_FLOAT3, "position"); - rna_iterator_array_begin( - iter, (void *)positions, sizeof(float[3]), curves->geometry.point_num, false, NULL); + Curves *curves = rna_curves(ptr); + rna_iterator_array_begin(iter, + get_curves_positions(curves), + sizeof(float[3]), + curves->geometry.point_num, + false, + NULL); } static int rna_CurvePoint_index_get(PointerRNA *ptr) @@ -126,6 +157,18 @@ static char *rna_CurvePoint_path(const PointerRNA *ptr) return BLI_sprintfN("points[%d]", rna_CurvePoint_index_get_const(ptr)); } +int rna_Curves_points_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + Curves *curves = rna_curves(ptr); + if (index < 0 || index >= curves->geometry.point_num) { + return false; + } + r_ptr->owner_id = &curves->id; + r_ptr->type = &RNA_CurvePoint; + r_ptr->data = &get_curves_positions(curves)[index]; + return true; +} + static int rna_CurveSlice_index_get_const(const PointerRNA *ptr) { Curves *curves = rna_curves(ptr); @@ -280,7 +323,7 @@ static void rna_def_curves(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Curves_position_data_length", - NULL, + "rna_Curves_points_lookup_int", NULL, NULL); RNA_def_property_ui_text(prop, "Points", "Control points of all curves"); @@ -295,7 +338,7 @@ static void rna_def_curves(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Curves_position_data_length", - NULL, + "rna_Curves_position_data_lookup_int", NULL, NULL); RNA_def_property_struct_type(prop, "FloatVectorAttributeValue"); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 44b642d0fcc..b7856794da2 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -147,7 +147,7 @@ PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier) for (link = listbase->first; link; link = link->next) { PropertyRNA *prop = ((PropertyDefRNA *)link)->prop; - if (prop && (STREQ(prop->identifier, identifier))) { + if (prop && STREQ(prop->identifier, identifier)) { return (PropertyDefRNA *)link; } } @@ -916,8 +916,8 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN DefRNA.laststruct = srna; if (srnafrom) { - /* copy from struct to derive stuff, a bit clumsy since we can't - * use MEM_dupallocN, data structs may not be alloced but builtin */ + /* Copy from struct to derive stuff, a bit clumsy since we can't + * use #MEM_dupallocN, data structs may not be allocated but builtin. */ memcpy(srna, srnafrom, sizeof(StructRNA)); srna->cont.prophash = NULL; BLI_listbase_clear(&srna->cont.properties); @@ -2753,7 +2753,7 @@ void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, co return; } - if ((/* dp= */ rna_def_property_sdna(prop, structname, propname))) { + if (/* dp= */ rna_def_property_sdna(prop, structname, propname)) { if (prop->arraydimension) { prop->arraydimension = 0; prop->totarraylength = 0; diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index ff107d0b833..9af76de2a2b 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -61,6 +61,14 @@ void **rna_DepsgraphIterator_instance(PointerRNA *ptr) } # endif +/* Temporary hack for Cycles until it is changed to work with the C API directly. */ +DupliObject *rna_hack_DepsgraphObjectInstance_dupli_object_get(PointerRNA *ptr) +{ + RNA_DepsgraphIterator *di = ptr->data; + DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data; + return deg_iter->dupli_object_current; +} + static PointerRNA rna_DepsgraphObjectInstance_object_get(PointerRNA *ptr) { RNA_DepsgraphIterator *di = ptr->data; @@ -160,7 +168,7 @@ static void rna_DepsgraphObjectInstance_matrix_world_get(PointerRNA *ptr, float /* We can return actual object's matrix here, no reason to return identity matrix * when this is not actually an instance... */ Object *ob = (Object *)di->iter.current; - copy_m4_m4((float(*)[4])mat, ob->obmat); + copy_m4_m4((float(*)[4])mat, ob->object_to_world); } } @@ -300,10 +308,14 @@ static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, Pointe { iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__); DEGObjectIterData *data = MEM_callocN(sizeof(DEGObjectIterData), __func__); + DEGObjectIterSettings *deg_iter_settings = MEM_callocN(sizeof(DEGObjectIterSettings), __func__); + deg_iter_settings->depsgraph = (Depsgraph *)ptr->data; + deg_iter_settings->flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET; - data->graph = (Depsgraph *)ptr->data; - data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE | - DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET; + data->settings = deg_iter_settings; + data->graph = deg_iter_settings->depsgraph; + data->flag = deg_iter_settings->flags; ((BLI_Iterator *)iter->internal.custom)->valid = true; DEG_iterator_objects_begin(iter->internal.custom, data); @@ -318,7 +330,9 @@ static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter) static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter) { + DEGObjectIterData *data = (DEGObjectIterData *)((BLI_Iterator *)iter->internal.custom)->data; DEG_iterator_objects_end(iter->internal.custom); + MEM_freeN(data->settings); MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data); MEM_freeN(iter->internal.custom); } @@ -349,11 +363,16 @@ static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *ite { RNA_Depsgraph_Instances_Iterator *di_it = iter->internal.custom = MEM_callocN(sizeof(*di_it), __func__); + DEGObjectIterSettings *deg_iter_settings = MEM_callocN(sizeof(DEGObjectIterSettings), __func__); + deg_iter_settings->depsgraph = (Depsgraph *)ptr->data; + deg_iter_settings->flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | + DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_DUPLI; DEGObjectIterData *data = &di_it->deg_data[0]; - data->graph = (Depsgraph *)ptr->data; - data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | - DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI; + data->settings = deg_iter_settings; + data->graph = deg_iter_settings->depsgraph; + data->flag = deg_iter_settings->flags; di_it->iterators[0].iter.valid = true; DEG_iterator_objects_begin(&di_it->iterators[0].iter, data); @@ -392,6 +411,11 @@ static void rna_Depsgraph_object_instances_end(CollectionPropertyIterator *iter) iter->internal.custom; for (int i = 0; i < ARRAY_SIZE(di_it->iterators); i++) { RNA_DepsgraphIterator *di = &di_it->iterators[i]; + DEGObjectIterData *data = &di_it->deg_data[i]; + if (i == 0) { + /* Is shared between both iterators. */ + MEM_freeN(data->settings); + } DEG_iterator_objects_end(&di->iter); # ifdef WITH_PYTHON @@ -740,14 +764,13 @@ static void rna_def_depsgraph(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Scene"); RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_eval_get", NULL, NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for"); + RNA_def_property_ui_text(prop, "Scene", "Scene at its evaluated state"); prop = RNA_def_property(srna, "view_layer_eval", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ViewLayer"); RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_eval_get", NULL, NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text( - prop, "View Layer", "Original view layer dependency graph is built for"); + RNA_def_property_ui_text(prop, "View Layer", "View layer at its evaluated state"); /* Iterators. */ diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 727d329781d..9fe7dda0e20 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -2416,7 +2416,7 @@ static void rna_def_fcurve(BlenderRNA *brna) prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor"); RNA_def_property_update(prop, NC_ANIMATION, NULL); - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor"); diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index 384ce8f04fb..bd601d0a736 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -20,6 +20,8 @@ #include "BKE_modifier.h" #include "BKE_pointcache.h" +#include "BLT_translation.h" + #include "DNA_fluid_types.h" #include "DNA_modifier_types.h" #include "DNA_object_force_types.h" @@ -570,14 +572,14 @@ static const EnumPropertyItem *rna_Fluid_cachetype_mesh_itemf(bContext *UNUSED(C tmp.value = FLUID_DOMAIN_FILE_BIN_OBJECT; tmp.identifier = "BOBJECT"; - tmp.name = "Binary Object"; - tmp.description = "Binary object file format (.bobj.gz)"; + tmp.name = N_("Binary Object"); + tmp.description = N_("Binary object file format (.bobj.gz)"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FILE_OBJECT; tmp.identifier = "OBJECT"; - tmp.name = "Object"; - tmp.description = "Object file format (.obj)"; + tmp.name = N_("Object"); + tmp.description = N_("Object file format (.obj)"); RNA_enum_item_add(&item, &totitem, &tmp); RNA_enum_item_end(&item, &totitem); @@ -597,15 +599,15 @@ static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED tmp.value = FLUID_DOMAIN_FILE_UNI; tmp.identifier = "UNI"; - tmp.name = "Uni Cache"; - tmp.description = "Uni file format (.uni)"; + tmp.name = N_("Uni Cache"); + tmp.description = N_("Uni file format (.uni)"); RNA_enum_item_add(&item, &totitem, &tmp); # ifdef WITH_OPENVDB tmp.value = FLUID_DOMAIN_FILE_OPENVDB; tmp.identifier = "OPENVDB"; - tmp.name = "OpenVDB"; - tmp.description = "OpenVDB file format (.vdb)"; + tmp.name = N_("OpenVDB"); + tmp.description = N_("OpenVDB file format (.vdb)"); RNA_enum_item_add(&item, &totitem, &tmp); # endif @@ -615,8 +617,8 @@ static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED fds->cache_noise_format == FLUID_DOMAIN_FILE_RAW) { tmp.value = FLUID_DOMAIN_FILE_RAW; tmp.identifier = "RAW"; - tmp.name = "Raw Cache"; - tmp.description = "Raw file format (.raw)"; + tmp.name = N_("Raw Cache"); + tmp.description = N_("Raw file format (.raw)"); RNA_enum_item_add(&item, &totitem, &tmp); } @@ -637,8 +639,8 @@ static const EnumPropertyItem *rna_Fluid_cachetype_particle_itemf(bContext *UNUS tmp.value = FLUID_DOMAIN_FILE_UNI; tmp.identifier = "UNI"; - tmp.name = "Uni Cache"; - tmp.description = "Uni file format"; + tmp.name = N_("Uni Cache"); + tmp.description = N_("Uni file format"); RNA_enum_item_add(&item, &totitem, &tmp); RNA_enum_item_end(&item, &totitem); @@ -676,136 +678,136 @@ static const EnumPropertyItem *rna_Fluid_cobafield_itemf(bContext *UNUSED(C), tmp.value = FLUID_DOMAIN_FIELD_FLAGS; tmp.identifier = "FLAGS"; tmp.icon = 0; - tmp.name = "Flags"; - tmp.description = "Flag grid of the fluid domain"; + tmp.name = N_("Flags"); + tmp.description = N_("Flag grid of the fluid domain"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_PRESSURE; tmp.identifier = "PRESSURE"; tmp.icon = 0; - tmp.name = "Pressure"; - tmp.description = "Pressure field of the fluid domain"; + tmp.name = N_("Pressure"); + tmp.description = N_("Pressure field of the fluid domain"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_X; tmp.identifier = "VELOCITY_X"; tmp.icon = 0; - tmp.name = "X Velocity"; - tmp.description = "X component of the velocity field"; + tmp.name = N_("X Velocity"); + tmp.description = N_("X component of the velocity field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_Y; tmp.identifier = "VELOCITY_Y"; tmp.icon = 0; - tmp.name = "Y Velocity"; - tmp.description = "Y component of the velocity field"; + tmp.name = N_("Y Velocity"); + tmp.description = N_("Y component of the velocity field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_Z; tmp.identifier = "VELOCITY_Z"; tmp.icon = 0; - tmp.name = "Z Velocity"; - tmp.description = "Z component of the velocity field"; + tmp.name = N_("Z Velocity"); + tmp.description = N_("Z component of the velocity field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_FORCE_X; tmp.identifier = "FORCE_X"; tmp.icon = 0; - tmp.name = "X Force"; - tmp.description = "X component of the force field"; + tmp.name = N_("X Force"); + tmp.description = N_("X component of the force field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_FORCE_Y; tmp.identifier = "FORCE_Y"; tmp.icon = 0; - tmp.name = "Y Force"; - tmp.description = "Y component of the force field"; + tmp.name = N_("Y Force"); + tmp.description = N_("Y component of the force field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_FORCE_Z; tmp.identifier = "FORCE_Z"; tmp.icon = 0; - tmp.name = "Z Force"; - tmp.description = "Z component of the force field"; + tmp.name = N_("Z Force"); + tmp.description = N_("Z component of the force field"); RNA_enum_item_add(&item, &totitem, &tmp); if (settings->type == FLUID_DOMAIN_TYPE_GAS) { tmp.value = FLUID_DOMAIN_FIELD_COLOR_R; tmp.identifier = "COLOR_R"; tmp.icon = 0; - tmp.name = "Red"; - tmp.description = "Red component of the color field"; + tmp.name = N_("Red"); + tmp.description = N_("Red component of the color field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_COLOR_G; tmp.identifier = "COLOR_G"; tmp.icon = 0; - tmp.name = "Green"; - tmp.description = "Green component of the color field"; + tmp.name = N_("Green"); + tmp.description = N_("Green component of the color field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_COLOR_B; tmp.identifier = "COLOR_B"; tmp.icon = 0; - tmp.name = "Blue"; - tmp.description = "Blue component of the color field"; + tmp.name = N_("Blue"); + tmp.description = N_("Blue component of the color field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_DENSITY; tmp.identifier = "DENSITY"; tmp.icon = 0; - tmp.name = "Density"; - tmp.description = "Quantity of soot in the fluid"; + tmp.name = N_("Density"); + tmp.description = N_("Quantity of soot in the fluid"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_FLAME; tmp.identifier = "FLAME"; tmp.icon = 0; - tmp.name = "Flame"; - tmp.description = "Flame field"; + tmp.name = N_("Flame"); + tmp.description = N_("Flame field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_FUEL; tmp.identifier = "FUEL"; tmp.icon = 0; - tmp.name = "Fuel"; - tmp.description = "Fuel field"; + tmp.name = N_("Fuel"); + tmp.description = N_("Fuel field"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_HEAT; tmp.identifier = "HEAT"; tmp.icon = 0; - tmp.name = "Heat"; - tmp.description = "Temperature of the fluid"; + tmp.name = N_("Heat"); + tmp.description = N_("Temperature of the fluid"); RNA_enum_item_add(&item, &totitem, &tmp); } else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) { tmp.value = FLUID_DOMAIN_FIELD_PHI; tmp.identifier = "PHI"; tmp.icon = 0; - tmp.name = "Fluid Levelset"; - tmp.description = "Levelset representation of the fluid"; + tmp.name = N_("Fluid Level Set"); + tmp.description = N_("Level set representation of the fluid"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_PHI_IN; tmp.identifier = "PHI_IN"; tmp.icon = 0; - tmp.name = "Inflow Levelset"; - tmp.description = "Levelset representation of the inflow"; + tmp.name = N_("Inflow Level Set"); + tmp.description = N_("Level set representation of the inflow"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_PHI_OUT; tmp.identifier = "PHI_OUT"; tmp.icon = 0; - tmp.name = "Outflow Levelset"; - tmp.description = "Levelset representation of the outflow"; + tmp.name = N_("Outflow Level Set"); + tmp.description = N_("Level set representation of the outflow"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = FLUID_DOMAIN_FIELD_PHI_OBSTACLE; tmp.identifier = "PHI_OBSTACLE"; tmp.icon = 0; - tmp.name = "Obstacle Levelset"; - tmp.description = "Levelset representation of the obstacles"; + tmp.name = N_("Obstacle Level Set"); + tmp.description = N_("Level set representation of the obstacles"); RNA_enum_item_add(&item, &totitem, &tmp); } @@ -829,23 +831,23 @@ static const EnumPropertyItem *rna_Fluid_data_depth_itemf(bContext *UNUSED(C), tmp.value = VDB_PRECISION_FULL_FLOAT; tmp.identifier = "32"; tmp.icon = 0; - tmp.name = "Full"; - tmp.description = "Full float (Use 32 bit for all data)"; + tmp.name = N_("Full"); + tmp.description = N_("Full float (Use 32 bit for all data)"); RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = VDB_PRECISION_HALF_FLOAT; tmp.identifier = "16"; tmp.icon = 0; - tmp.name = "Half"; - tmp.description = "Half float (Use 16 bit for all data)"; + tmp.name = N_("Half"); + tmp.description = N_("Half float (Use 16 bit for all data)"); RNA_enum_item_add(&item, &totitem, &tmp); if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) { tmp.value = VDB_PRECISION_MINI_FLOAT; tmp.identifier = "8"; tmp.icon = 0; - tmp.name = "Mini"; - tmp.description = "Mini float (Use 8 bit where possible, otherwise use 16 bit)"; + tmp.name = N_("Mini"); + tmp.description = N_("Mini float (Use 8 bit where possible, otherwise use 16 bit)"); RNA_enum_item_add(&item, &totitem, &tmp); } @@ -1192,16 +1194,16 @@ static const EnumPropertyItem *rna_Fluid_flowsource_itemf(bContext *UNUSED(C), tmp.value = FLUID_FLOW_SOURCE_MESH; tmp.identifier = "MESH"; tmp.icon = ICON_META_CUBE; - tmp.name = "Mesh"; - tmp.description = "Emit fluid from mesh surface or volume"; + tmp.name = N_("Mesh"); + tmp.description = N_("Emit fluid from mesh surface or volume"); RNA_enum_item_add(&item, &totitem, &tmp); if (settings->type != FLUID_FLOW_TYPE_LIQUID) { tmp.value = FLUID_FLOW_SOURCE_PARTICLES; tmp.identifier = "PARTICLES"; tmp.icon = ICON_PARTICLES; - tmp.name = "Particle System"; - tmp.description = "Emit smoke from particles"; + tmp.name = N_("Particle System"); + tmp.description = N_("Emit smoke from particles"); RNA_enum_item_add(&item, &totitem, &tmp); } diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index cf0ff546d41..a55a1b0ffcd 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -334,13 +334,13 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr, const char ** static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *substr) { if (type == PAROBJECT) { - invert_m4_m4(gpl->inverse, par->obmat); + invert_m4_m4(gpl->inverse, par->object_to_world); gpl->parent = par; gpl->partype |= PAROBJECT; gpl->parsubstr[0] = 0; } else if (type == PARSKEL) { - invert_m4_m4(gpl->inverse, par->obmat); + invert_m4_m4(gpl->inverse, par->object_to_world); gpl->parent = par; gpl->partype |= PARSKEL; gpl->parsubstr[0] = 0; @@ -349,7 +349,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * bPoseChannel *pchan = BKE_pose_channel_find_name(par->pose, substr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, par->obmat, pchan->pose_mat); + mul_m4_m4m4(tmp_mat, par->object_to_world, pchan->pose_mat); invert_m4_m4(gpl->inverse, tmp_mat); gpl->parent = par; @@ -357,7 +357,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * BLI_strncpy(gpl->parsubstr, substr, sizeof(gpl->parsubstr)); } else { - invert_m4_m4(gpl->inverse, par->obmat); + invert_m4_m4(gpl->inverse, par->object_to_world); gpl->parent = par; gpl->partype |= PAROBJECT; gpl->parsubstr[0] = 0; diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 2dfd9d46665..320ef169ae5 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -9,11 +9,8 @@ #include <stdlib.h> #include "DNA_armature_types.h" -#include "DNA_brush_types.h" -#include "DNA_cachefile_types.h" #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" @@ -21,20 +18,13 @@ #include "MEM_guardedalloc.h" -#include "BLI_math.h" -#include "BLI_rand.h" +#include "BLI_math_base.h" +#include "BLI_math_rotation.h" #include "BLI_string_utils.h" #include "BLT_translation.h" #include "BKE_animsys.h" -#include "BKE_data_transfer.h" -#include "BKE_dynamicpaint.h" -#include "BKE_effect.h" -#include "BKE_fluid.h" /* For BKE_fluid_modifier_free & BKE_fluid_modifier_create_type_data */ -#include "BKE_mesh_mapping.h" -#include "BKE_mesh_remap.h" -#include "BKE_multires.h" #include "RNA_access.h" #include "RNA_define.h" @@ -82,7 +72,7 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { "Generate dot-dash styled strokes"}, {eGpencilModifierType_Envelope, "GP_ENVELOPE", - ICON_MOD_SKIN, + ICON_MOD_ENVELOPE, "Envelope", "Create an envelope shape"}, {eGpencilModifierType_Length, @@ -105,6 +95,11 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { ICON_GP_MULTIFRAME_EDITING, "Multiple Strokes", "Produce multiple strokes along one stroke"}, + {eGpencilModifierType_Outline, + "GP_OUTLINE", + ICON_MOD_OUTLINE, + "Outline", + "Convert stroke to perimeter"}, {eGpencilModifierType_Simplify, "GP_SIMPLIFY", ICON_MOD_SIMPLIFY, @@ -196,7 +191,19 @@ static const EnumPropertyItem rna_enum_time_mode_items[] = { {GP_TIME_MODE_NORMAL, "NORMAL", 0, "Regular", "Apply offset in usual animation direction"}, {GP_TIME_MODE_REVERSE, "REVERSE", 0, "Reverse", "Apply offset in reverse animation direction"}, {GP_TIME_MODE_FIX, "FIX", 0, "Fixed Frame", "Keep frame and do not change with time"}, - {GP_TIME_MODE_PINGPONG, "PINGPONG", 0, "Ping Pong", "Loop back and forth"}, + {GP_TIME_MODE_PINGPONG, "PINGPONG", 0, "Ping Pong", "Loop back and forth starting in reverse"}, + {GP_TIME_MODE_CHAIN, "CHAIN", 0, "Chain", "List of chained animation segments"}, + {0, NULL, 0, NULL, NULL}, +}; + +static const EnumPropertyItem rna_enum_time_seg_mode_items[] = { + {GP_TIME_SEG_MODE_NORMAL, "NORMAL", 0, "Regular", "Apply offset in usual animation direction"}, + {GP_TIME_SEG_MODE_REVERSE, + "REVERSE", + 0, + "Reverse", + "Apply offset in reverse animation direction"}, + {GP_TIME_SEG_MODE_PINGPONG, "PINGPONG", 0, "Ping Pong", "Loop back and forth"}, {0, NULL, 0, NULL, NULL}, }; @@ -286,6 +293,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr) return &RNA_BuildGpencilModifier; case eGpencilModifierType_Opacity: return &RNA_OpacityGpencilModifier; + case eGpencilModifierType_Outline: + return &RNA_OutlineGpencilModifier; case eGpencilModifierType_Lattice: return &RNA_LatticeGpencilModifier; case eGpencilModifierType_Length: @@ -668,6 +677,37 @@ static void rna_OpacityGpencilModifier_material_set(PointerRNA *ptr, rna_GpencilModifier_material_set(ptr, value, ma_target, reports); } +static void rna_OutlineGpencilModifier_object_set(PointerRNA *ptr, + PointerRNA value, + struct ReportList *UNUSED(reports)) +{ + OutlineGpencilModifierData *omd = ptr->data; + Object *ob = (Object *)value.data; + + omd->object = ob; + id_lib_extern((ID *)ob); +} + +static void rna_OutlineGpencilModifier_material_set(PointerRNA *ptr, + PointerRNA value, + struct ReportList *reports) +{ + OutlineGpencilModifierData *omd = (OutlineGpencilModifierData *)ptr->data; + Material **ma_target = &omd->material; + + rna_GpencilModifier_material_set(ptr, value, ma_target, reports); +} + +static void rna_OutlineStrokeGpencilModifier_material_set(PointerRNA *ptr, + PointerRNA value, + struct ReportList *reports) +{ + OutlineGpencilModifierData *omd = (OutlineGpencilModifierData *)ptr->data; + Material **ma_target = &omd->outline_material; + + rna_GpencilModifier_material_set(ptr, value, ma_target, reports); +} + static void rna_LatticeGpencilModifier_material_set(PointerRNA *ptr, PointerRNA value, struct ReportList *reports) @@ -753,7 +793,32 @@ static void rna_GpencilDash_segments_begin(CollectionPropertyIterator *iter, Poi iter, dmd->segments, sizeof(DashGpencilModifierSegment), dmd->segments_len, false, NULL); } +static void rna_GpencilTime_segments_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)ptr->data; + rna_iterator_array_begin( + iter, gpmd->segments, sizeof(TimeGpencilModifierSegment), gpmd->segments_len, false, NULL); +} + +static char *rna_TimeGpencilModifierSegment_path(const PointerRNA *ptr) +{ + TimeGpencilModifierSegment *ds = (TimeGpencilModifierSegment *)ptr->data; + + TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)ds->gpmd; + + BLI_assert(gpmd != NULL); + + char name_esc[sizeof(gpmd->modifier.name) * 2]; + BLI_str_escape(name_esc, gpmd->modifier.name, sizeof(name_esc)); + + char ds_name_esc[sizeof(ds->name) * 2]; + BLI_str_escape(ds_name_esc, ds->name, sizeof(ds_name_esc)); + + return BLI_sprintfN("grease_pencil_modifiers[\"%s\"].segments[\"%s\"]", name_esc, ds_name_esc); +} + static char *rna_DashGpencilModifierSegment_path(const PointerRNA *ptr) + { const DashGpencilModifierSegment *ds = (DashGpencilModifierSegment *)ptr->data; @@ -781,6 +846,17 @@ static bool dash_segment_name_exists_fn(void *arg, const char *name) return false; } +static bool time_segment_name_exists_fn(void *arg, const char *name) +{ + const TimeGpencilModifierData *gpmd = (const TimeGpencilModifierData *)arg; + for (int i = 0; i < gpmd->segments_len; i++) { + if (STREQ(gpmd->segments[i].name, name) && gpmd->segments[i].name != name) { + return true; + } + } + return false; +} + static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char *value) { DashGpencilModifierSegment *ds = ptr->data; @@ -804,6 +880,29 @@ static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char BKE_animdata_fix_paths_rename_all(NULL, prefix, oldname, ds->name); } +static void rna_TimeGpencilModifierSegment_name_set(PointerRNA *ptr, const char *value) +{ + TimeGpencilModifierSegment *ds = ptr->data; + + char oldname[sizeof(ds->name)]; + BLI_strncpy(oldname, ds->name, sizeof(ds->name)); + + BLI_strncpy_utf8(ds->name, value, sizeof(ds->name)); + + BLI_assert(ds->gpmd != NULL); + BLI_uniquename_cb( + time_segment_name_exists_fn, ds->gpmd, "Segment", '.', ds->name, sizeof(ds->name)); + + char name_esc[sizeof(ds->gpmd->modifier.name) * 2]; + BLI_str_escape(name_esc, ds->gpmd->modifier.name, sizeof(name_esc)); + + char prefix[36 + sizeof(name_esc) + 1]; + SNPRINTF(prefix, "grease_pencil_modifiers[\"%s\"].segments", name_esc); + + /* Fix all the animation data which may link to this. */ + 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; @@ -1680,6 +1779,38 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + srna = RNA_def_struct(brna, "TimeGpencilModifierSegment", NULL); + RNA_def_struct_ui_text(srna, "Time Modifier Segment", "Configuration for a single dash segment"); + RNA_def_struct_sdna(srna, "TimeGpencilModifierSegment"); + RNA_def_struct_path_func(srna, "rna_TimeGpencilModifierSegment_path"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", "Name of the dash segment"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_TimeGpencilModifierSegment_name_set"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "seg_start", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, INT16_MAX); + RNA_def_property_ui_text(prop, "Frame Start", "First frame of the segment"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "seg_end", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, INT16_MAX); + RNA_def_property_ui_text(prop, "End", "Last frame of the segment"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "seg_repeat", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, INT16_MAX); + RNA_def_property_ui_text(prop, "Repeat", "Number of cycle repeats"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "seg_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "seg_mode"); + RNA_def_property_enum_items(prop, rna_enum_time_seg_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); srna = RNA_def_struct(brna, "TimeGpencilModifier", "GpencilModifier"); RNA_def_struct_ui_text(srna, "Time Offset Modifier", "Time offset modifier"); @@ -1688,6 +1819,24 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna) RNA_define_lib_overridable(true); + prop = RNA_def_property(srna, "segments", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "TimeGpencilModifierSegment"); + RNA_def_property_collection_sdna(prop, NULL, "segments", NULL); + RNA_def_property_collection_funcs(prop, + "rna_GpencilTime_segments_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + NULL, + NULL, + NULL, + NULL); + RNA_def_property_ui_text(prop, "Segments", ""); + + prop = RNA_def_property(srna, "segment_active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Active Dash Segment Index", "Active index in the segment list"); + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, rna_enum_time_mode_items); @@ -1972,6 +2121,107 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna) RNA_define_lib_overridable(false); } +static void rna_def_modifier_gpenciloutline(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "OutlineGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text(srna, "Outline Modifier", "Outline of Strokes modifier from camera view"); + RNA_def_struct_sdna(srna, "OutlineGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_OUTLINE); + + RNA_define_lib_overridable(true); + + 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_OutlineGpencilModifier_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, "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_OUTLINE_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_OUTLINE_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_OUTLINE_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, "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_OUTLINE_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, "thickness", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "thickness"); + RNA_def_property_range(prop, 1, 1000); + RNA_def_property_ui_text(prop, "Thickness", "Thickness of the perimeter stroke"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "sample_length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sample_length"); + RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1f, 2); + RNA_def_property_ui_text(prop, "Sample Length", ""); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "subdivision", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "subdiv"); + RNA_def_property_range(prop, 0, 10); + RNA_def_property_ui_text(prop, "Subdivisions", "Number of subdivisions"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_keep_shape", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OUTLINE_KEEP_SHAPE); + RNA_def_property_ui_text(prop, "Keep Shape", "Try to keep global shape"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "outline_material", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, + NULL, + "rna_OutlineStrokeGpencilModifier_material_set", + NULL, + "rna_GpencilModifier_material_poll"); + RNA_def_property_ui_text(prop, "Outline Material", "Material used for outline strokes"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Target Object", "Target object to define stroke start"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_pointer_funcs(prop, NULL, "rna_OutlineGpencilModifier_object_set", NULL, NULL); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + RNA_define_lib_overridable(false); +} + static void rna_def_modifier_gpencilarray(BlenderRNA *brna) { StructRNA *srna; @@ -4170,7 +4420,7 @@ static void rna_def_modifier_gpencilenvelope(BlenderRNA *brna) srna = RNA_def_struct(brna, "EnvelopeGpencilModifier", "GpencilModifier"); RNA_def_struct_ui_text(srna, "Envelope Modifier", "Envelope stroke effect modifier"); RNA_def_struct_sdna(srna, "EnvelopeGpencilModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN); + RNA_def_struct_ui_icon(srna, ICON_MOD_ENVELOPE); RNA_define_lib_overridable(true); @@ -4353,6 +4603,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna) rna_def_modifier_gpencilarray(brna); rna_def_modifier_gpencilbuild(brna); rna_def_modifier_gpencilopacity(brna); + rna_def_modifier_gpenciloutline(brna); rna_def_modifier_gpencillattice(brna); rna_def_modifier_gpencilmirror(brna); rna_def_modifier_gpencilhook(brna); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index b7ab7689dd7..4e7c06bd37c 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -177,7 +177,7 @@ void rna_Image_generated_color_set(PointerRNA *ptr, const float values[4]) { Image *ima = (Image *)(ptr->data); ImageTile *base_tile = BKE_image_get_tile(ima, 0); - for (unsigned int i = 0; i < 4; i++) { + for (uint i = 0; i < 4; i++) { base_tile->gen_color[i] = CLAMPIS(values[i], 0.0f, FLT_MAX); } } @@ -625,7 +625,7 @@ static void rna_Image_pixels_get(PointerRNA *ptr, float *values) } else { for (i = 0; i < size; i++) { - values[i] = ((unsigned char *)ibuf->rect)[i] * (1.0f / 255.0f); + values[i] = ((uchar *)ibuf->rect)[i] * (1.0f / 255.0f); } } } @@ -650,7 +650,7 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values) } else { for (i = 0; i < size; i++) { - ((unsigned char *)ibuf->rect)[i] = unit_float_to_uchar_clamp(values[i]); + ((uchar *)ibuf->rect)[i] = unit_float_to_uchar_clamp(values[i]); } } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 3d5c1810558..ea829e5cd86 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -24,7 +24,7 @@ struct AssetLibraryReference; struct FreestyleSettings; struct ID; struct IDOverrideLibrary; -struct IDOverrideLibraryPropertyOperation; +struct IDOverrideLibraryenOperation; struct IDProperty; struct Main; struct Object; @@ -322,7 +322,9 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr, PointerRNA rna_object_shapekey_index_get(struct ID *id, int value); int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current); -void rna_def_object_type_visibility_flags_common(StructRNA *srna, int noteflag); +void rna_def_object_type_visibility_flags_common(StructRNA *srna, + int noteflag, + const char *update_func); int rna_object_type_visibility_icon_get_common(int object_type_exclude_viewport, const int *object_type_exclude_select); diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 6ab9d3a46ad..b08d4b60fcc 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -50,8 +50,10 @@ static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr) { + const Scene *scene = (const Scene *)ptr->owner_id; ViewLayer *view_layer = (ViewLayer *)ptr->data; - LayerCollection *lc = view_layer->active_collection; + BKE_view_layer_synced_ensure(scene, view_layer); + LayerCollection *lc = BKE_view_layer_active_collection_get(view_layer); return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc); } @@ -59,8 +61,10 @@ static void rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) { + const Scene *scene = (const Scene *)ptr->owner_id; ViewLayer *view_layer = (ViewLayer *)ptr->data; LayerCollection *lc = (LayerCollection *)value.data; + BKE_view_layer_synced_ensure(scene, view_layer); const int index = BKE_layer_collection_findindex(view_layer, lc); if (index != -1) { BKE_layer_collection_activate(view_layer, lc); @@ -69,18 +73,22 @@ static void rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr, static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr) { + const Scene *scene = (Scene *)ptr->owner_id; ViewLayer *view_layer = (ViewLayer *)ptr->data; + BKE_view_layer_synced_ensure(scene, view_layer); return rna_pointer_inherit_refine( - ptr, &RNA_Object, view_layer->basact ? view_layer->basact->object : NULL); + ptr, &RNA_Object, BKE_view_layer_active_object_get(view_layer)); } static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value, struct ReportList *reports) { + const Scene *scene = (Scene *)ptr->owner_id; ViewLayer *view_layer = (ViewLayer *)ptr->data; if (value.data) { Object *ob = value.data; + BKE_view_layer_synced_ensure(scene, view_layer); Base *basact_test = BKE_view_layer_base_find(view_layer, ob); if (basact_test != NULL) { view_layer->basact = basact_test; @@ -197,7 +205,7 @@ static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, Po { ViewLayer *view_layer = (ViewLayer *)ptr->data; rna_iterator_listbase_begin( - iter, &view_layer->object_bases, rna_ViewLayer_objects_selected_skip); + iter, BKE_view_layer_object_bases_get(view_layer), rna_ViewLayer_objects_selected_skip); } static void rna_ViewLayer_update_tagged(ID *id_ptr, @@ -245,7 +253,7 @@ static void rna_ObjectBase_hide_viewport_update(bContext *C, PointerRNA *UNUSED( { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - BKE_layer_collection_sync(scene, view_layer); + BKE_view_layer_need_resync_tag(view_layer); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -309,13 +317,13 @@ static void rna_LayerCollection_exclude_update(Main *bmain, Scene *UNUSED(scene) const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0; BKE_layer_collection_set_flag(lc, LAYER_COLLECTION_EXCLUDE, exclude); - BKE_layer_collection_sync(scene, view_layer); + BKE_view_layer_need_resync_tag(view_layer); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); if (!exclude) { /* We need to update animation of objects added back to the scene through enabling this view * layer. */ - FOREACH_OBJECT_BEGIN (view_layer, ob) { + FOREACH_OBJECT_BEGIN (scene, view_layer, ob) { DEG_id_tag_update(&ob->id, ID_RECALC_ANIMATION); } FOREACH_OBJECT_END; @@ -334,7 +342,7 @@ static void rna_LayerCollection_update(Main *UNUSED(bmain), Scene *UNUSED(scene) LayerCollection *lc = (LayerCollection *)ptr->data; ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc); - BKE_layer_collection_sync(scene, view_layer); + BKE_view_layer_need_resync_tag(view_layer); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); @@ -347,9 +355,63 @@ static bool rna_LayerCollection_has_objects(LayerCollection *lc) return (lc->runtime_flag & LAYER_COLLECTION_HAS_OBJECTS) != 0; } -static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc, ViewLayer *view_layer) +static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc, + Main *bmain, + ViewLayer *view_layer) { - return BKE_layer_collection_has_selected_objects(view_layer, lc); + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + LISTBASE_FOREACH (ViewLayer *, scene_view_layer, &scene->view_layers) { + if (scene_view_layer == view_layer) { + return BKE_layer_collection_has_selected_objects(scene, view_layer, lc); + } + } + } + return false; +} + +void rna_LayerCollection_children_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Scene *scene = (Scene *)ptr->owner_id; + LayerCollection *lc = (LayerCollection *)ptr->data; + ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc); + BKE_view_layer_synced_ensure(scene, view_layer); + + rna_iterator_listbase_begin(iter, &lc->layer_collections, NULL); +} + +static bool rna_LayerCollection_children_lookupint(struct PointerRNA *ptr, + int key, + struct PointerRNA *r_ptr) +{ + Scene *scene = (Scene *)ptr->owner_id; + LayerCollection *lc = (LayerCollection *)ptr->data; + ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc); + BKE_view_layer_synced_ensure(scene, view_layer); + + LayerCollection *child = BLI_findlink(&lc->layer_collections, key); + if (!child) { + return false; + } + RNA_pointer_create(ptr->owner_id, &RNA_LayerCollection, child, r_ptr); + return true; +} + +static bool rna_LayerCollection_children_lookupstring(struct PointerRNA *ptr, + const char *key, + struct PointerRNA *r_ptr) +{ + Scene *scene = (Scene *)ptr->owner_id; + LayerCollection *lc = (LayerCollection *)ptr->data; + ViewLayer *view_layer = BKE_view_layer_find_from_collection(scene, lc); + BKE_view_layer_synced_ensure(scene, view_layer); + + LISTBASE_FOREACH (LayerCollection *, child, &lc->layer_collections) { + if (STREQ(child->collection->id.name + 2, key)) { + RNA_pointer_create(ptr->owner_id, &RNA_LayerCollection, child, r_ptr); + return true; + } + } + return false; } #else @@ -382,6 +444,15 @@ static void rna_def_layer_collection(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL); RNA_def_property_struct_type(prop, "LayerCollection"); RNA_def_property_ui_text(prop, "Children", "Child layer collections"); + RNA_def_property_collection_funcs(prop, + "rna_LayerCollection_children_begin", + NULL, + NULL, + NULL, + NULL, + "rna_LayerCollection_children_lookupint", + "rna_LayerCollection_children_lookupstring", + NULL); /* Restriction flags. */ prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE); @@ -442,6 +513,7 @@ static void rna_def_layer_collection(BlenderRNA *brna) func = RNA_def_function( srna, "has_selected_objects", "rna_LayerCollection_has_selected_objects"); + RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, ""); prop = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "View layer the layer collection belongs to"); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 1f21fa3fab9..35678f2f1dd 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -629,6 +629,7 @@ static bAction *rna_Main_actions_new(Main *bmain, const char *name) bAction *act = BKE_action_add(bmain, safe_name); id_fake_user_clear(&act->id); + id_us_min(&act->id); WM_main_add_notifier(NC_ID | NA_ADDED, NULL); @@ -701,6 +702,7 @@ static Mask *rna_Main_mask_new(Main *bmain, const char *name) rna_idname_validate(name, safe_name); Mask *mask = BKE_mask_new(bmain, safe_name); + id_us_min(&mask->id); WM_main_add_notifier(NC_ID | NA_ADDED, NULL); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 252d2e657b5..1616684cb6a 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -142,7 +142,6 @@ static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, Pointe static void rna_Material_active_paint_texture_index_update(bContext *C, PointerRNA *ptr) { Main *bmain = CTX_data_main(C); - bScreen *screen; Material *ma = (Material *)ptr->owner_id; if (ma->use_nodes && ma->nodetree) { @@ -157,25 +156,7 @@ static void rna_Material_active_paint_texture_index_update(bContext *C, PointerR TexPaintSlot *slot = &ma->texpaintslot[ma->paint_active_slot]; Image *image = slot->ima; if (image) { - for (screen = bmain->screens.first; screen; screen = screen->id.next) { - wmWindow *win = ED_screen_window_find(screen, bmain->wm.first); - if (win == NULL) { - continue; - } - - ScrArea *area; - for (area = screen->areabase.first; area; area = area->next) { - SpaceLink *sl; - for (sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)sl; - if (!sima->pin) { - ED_space_image_set(bmain, sima, image, true); - } - } - } - } - } + ED_space_image_sync(bmain, image, false); } /* For compatibility reasons with vertex paint we activate the color attribute. */ diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 28ceb0d1d9d..f13132b5b7c 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -108,7 +108,7 @@ static CustomData *rna_mesh_vdata(const PointerRNA *ptr) Mesh *me = rna_mesh(ptr); return rna_mesh_vdata_helper(me); } -static CustomData *rna_mesh_edata(PointerRNA *ptr) +static CustomData *rna_mesh_edata(const PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); return rna_mesh_edata_helper(me); @@ -239,6 +239,16 @@ static bool rna_Mesh_has_vertex_bevel_weight_get(PointerRNA *ptr) return CustomData_has_layer(rna_mesh_vdata(ptr), CD_BWEIGHT); } +static bool rna_Mesh_has_edge_crease_get(PointerRNA *ptr) +{ + return CustomData_has_layer(rna_mesh_edata(ptr), CD_CREASE); +} + +static bool rna_Mesh_has_vertex_crease_get(PointerRNA *ptr) +{ + return CustomData_has_layer(rna_mesh_vdata(ptr), CD_CREASE); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -396,12 +406,39 @@ static int rna_MeshLoopTriangle_index_get(PointerRNA *ptr) { const Mesh *mesh = rna_mesh(ptr); const MLoopTri *ltri = (MLoopTri *)ptr->data; - const int index = (int)(ltri - mesh->runtime.looptris.array); + const int index = (int)(ltri - BKE_mesh_runtime_looptri_ensure(mesh)); BLI_assert(index >= 0); - BLI_assert(index < mesh->runtime.looptris.len); + BLI_assert(index < BKE_mesh_runtime_looptri_len(mesh)); return index; } +static void rna_Mesh_loop_triangles_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + const MLoopTri *looptris = BKE_mesh_runtime_looptri_ensure(mesh); + rna_iterator_array_begin( + iter, (void *)looptris, sizeof(MLoopTri), BKE_mesh_runtime_looptri_len(mesh), false, NULL); +} + +static int rna_Mesh_loop_triangles_length(PointerRNA *ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + return BKE_mesh_runtime_looptri_len(mesh); +} + +int rna_Mesh_loop_triangles_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + if (index < 0 || index >= BKE_mesh_runtime_looptri_len(mesh)) { + return false; + } + /* Casting away const is okay because this RNA type doesn't allow changing the value. */ + r_ptr->owner_id = (ID *)&mesh->id; + r_ptr->type = &RNA_MeshLoopTriangle; + r_ptr->data = (void *)&BKE_mesh_runtime_looptri_ensure(mesh)[index]; + return true; +} + static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value) { Mesh *mesh = rna_mesh(ptr); @@ -436,6 +473,32 @@ static void rna_MeshVertex_hide_set(PointerRNA *ptr, bool value) hide_vert[index] = value; } +static bool rna_MeshVertex_select_get(PointerRNA *ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + const bool *select_vert = (const bool *)CustomData_get_layer_named( + &mesh->vdata, CD_PROP_BOOL, ".select_vert"); + const int index = rna_MeshVertex_index_get(ptr); + return select_vert == NULL ? false : select_vert[index]; +} + +static void rna_MeshVertex_select_set(PointerRNA *ptr, bool value) +{ + Mesh *mesh = rna_mesh(ptr); + bool *select_vert = (bool *)CustomData_duplicate_referenced_layer_named( + &mesh->vdata, CD_PROP_BOOL, ".select_vert", mesh->totvert); + if (!select_vert) { + if (!value) { + /* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */ + return; + } + select_vert = (bool *)CustomData_add_layer_named( + &mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totvert, ".select_vert"); + } + const int index = rna_MeshVertex_index_get(ptr); + select_vert[index] = value; +} + static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr) { const Mesh *mesh = rna_mesh(ptr); @@ -472,14 +535,19 @@ static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value) static float rna_MEdge_crease_get(PointerRNA *ptr) { - MEdge *medge = (MEdge *)ptr->data; - return medge->crease / 255.0f; + const Mesh *mesh = rna_mesh(ptr); + const int index = rna_MeshEdge_index_get(ptr); + const float *values = (const float *)CustomData_get_layer(&mesh->edata, CD_CREASE); + return values == NULL ? 0.0f : values[index]; } static void rna_MEdge_crease_set(PointerRNA *ptr, float value) { - MEdge *medge = (MEdge *)ptr->data; - medge->crease = round_fl_to_uchar_clamp(value * 255.0f); + Mesh *mesh = rna_mesh(ptr); + const int index = rna_MeshEdge_index_get(ptr); + float *values = (float *)CustomData_add_layer( + &mesh->edata, CD_CREASE, CD_SET_DEFAULT, NULL, mesh->totedge); + values[index] = clamp_f(value, 0.0f, 1.0f); } static void rna_MeshLoop_normal_get(PointerRNA *ptr, float *values) @@ -581,6 +649,32 @@ static void rna_MeshPolygon_hide_set(PointerRNA *ptr, bool value) hide_poly[index] = value; } +static bool rna_MeshPolygon_select_get(PointerRNA *ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + const bool *select_poly = (const bool *)CustomData_get_layer_named( + &mesh->pdata, CD_PROP_BOOL, ".select_poly"); + const int index = rna_MeshPolygon_index_get(ptr); + return select_poly == NULL ? false : select_poly[index]; +} + +static void rna_MeshPolygon_select_set(PointerRNA *ptr, bool value) +{ + Mesh *mesh = rna_mesh(ptr); + bool *select_poly = (bool *)CustomData_duplicate_referenced_layer_named( + &mesh->pdata, CD_PROP_BOOL, ".select_poly", mesh->totpoly); + if (!select_poly) { + if (!value) { + /* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */ + return; + } + select_poly = (bool *)CustomData_add_layer_named( + &mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totpoly, ".select_poly"); + } + const int index = rna_MeshPolygon_index_get(ptr); + select_poly[index] = value; +} + static int rna_MeshPolygon_material_index_get(PointerRNA *ptr) { const Mesh *mesh = rna_mesh(ptr); @@ -641,9 +735,9 @@ static void rna_MeshLoopTriangle_normal_get(PointerRNA *ptr, float *values) MLoopTri *lt = (MLoopTri *)ptr->data; const MVert *verts = BKE_mesh_verts(me); const MLoop *loops = BKE_mesh_loops(me); - unsigned int v1 = loops[lt->tri[0]].v; - unsigned int v2 = loops[lt->tri[1]].v; - unsigned int v3 = loops[lt->tri[2]].v; + uint v1 = loops[lt->tri[0]].v; + uint v2 = loops[lt->tri[1]].v; + uint v3 = loops[lt->tri[2]].v; normal_tri_v3(values, verts[v1].co, verts[v2].co, verts[v3].co); } @@ -672,9 +766,9 @@ static float rna_MeshLoopTriangle_area_get(PointerRNA *ptr) MLoopTri *lt = (MLoopTri *)ptr->data; const MVert *verts = BKE_mesh_verts(me); const MLoop *loops = BKE_mesh_loops(me); - unsigned int v1 = loops[lt->tri[0]].v; - unsigned int v2 = loops[lt->tri[1]].v; - unsigned int v3 = loops[lt->tri[2]].v; + uint v1 = loops[lt->tri[0]].v; + uint v2 = loops[lt->tri[1]].v; + uint v3 = loops[lt->tri[2]].v; return area_tri_v3(verts[v1].co, verts[v2].co, verts[v3].co); } @@ -1165,6 +1259,31 @@ static int rna_MeshVertexCreaseLayer_data_length(PointerRNA *ptr) /* End vertex creases */ +/* Edge creases */ + +DEFINE_CUSTOMDATA_LAYER_COLLECTION(edge_crease, edata, CD_CREASE) + +static char *rna_EdgeCustomData_data_path(const PointerRNA *ptr, const char *collection, int type); +static char *rna_MeshEdgeCreaseLayer_path(const PointerRNA *ptr) +{ + return rna_EdgeCustomData_data_path(ptr, "edge_creases", CD_CREASE); +} + +static void rna_MeshEdgeCreaseLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + CustomDataLayer *layer = (CustomDataLayer *)ptr->data; + rna_iterator_array_begin(iter, layer->data, sizeof(float), me->totedge, 0, NULL); +} + +static int rna_MeshEdgeCreaseLayer_data_length(PointerRNA *ptr) +{ + Mesh *me = rna_mesh(ptr); + return me->totedge; +} + +/* End edge creases */ + /* Paint mask */ DEFINE_CUSTOMDATA_LAYER_COLLECTION(vertex_paint_mask, vdata, CD_PAINT_MASK) @@ -1285,7 +1404,7 @@ static void rna_MeshPoly_vertices_get(PointerRNA *ptr, int *values) MPoly *mp = (MPoly *)ptr->data; const MLoop *loops = BKE_mesh_loops(me); const MLoop *ml = &loops[mp->loopstart]; - unsigned int i; + uint i; for (i = mp->totloop; i > 0; i--, values++, ml++) { *values = ml->v; } @@ -1298,7 +1417,7 @@ static void rna_MeshPoly_vertices_set(PointerRNA *ptr, const int *values) MLoop *loops = BKE_mesh_loops_for_write(me); MLoop *ml = &loops[mp->loopstart]; - unsigned int i; + uint i; for (i = mp->totloop; i > 0; i--, values++, ml++) { ml->v = *values; } @@ -1341,6 +1460,32 @@ static void rna_MeshEdge_hide_set(PointerRNA *ptr, bool value) hide_edge[index] = value; } +static bool rna_MeshEdge_select_get(PointerRNA *ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + const bool *select_edge = (const bool *)CustomData_get_layer_named( + &mesh->edata, CD_PROP_BOOL, ".select_edge"); + const int index = rna_MeshEdge_index_get(ptr); + return select_edge == NULL ? false : select_edge[index]; +} + +static void rna_MeshEdge_select_set(PointerRNA *ptr, bool value) +{ + Mesh *mesh = rna_mesh(ptr); + bool *select_edge = (bool *)CustomData_duplicate_referenced_layer_named( + &mesh->edata, CD_PROP_BOOL, ".select_edge", mesh->totedge); + if (!select_edge) { + if (!value) { + /* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */ + return; + } + select_edge = (bool *)CustomData_add_layer_named( + &mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totedge, ".select_edge"); + } + const int index = rna_MeshEdge_index_get(ptr); + select_edge[index] = value; +} + static int rna_MeshLoopTriangle_material_index_get(PointerRNA *ptr) { const Mesh *me = rna_mesh(ptr); @@ -1384,8 +1529,9 @@ static char *rna_MeshPolygon_path(const PointerRNA *ptr) static char *rna_MeshLoopTriangle_path(const PointerRNA *ptr) { - return BLI_sprintfN("loop_triangles[%d]", - (int)((MLoopTri *)ptr->data - rna_mesh(ptr)->runtime.looptris.array)); + return BLI_sprintfN( + "loop_triangles[%d]", + (int)((MLoopTri *)ptr->data - BKE_mesh_runtime_looptri_ensure(rna_mesh(ptr)))); } static char *rna_MeshEdge_path(const PointerRNA *ptr) @@ -1424,6 +1570,27 @@ static char *rna_VertCustomData_data_path(const PointerRNA *ptr, const char *col return NULL; } +static char *rna_EdgeCustomData_data_path(const PointerRNA *ptr, const char *collection, int type) +{ + const CustomDataLayer *cdl; + const Mesh *me = rna_mesh(ptr); + const CustomData *edata = rna_mesh_edata(ptr); + int a, b, totedge = (me->edit_mesh) ? 0 : me->totedge; + + for (cdl = edata->layers, a = 0; a < edata->totlayer; cdl++, a++) { + if (cdl->type == type) { + b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type); + if (b >= 0 && b < totedge) { + char name_esc[sizeof(cdl->name) * 2]; + BLI_str_escape(name_esc, cdl->name, sizeof(name_esc)); + return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b); + } + } + } + + return NULL; +} + static char *rna_PolyCustomData_data_path(const PointerRNA *ptr, const char *collection, int type) { const CustomDataLayer *cdl; @@ -1571,6 +1738,19 @@ static int rna_Mesh_vertex_normals_length(PointerRNA *ptr) return mesh->totvert; } +int rna_Mesh_vertex_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + if (index < 0 || index >= mesh->totvert) { + return false; + } + /* Casting away const is okay because this RNA type doesn't allow changing the value. */ + r_ptr->owner_id = (ID *)&mesh->id; + r_ptr->type = &RNA_MeshNormalValue; + r_ptr->data = (float *)BKE_mesh_vertex_normals_ensure(mesh)[index]; + return true; +} + static void rna_Mesh_poly_normals_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { const Mesh *mesh = rna_mesh(ptr); @@ -1584,6 +1764,19 @@ static int rna_Mesh_poly_normals_length(PointerRNA *ptr) return mesh->totpoly; } +int rna_Mesh_poly_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + const Mesh *mesh = rna_mesh(ptr); + if (index < 0 || index >= mesh->totpoly) { + return false; + } + /* Casting away const is okay because this RNA type doesn't allow changing the value. */ + r_ptr->owner_id = (ID *)&mesh->id; + r_ptr->type = &RNA_MeshNormalValue; + r_ptr->data = (float *)BKE_mesh_poly_normals_ensure(mesh)[index]; + return true; +} + static char *rna_MeshUVLoop_path(const PointerRNA *ptr) { return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_MLOOPUV); @@ -1943,6 +2136,7 @@ static void UNUSED_FUNCTION(rna_mesh_unused)(void) (void)rna_Mesh_face_map_active_index_get; (void)rna_Mesh_face_map_active_set; (void)rna_Mesh_vertex_crease_index_range; + (void)rna_Mesh_edge_crease_index_range; /* end unused function block */ } @@ -2052,7 +2246,7 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Normal", "Vertex Normal"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); + RNA_def_property_boolean_funcs(prop, "rna_MeshVertex_select_get", "rna_MeshVertex_select_set"); RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); @@ -2128,7 +2322,7 @@ static void rna_def_medge(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); + RNA_def_property_boolean_funcs(prop, "rna_MeshEdge_select_get", "rna_MeshEdge_select_set"); RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); @@ -2342,7 +2536,7 @@ static void rna_def_mpolygon(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FACE_SEL); + RNA_def_property_boolean_funcs(prop, "rna_MeshPolygon_select_get", "rna_MeshPolygon_select_set"); RNA_def_property_ui_text(prop, "Select", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_select"); @@ -3265,6 +3459,40 @@ static void rna_def_vertex_creases(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); } +static void rna_def_edge_creases(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MeshEdgeCreaseLayer", NULL); + RNA_def_struct_ui_text(srna, "Mesh Edge Crease Layer", "Per-edge crease"); + RNA_def_struct_sdna(srna, "CustomDataLayer"); + RNA_def_struct_path_func(srna, "rna_MeshEdgeCreaseLayer_path"); + + prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "MeshEdgeCrease"); + RNA_def_property_ui_text(prop, "Data", ""); + RNA_def_property_collection_funcs(prop, + "rna_MeshEdgeCreaseLayer_data_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_MeshEdgeCreaseLayer_data_length", + NULL, + NULL, + NULL); + + /* EdgeCrease struct */ + srna = RNA_def_struct(brna, "MeshEdgeCrease", NULL); + RNA_def_struct_sdna(srna, "MFloatProperty"); + RNA_def_struct_ui_text(srna, "Float Property", ""); + + prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "f"); + RNA_def_property_ui_text(prop, "Value", ""); + RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); +} + static void rna_def_paint_mask(BlenderRNA *brna, PropertyRNA *UNUSED(cprop)) { StructRNA *srna; @@ -3462,7 +3690,7 @@ static void rna_def_mesh(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Mesh_vertex_normals_length", - NULL, + "rna_Mesh_vertex_normals_lookup_int", NULL, NULL); @@ -3479,12 +3707,20 @@ static void rna_def_mesh(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Mesh_poly_normals_length", - NULL, + "rna_Mesh_poly_normals_lookup_int", NULL, NULL); prop = RNA_def_property(srna, "loop_triangles", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "runtime.looptris.array", "runtime.looptris.len"); + RNA_def_property_collection_funcs(prop, + "rna_Mesh_loop_triangles_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_Mesh_loop_triangles_length", + "rna_Mesh_loop_triangles_lookup_int", + NULL, + NULL); RNA_def_property_struct_type(prop, "MeshLoopTriangle"); RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE); RNA_def_property_ui_text(prop, "Loop Triangles", "Tessellation of mesh polygons into triangles"); @@ -3739,6 +3975,24 @@ static void rna_def_mesh(BlenderRNA *brna) rna_def_vertex_creases(brna); /* End vertex crease */ + /* Vertex Crease */ + prop = RNA_def_property(srna, "edge_creases", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "MeshEdgeCreaseLayer"); + RNA_def_property_collection_sdna(prop, NULL, "edata.layers", "edata.totlayer"); + RNA_def_property_collection_funcs(prop, + "rna_Mesh_edge_creases_begin", + NULL, + NULL, + NULL, + "rna_Mesh_edge_creases_length", + NULL, + NULL, + NULL); + RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE); + RNA_def_property_ui_text(prop, "Edge Creases", "Sharpness of the edges for subdivision"); + rna_def_edge_creases(brna); + /* End edge crease */ + /* Paint mask */ prop = RNA_def_property(srna, "vertex_paint_masks", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer"); @@ -3770,6 +4024,7 @@ static void rna_def_mesh(BlenderRNA *brna) "Size of the voxel in object space used for volume evaluation. Lower " "values preserve finer details"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "remesh_voxel_adaptivity", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "remesh_voxel_adaptivity"); @@ -3781,11 +4036,13 @@ static void rna_def_mesh(BlenderRNA *brna) "Reduces the final face count by simplifying geometry where detail is not needed, " "generating triangles. A value greater than 0 disables Fix Poles"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "use_remesh_fix_poles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_FIX_POLES); RNA_def_property_ui_text(prop, "Fix Poles", "Produces less poles and a better topology flow"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "use_remesh_preserve_volume", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_REPROJECT_VOLUME); @@ -3794,29 +4051,34 @@ static void rna_def_mesh(BlenderRNA *brna) "Preserve Volume", "Projects the mesh to preserve the volume and details of the original mesh"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "use_remesh_preserve_paint_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_REPROJECT_PAINT_MASK); RNA_def_property_ui_text(prop, "Preserve Paint Mask", "Keep the current mask on the new mesh"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "use_remesh_preserve_sculpt_face_sets", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_REPROJECT_SCULPT_FACE_SETS); RNA_def_property_ui_text( prop, "Preserve Face Sets", "Keep the current Face Sets on the new mesh"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "use_remesh_preserve_vertex_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_REMESH_REPROJECT_VERTEX_COLORS); RNA_def_property_ui_text( prop, "Preserve Vertex Colors", "Keep the current vertex colors on the new mesh"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); prop = RNA_def_property(srna, "remesh_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "remesh_mode"); RNA_def_property_enum_items(prop, rna_enum_mesh_remesh_mode_items); RNA_def_property_ui_text(prop, "Remesh Mode", ""); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); + RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE); /* End remesh */ @@ -3884,6 +4146,17 @@ static void rna_def_mesh(BlenderRNA *brna) prop, "Has Vertex Bevel Weight", "True if the mesh has an vertex bevel weight layer"); RNA_def_property_boolean_funcs(prop, "rna_Mesh_has_vertex_bevel_weight_get", NULL); + prop = RNA_def_property(srna, "has_crease_edge", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has Edge Crease", "True if the mesh has an edge crease layer"); + RNA_def_property_boolean_funcs(prop, "rna_Mesh_has_edge_crease_get", NULL); + + prop = RNA_def_property(srna, "has_crease_vertex", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text( + prop, "Has Vertex Crease", "True if the mesh has an vertex crease layer"); + RNA_def_property_boolean_funcs(prop, "rna_Mesh_has_vertex_crease_get", NULL); + prop = RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "texcomesh"); RNA_def_property_flag(prop, PROP_EDITABLE); @@ -3936,16 +4209,6 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Mesh_update_vertmask"); - /* customdata flags */ - - prop = RNA_def_property(srna, "use_customdata_vertex_crease", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cd_flag", ME_CDFLAG_VERT_CREASE); - RNA_def_property_ui_text(prop, "Store Vertex Crease", ""); - - prop = RNA_def_property(srna, "use_customdata_edge_crease", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cd_flag", ME_CDFLAG_EDGE_CREASE); - RNA_def_property_ui_text(prop, "Store Edge Crease", ""); - /* readonly editmesh info - use for extrude menu */ prop = RNA_def_property(srna, "total_vert_sel", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_funcs(prop, "rna_Mesh_tot_vert_get", NULL, NULL); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 524e3134f9c..de033408170 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -822,6 +822,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_repeat_set", NULL); /* these limits have currently be chosen arbitrarily, but could be extended * (minimum should still be > 0 though) if needed... */ + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.1f, 1000.0f); RNA_def_property_ui_text(prop, "Repeat", "Number of times to repeat the action range"); RNA_def_property_update( @@ -832,6 +833,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, "rna_NlaStrip_scale_set", NULL); /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs * due to numeric errors */ + RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.0001f, 1000.0f); RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action"); RNA_def_property_update( diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index caeee35a80a..cfec020c739 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -13,6 +13,7 @@ #include "BLT_translation.h" +#include "DNA_curves_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" @@ -827,21 +828,21 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), tmp.value = NODE_CUSTOM; tmp.identifier = "CUSTOM"; - tmp.name = "Custom"; - tmp.description = "Custom Node"; + tmp.name = N_("Custom"); + tmp.description = N_("Custom Node"); tmp.icon = ICON_NONE; RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = NODE_CUSTOM_GROUP; tmp.identifier = "CUSTOM GROUP"; - tmp.name = "CustomGroup"; - tmp.description = "Custom Group Node"; + tmp.name = N_("CustomGroup"); + tmp.description = N_("Custom Group Node"); tmp.icon = ICON_NONE; RNA_enum_item_add(&item, &totitem, &tmp); tmp.value = NODE_UNDEFINED; tmp.identifier = "UNDEFINED"; - tmp.name = "UNDEFINED"; + tmp.name = N_("UNDEFINED"); tmp.description = ""; tmp.icon = ICON_NONE; RNA_enum_item_add(&item, &totitem, &tmp); @@ -1892,7 +1893,7 @@ static void rna_Node_unregister(Main *UNUSED(bmain), StructRNA *type) } /* Generic internal registration function. - * Can be used to implement callbacks for registerable RNA node subtypes. + * Can be used to implement callbacks for registerable RNA node sub-types. */ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, @@ -2199,18 +2200,6 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeType_type_with_socket_it generic_attribute_type_supported_with_socket); } -static bool transfer_attribute_type_supported(const EnumPropertyItem *item) -{ - return ELEM( - item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_COLOR, CD_PROP_BOOL, CD_PROP_INT32); -} -static const EnumPropertyItem *rna_NodeGeometryTransferAttribute_type_itemf( - bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ - *r_free = true; - return itemf_function_check(rna_enum_attribute_type_items, transfer_attribute_type_supported); -} - static bool attribute_statistic_type_supported(const EnumPropertyItem *item) { return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3); @@ -2436,21 +2425,13 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, const char *name, const char *identifier) { - - if (ELEM(node->type, NODE_GROUP_INPUT, NODE_FRAME)) { - BKE_report(reports, RPT_ERROR, "Unable to create socket"); + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node"); return NULL; } - /* Adding an input to a group node is not working, - * simpler to add it to its underlying nodetree. */ - if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != NULL) { - return rna_NodeTree_inputs_new((bNodeTree *)node->id, bmain, reports, type, name); - } bNodeTree *ntree = (bNodeTree *)id; - bNodeSocket *sock; - - sock = nodeAddSocket(ntree, node, SOCK_IN, type, identifier, name); + bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_IN, type, identifier, name); if (sock == NULL) { BKE_report(reports, RPT_ERROR, "Unable to create socket"); @@ -2471,20 +2452,13 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, const char *name, const char *identifier) { - if (ELEM(node->type, NODE_GROUP_OUTPUT, NODE_FRAME)) { - BKE_report(reports, RPT_ERROR, "Unable to create socket"); + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node"); return NULL; } - /* Adding an output to a group node is not working, - * simpler to add it to its underlying nodetree. */ - if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != NULL) { - return rna_NodeTree_outputs_new((bNodeTree *)node->id, bmain, reports, type, name); - } bNodeTree *ntree = (bNodeTree *)id; - bNodeSocket *sock; - - sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name); + bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name); if (sock == NULL) { BKE_report(reports, RPT_ERROR, "Unable to create socket"); @@ -2500,6 +2474,11 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, static void rna_Node_socket_remove( ID *id, bNode *node, Main *bmain, ReportList *reports, bNodeSocket *sock) { + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Unable to remove socket from built-in node"); + return; + } + bNodeTree *ntree = (bNodeTree *)id; if (BLI_findindex(&node->inputs, sock) == -1 && BLI_findindex(&node->outputs, sock) == -1) { @@ -2513,8 +2492,13 @@ static void rna_Node_socket_remove( } } -static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain) +static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain, ReportList *reports) { + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Unable to remove sockets from built-in node"); + return; + } + bNodeTree *ntree = (bNodeTree *)id; bNodeSocket *sock, *nextsock; @@ -2527,8 +2511,13 @@ static void rna_Node_inputs_clear(ID *id, bNode *node, Main *bmain) WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } -static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain) +static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain, ReportList *reports) { + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Unable to remove socket from built-in node"); + return; + } + bNodeTree *ntree = (bNodeTree *)id; bNodeSocket *sock, *nextsock; @@ -2541,8 +2530,14 @@ static void rna_Node_outputs_clear(ID *id, bNode *node, Main *bmain) WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } -static void rna_Node_inputs_move(ID *id, bNode *node, Main *bmain, int from_index, int to_index) +static void rna_Node_inputs_move( + ID *id, bNode *node, Main *bmain, ReportList *reports, int from_index, int to_index) { + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Unable to move sockets in built-in node"); + return; + } + bNodeTree *ntree = (bNodeTree *)id; bNodeSocket *sock; @@ -2573,8 +2568,14 @@ static void rna_Node_inputs_move(ID *id, bNode *node, Main *bmain, int from_inde WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } -static void rna_Node_outputs_move(ID *id, bNode *node, Main *bmain, int from_index, int to_index) +static void rna_Node_outputs_move( + ID *id, bNode *node, Main *bmain, ReportList *reports, int from_index, int to_index) { + if (node->type != NODE_CUSTOM) { + BKE_report(reports, RPT_ERROR, "Unable to move sockets in built-in node"); + return; + } + bNodeTree *ntree = (bNodeTree *)id; bNodeSocket *sock; @@ -3585,7 +3586,7 @@ static void rna_difference_matte_t2_set(PointerRNA *ptr, float value) chroma->t2 = value; } -/* Button Set Funcs for Matte Nodes */ +/* Button Set Functions for Matte Nodes */ static void rna_Matte_t1_set(PointerRNA *ptr, float value) { bNode *node = (bNode *)ptr->data; @@ -5253,6 +5254,11 @@ static void def_sh_attribute(StructRNA *srna) "The attribute is associated with the instancer particle system or object, " "falling back to the Object mode if the attribute isn't found, or the object " "is not instanced"}, + {SHD_ATTRIBUTE_VIEW_LAYER, + "VIEW_LAYER", + 0, + "View Layer", + "The attribute is associated with the View Layer, Scene or World that is being rendered"}, {0, NULL, 0, NULL, NULL}, }; PropertyRNA *prop; @@ -5515,6 +5521,7 @@ static void def_sh_tex_image(StructRNA *srna) RNA_def_property_enum_items(prop, prop_image_extension); RNA_def_property_ui_text( prop, "Extension", "How the image is extrapolated past its original bounds"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_IMAGE); RNA_def_property_update(prop, 0, "rna_Node_update"); prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); @@ -5579,6 +5586,7 @@ static void def_geo_image_texture(StructRNA *srna) RNA_def_property_enum_items(prop, prop_image_extension); RNA_def_property_ui_text( prop, "Extension", "How the image is extrapolated past its original bounds"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_IMAGE); RNA_def_property_update(prop, 0, "rna_Node_update"); } @@ -6817,11 +6825,11 @@ static void def_cmp_levels(StructRNA *srna) PropertyRNA *prop; static const EnumPropertyItem channel_items[] = { - {1, "COMBINED_RGB", 0, "Combined", "Combined RGB"}, - {2, "RED", 0, "Red", "Red Channel"}, - {3, "GREEN", 0, "Green", "Green Channel"}, - {4, "BLUE", 0, "Blue", "Blue Channel"}, - {5, "LUMINANCE", 0, "Luminance", "Luminance Channel"}, + {CMP_NODE_LEVLES_LUMINANCE, "COMBINED_RGB", 0, "Combined", "Combined RGB"}, + {CMP_NODE_LEVLES_RED, "RED", 0, "Red", "Red Channel"}, + {CMP_NODE_LEVLES_GREEN, "GREEN", 0, "Green", "Green Channel"}, + {CMP_NODE_LEVLES_BLUE, "BLUE", 0, "Blue", "Blue Channel"}, + {CMP_NODE_LEVLES_LUMINANCE_BT709, "LUMINANCE", 0, "Luminance", "Luminance Channel"}, {0, NULL, 0, NULL, NULL}, }; @@ -7039,11 +7047,11 @@ static void rna_def_cmp_output_file_slots_api(BlenderRNA *brna, func = RNA_def_function(srna, "clear", "rna_Node_inputs_clear"); RNA_def_function_ui_description(func, "Remove all file slots from this node"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); func = RNA_def_function(srna, "move", "rna_Node_inputs_move"); RNA_def_function_ui_description(func, "Move a file slot to another position"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); parm = RNA_def_int( func, "from_index", -1, 0, INT_MAX, "From Index", "Index of the socket to move", 0, 10000); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -7060,6 +7068,7 @@ static void def_cmp_output_file(BlenderRNA *brna, StructRNA *srna) prop = RNA_def_property(srna, "base_path", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "base_path"); RNA_def_property_ui_text(prop, "Base Path", "Base output path for the image"); + RNA_def_property_flag(prop, PROP_PATH_OUTPUT); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "active_input_index", PROP_INT, PROP_NONE); @@ -7326,19 +7335,9 @@ static void def_cmp_convert_color_space(StructRNA *srna) PropertyRNA *prop; RNA_def_struct_sdna_from(srna, "NodeConvertColorSpace", "storage"); - static const EnumPropertyItem color_space_items[] = { - {0, - "NONE", - 0, - "None", - "Do not perform any color transform on load, treat colors as in scene linear space " - "already"}, - {0, NULL, 0, NULL, NULL}, - }; - prop = RNA_def_property(srna, "from_color_space", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_items(prop, rna_enum_color_space_convert_default_items); RNA_def_property_enum_funcs(prop, "rna_NodeConvertColorSpace_from_color_space_get", "rna_NodeConvertColorSpace_from_color_space_set", @@ -7348,7 +7347,7 @@ static void def_cmp_convert_color_space(StructRNA *srna) prop = RNA_def_property(srna, "to_color_space", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); - RNA_def_property_enum_items(prop, color_space_items); + RNA_def_property_enum_items(prop, rna_enum_color_space_convert_default_items); RNA_def_property_enum_funcs(prop, "rna_NodeConvertColorSpace_to_color_space_get", "rna_NodeConvertColorSpace_to_color_space_set", @@ -9445,10 +9444,26 @@ static void def_geo_curve_sample(StructRNA *srna) RNA_def_struct_sdna_from(srna, "NodeGeometryCurveSample", "storage"); - PropertyRNA *prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + PropertyRNA *prop; + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, mode_items); RNA_def_property_ui_text(prop, "Mode", "Method for sampling input"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); + + prop = RNA_def_property(srna, "use_all_curves", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, + "All Curves", + "Sample lengths based on the total lengh of all curves, rather than " + "using a length inside each selected curve"); + 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_items(prop, rna_enum_attribute_type_items); + RNA_def_property_enum_funcs( + prop, NULL, NULL, "rna_GeometryNodeAttributeType_type_with_socket_itemf"); + RNA_def_property_enum_default(prop, CD_PROP_FLOAT); + RNA_def_property_ui_text(prop, "Data Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } static void def_geo_triangulate(StructRNA *srna) @@ -9614,6 +9629,31 @@ static void def_geo_extrude_mesh(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_geo_distribute_points_in_volume(StructRNA *srna) +{ + PropertyRNA *prop; + + static const EnumPropertyItem mode_items[] = { + {GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM, + "DENSITY_RANDOM", + 0, + "Random", + "Distribute points randomly inside of the volume"}, + {GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_GRID, + "DENSITY_GRID", + 0, + "Grid", + "Distribute the points in a grid pattern inside of the volume"}, + {0, NULL, 0, NULL, NULL}, + }; + + RNA_def_struct_sdna_from(srna, "NodeGeometryDistributePointsInVolume", "storage"); + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_ui_text(prop, "Distribution Method", "Method to use for scattering points"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); +} + static void def_geo_distribute_points_on_faces(StructRNA *srna) { PropertyRNA *prop; @@ -9684,6 +9724,17 @@ static void def_geo_curve_set_handle_positions(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } +static void def_geo_set_curve_normal(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, rna_enum_curve_normal_modes); + RNA_def_property_ui_text(prop, "Mode", "Mode for curve normal evaluation"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + static void def_geo_curve_handle_type_selection(StructRNA *srna) { PropertyRNA *prop; @@ -10398,53 +10449,68 @@ static void def_geo_curve_trim(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } -static void def_geo_transfer_attribute(StructRNA *srna) +static void def_geo_sample_index(StructRNA *srna) { - static EnumPropertyItem mapping_items[] = { - {GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED, - "NEAREST_FACE_INTERPOLATED", - 0, - "Nearest Face Interpolated", - "Transfer the attribute from the nearest face on a surface (loose points and edges are " - "ignored)"}, - {GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST, - "NEAREST", - 0, - "Nearest", - "Transfer the element from the nearest element (using face and edge centers for the " - "distance computation)"}, - {GEO_NODE_ATTRIBUTE_TRANSFER_INDEX, - "INDEX", - 0, - "Index", - "Transfer the data from the element with the corresponding index in the target geometry"}, - {0, NULL, 0, NULL, NULL}, - }; - PropertyRNA *prop; - RNA_def_struct_sdna_from(srna, "NodeGeometryTransferAttribute", "storage"); - - prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mapping_items); - RNA_def_property_ui_text(prop, "Mapping", "Mapping between geometries"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); + RNA_def_struct_sdna_from(srna, "NodeGeometrySampleIndex", "storage"); prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_attribute_type_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_NodeGeometryTransferAttribute_type_itemf"); + RNA_def_property_enum_funcs( + prop, NULL, NULL, "rna_GeometryNodeAttributeType_type_with_socket_itemf"); RNA_def_property_enum_default(prop, CD_PROP_FLOAT); - RNA_def_property_ui_text(prop, "Data Type", "The type for the source and result data"); + RNA_def_property_ui_text(prop, "Data Type", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_attribute_domain_items); RNA_def_property_enum_default(prop, ATTR_DOMAIN_POINT); - RNA_def_property_ui_text(prop, "Domain", "The domain to use on the target geometry"); + RNA_def_property_ui_text(prop, "Domain", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "clamp", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, + "Clamp", + "Clamp the indices to the size of the attribute domain instead of " + "outputting a default value for invalid indices"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_geo_sample_nearest_surface(StructRNA *srna) +{ + PropertyRNA *prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, rna_enum_attribute_type_items); + RNA_def_property_enum_funcs( + prop, NULL, NULL, "rna_GeometryNodeAttributeType_type_with_socket_itemf"); + RNA_def_property_enum_default(prop, CD_PROP_FLOAT); + RNA_def_property_ui_text(prop, "Data Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); +} + +static void def_geo_sample_nearest(StructRNA *srna) +{ + PropertyRNA *prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom2"); + RNA_def_property_enum_items(prop, rna_enum_attribute_domain_only_mesh_items); + RNA_def_property_enum_default(prop, ATTR_DOMAIN_POINT); + RNA_def_property_ui_text(prop, "Domain", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + +static void def_geo_sample_uv_surface(StructRNA *srna) +{ + PropertyRNA *prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, rna_enum_attribute_type_items); + RNA_def_property_enum_funcs( + prop, NULL, NULL, "rna_GeometryNodeAttributeType_type_with_socket_itemf"); + RNA_def_property_enum_default(prop, CD_PROP_FLOAT); + RNA_def_property_ui_text(prop, "Data Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); +} + static void def_geo_input_material(StructRNA *srna) { PropertyRNA *prop; @@ -10786,6 +10852,12 @@ static void def_geo_viewer(StructRNA *srna) RNA_def_property_enum_default(prop, CD_PROP_FLOAT); RNA_def_property_ui_text(prop, "Data Type", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_GeometryNode_socket_update"); + + prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_attribute_domain_with_auto_items); + RNA_def_property_enum_default(prop, ATTR_DOMAIN_POINT); + RNA_def_property_ui_text(prop, "Domain", "Domain to evaluate the field on"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_geo_realize_instances(StructRNA *srna) @@ -12054,11 +12126,11 @@ static void rna_def_node_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int i func = RNA_def_function(srna, "clear", clearfunc); RNA_def_function_ui_description(func, "Remove all sockets from this node"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); func = RNA_def_function(srna, "move", movefunc); RNA_def_function_ui_description(func, "Move a socket to another position"); - RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS); parm = RNA_def_int( func, "from_index", -1, 0, INT_MAX, "From Index", "Index of the socket to move", 0, 10000); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -12176,7 +12248,7 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Custom Color", "Use custom color for the node"); RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Color", "Custom color of the node body"); @@ -12646,6 +12718,7 @@ static void rna_def_nodetree(BlenderRNA *brna) RNA_def_property_int_funcs( prop, "rna_NodeTree_active_input_get", "rna_NodeTree_active_input_set", NULL); RNA_def_property_ui_text(prop, "Active Input", "Index of the active input"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_NODE, NULL); prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE); @@ -12659,6 +12732,7 @@ static void rna_def_nodetree(BlenderRNA *brna) RNA_def_property_int_funcs( prop, "rna_NodeTree_active_output_get", "rna_NodeTree_active_output_set", NULL); RNA_def_property_ui_text(prop, "Active Output", "Index of the active output"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_NODE, NULL); /* exposed as a function for runtime interface type properties */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index cfc3a832166..1d6b3d5d69e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -356,7 +356,8 @@ static void rna_Object_internal_update_draw(Main *UNUSED(bmain), static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) { /* don't use compat so we get predictable rotation */ - BKE_object_apply_mat4((Object *)ptr->owner_id, ((Object *)ptr->owner_id)->obmat, false, true); + BKE_object_apply_mat4( + (Object *)ptr->owner_id, ((Object *)ptr->owner_id)->object_to_world, false, true); rna_Object_internal_update(bmain, scene, ptr); } @@ -381,7 +382,7 @@ static void rna_MaterialIndex_update(Main *UNUSED(bmain), Scene *UNUSED(scene), { Object *ob = (Object *)ptr->owner_id; if (ob && ob->type == OB_GPENCIL) { - /* notifying material property in topbar */ + /* Notifying material property in top-bar. */ WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); } } @@ -407,7 +408,7 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) Object *ob = (Object *)ptr->owner_id; float local_mat[4][4]; - /* Localspace matrix is truly relative to the parent, + /* Local-space matrix is truly relative to the parent, * but parameters stored in object are relative to parentinv matrix. * Undo the parent inverse part before applying it as local matrix. */ if (ob->parent) { @@ -497,12 +498,6 @@ static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), Poin void rna_Object_data_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Object *object = (Object *)ptr->data; - - if (object->mode == OB_MODE_SCULPT) { - BKE_sculpt_ensure_orig_mesh_data(object); - } - rna_Object_internal_update_data_dependency(bmain, scene, ptr); } @@ -2928,6 +2923,11 @@ static void rna_def_object_lineart(BlenderRNA *brna) 0, "No Intersection", "Include this object but do not generate intersection lines"}, + {OBJECT_LRT_FORCE_INTERSECTION, + "FORCE_INTERSECTION", + 0, + "Force Intersection", + "Generate intersection lines even with objects that disabled intersection"}, {0, NULL, 0, NULL, NULL}, }; @@ -3391,7 +3391,7 @@ static void rna_def_object(BlenderRNA *brna) /* matrix */ prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_float_sdna(prop, NULL, "obmat"); + RNA_def_property_float_sdna(prop, NULL, "object_to_world"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 6967f78026a..366a3597ce6 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -77,13 +77,36 @@ static const EnumPropertyItem space_items[] = { # include "MEM_guardedalloc.h" -static void rna_Object_select_set( - Object *ob, bContext *C, ReportList *reports, bool select, ViewLayer *view_layer) +static Base *find_view_layer_base_with_synced_ensure( + Object *ob, bContext *C, PointerRNA *view_layer_ptr, Scene **r_scene, ViewLayer **r_view_layer) { - if (view_layer == NULL) { + Scene *scene; + ViewLayer *view_layer; + if (view_layer_ptr->data) { + scene = (Scene *)view_layer_ptr->owner_id; + view_layer = view_layer_ptr->data; + } + else { + scene = CTX_data_scene(C); view_layer = CTX_data_view_layer(C); } - Base *base = BKE_view_layer_base_find(view_layer, ob); + if (r_scene != NULL) { + *r_scene = scene; + } + if (r_view_layer != NULL) { + *r_view_layer = view_layer; + } + + BKE_view_layer_synced_ensure(scene, view_layer); + return BKE_view_layer_base_find(view_layer, ob); +} + +static void rna_Object_select_set( + Object *ob, bContext *C, ReportList *reports, bool select, PointerRNA *view_layer_ptr) +{ + Scene *scene; + ViewLayer *view_layer; + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, &scene, &view_layer); if (!base) { if (select) { @@ -98,19 +121,14 @@ static void rna_Object_select_set( ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); - Scene *scene = CTX_data_scene(C); DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene); ED_outliner_select_sync_from_object_tag(C); } -static bool rna_Object_select_get(Object *ob, bContext *C, ViewLayer *view_layer) +static bool rna_Object_select_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr) { - if (view_layer == NULL) { - view_layer = CTX_data_view_layer(C); - } - Base *base = BKE_view_layer_base_find(view_layer, ob); - + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, NULL, NULL); if (!base) { return false; } @@ -119,13 +137,11 @@ static bool rna_Object_select_get(Object *ob, bContext *C, ViewLayer *view_layer } static void rna_Object_hide_set( - Object *ob, bContext *C, ReportList *reports, bool hide, ViewLayer *view_layer) + Object *ob, bContext *C, ReportList *reports, bool hide, PointerRNA *view_layer_ptr) { - if (view_layer == NULL) { - view_layer = CTX_data_view_layer(C); - } - Base *base = BKE_view_layer_base_find(view_layer, ob); - + Scene *scene; + ViewLayer *view_layer; + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, &scene, &view_layer); if (!base) { if (hide) { BKE_reportf(reports, @@ -144,19 +160,14 @@ static void rna_Object_hide_set( base->flag &= ~BASE_HIDDEN; } - Scene *scene = CTX_data_scene(C); - BKE_layer_collection_sync(scene, view_layer); + BKE_view_layer_need_resync_tag(view_layer); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } -static bool rna_Object_hide_get(Object *ob, bContext *C, ViewLayer *view_layer) +static bool rna_Object_hide_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr) { - if (view_layer == NULL) { - view_layer = CTX_data_view_layer(C); - } - Base *base = BKE_view_layer_base_find(view_layer, ob); - + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, NULL, NULL); if (!base) { return false; } @@ -164,15 +175,15 @@ static bool rna_Object_hide_get(Object *ob, bContext *C, ViewLayer *view_layer) return ((base->flag & BASE_HIDDEN) != 0); } -static bool rna_Object_visible_get(Object *ob, bContext *C, ViewLayer *view_layer, View3D *v3d) +static bool rna_Object_visible_get(Object *ob, + bContext *C, + PointerRNA *view_layer_ptr, + View3D *v3d) { - if (view_layer == NULL) { - view_layer = CTX_data_view_layer(C); - } + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, NULL, NULL); if (v3d == NULL) { v3d = CTX_wm_view3d(C); } - Base *base = BKE_view_layer_base_find(view_layer, ob); if (!base) { return false; @@ -181,31 +192,19 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ViewLayer *view_laye return BASE_VISIBLE(v3d, base); } -static bool rna_Object_holdout_get(Object *ob, bContext *C, ViewLayer *view_layer) +static bool rna_Object_holdout_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr) { - if (view_layer == NULL) { - view_layer = CTX_data_view_layer(C); - } - Base *base = BKE_view_layer_base_find(view_layer, ob); - + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, NULL, NULL); if (!base) { return false; } - return ((base->flag & BASE_HOLDOUT) != 0); + return ((base->flag & BASE_HOLDOUT) != 0) || ((ob->visibility_flag & OB_HOLDOUT) != 0); } -static bool rna_Object_indirect_only_get(Object *ob, bContext *C, ViewLayer *view_layer) +static bool rna_Object_indirect_only_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr) { - if (view_layer == NULL) { - view_layer = CTX_data_view_layer(C); - } - Base *base = BKE_view_layer_base_find(view_layer, ob); - - if (!base) { - return false; - } - + Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, NULL, NULL); return ((base->flag & BASE_INDIRECT_ONLY) != 0); } @@ -227,6 +226,7 @@ static Base *rna_Object_local_view_property_helper(bScreen *screen, view_layer = WM_window_get_active_view_layer(win); } + BKE_view_layer_synced_ensure(win ? WM_window_get_active_scene(win) : NULL, view_layer); Base *base = BKE_view_layer_base_find(view_layer, ob); if (base == NULL) { BKE_reportf( @@ -831,6 +831,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_boolean(func, "result", 0, "", "Object selected"); RNA_def_function_return(func, parm); @@ -842,6 +843,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); func = RNA_def_function(srna, "hide_get", "rna_Object_hide_get"); RNA_def_function_ui_description( @@ -850,6 +852,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_boolean(func, "result", 0, "", "Object hidden"); RNA_def_function_return(func, parm); @@ -861,6 +864,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get"); RNA_def_function_ui_description(func, @@ -869,6 +873,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_pointer( func, "viewport", "SpaceView3D", "", "Use this instead of the active 3D viewport"); parm = RNA_def_boolean(func, "result", 0, "", "Object visible"); @@ -879,6 +884,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_boolean(func, "result", 0, "", "Object holdout"); RNA_def_function_return(func, parm); @@ -889,6 +895,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer( func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer"); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_boolean(func, "result", 0, "", "Object indirect only"); RNA_def_function_return(func, parm); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 40e7f6e65c2..a56e7d28ef7 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -471,7 +471,7 @@ static void rna_ParticleSystem_co_hair( if (step >= 0 && step <= max_k) { copy_v3_v3(n_co, (cache + step)->co); mul_m4_v3(particlesystem->imat, n_co); - mul_m4_v3(object->obmat, n_co); + mul_m4_v3(object->object_to_world, n_co); } } @@ -1188,7 +1188,7 @@ static void rna_ParticleTarget_name_get(PointerRNA *ptr, char *str) if (psys) { if (pt->ob) { - sprintf(str, "%s: %s", pt->ob->id.name + 2, psys->name); + BLI_sprintf(str, "%s: %s", pt->ob->id.name + 2, psys->name); } else { strcpy(str, psys->name); @@ -1315,7 +1315,7 @@ static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str) ParticleDupliWeight *dw = ptr->data; if (dw->ob) { - sprintf(str, "%s: %i", dw->ob->id.name + 2, dw->count); + BLI_sprintf(str, "%s: %i", dw->ob->id.name + 2, dw->count); } else { strcpy(str, "No object"); @@ -3431,7 +3431,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Loop Count", "Number of times the keys are looped"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - /* modified dm support */ + /* Evaluated mesh support. */ prop = RNA_def_property(srna, "use_modifier_stack", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_modifier_stack", 0); RNA_def_property_ui_text( diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc index 96f46f5dbe6..e3898bbd682 100644 --- a/source/blender/makesrna/intern/rna_path.cc +++ b/source/blender/makesrna/intern/rna_path.cc @@ -583,7 +583,7 @@ bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, ListBase *r_el } char *RNA_path_append(const char *path, - const PointerRNA *UNUSED(ptr), + const PointerRNA * /*ptr*/, PropertyRNA *prop, int intkey, const char *strkey) @@ -708,7 +708,7 @@ const char *RNA_path_array_index_token_find(const char *rna_path, const Property if (UNLIKELY(rna_path[0] == '\0')) { return nullptr; } - size_t rna_path_len = (size_t)strlen(rna_path) - 1; + size_t rna_path_len = size_t(strlen(rna_path)) - 1; if (rna_path[rna_path_len] != ']') { return nullptr; } @@ -861,7 +861,7 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *array = IDP_IDPArray(iter); if (needle >= array && needle < (iter->len + array)) { /* found! */ link.name = iter->name; - link.index = (int)(needle - array); + link.index = int(needle - array); path = rna_idp_path_create(&link); break; } @@ -1333,7 +1333,7 @@ char *RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index) return ret; } -char *RNA_path_property_py(const PointerRNA *UNUSED(ptr), PropertyRNA *prop, int index) +char *RNA_path_property_py(const PointerRNA * /*ptr*/, PropertyRNA *prop, int index) { const bool is_rna = (prop->magic == RNA_MAGIC); const char *propname = RNA_property_identifier(prop); diff --git a/source/blender/makesrna/intern/rna_pointcloud.c b/source/blender/makesrna/intern/rna_pointcloud.c index df09bff1aea..904d011fa04 100644 --- a/source/blender/makesrna/intern/rna_pointcloud.c +++ b/source/blender/makesrna/intern/rna_pointcloud.c @@ -33,12 +33,22 @@ static PointCloud *rna_pointcloud(const PointerRNA *ptr) return (PointCloud *)ptr->owner_id; } +static float (*get_pointcloud_positions(PointCloud *pointcloud))[3] +{ + return (float(*)[3])CustomData_get_layer_named(&pointcloud->pdata, CD_PROP_FLOAT3, "position"); +} + +static const float (*get_pointcloud_positions_const(const PointCloud *pointcloud))[3] +{ + return (const float(*)[3])CustomData_get_layer_named( + &pointcloud->pdata, CD_PROP_FLOAT3, "position"); +} + static int rna_Point_index_get_const(const PointerRNA *ptr) { const PointCloud *pointcloud = rna_pointcloud(ptr); const float(*co)[3] = ptr->data; - const float(*positions)[3] = (const float(*)[3])CustomData_get_layer_named( - &pointcloud->pdata, CD_PROP_FLOAT3, "position"); + const float(*positions)[3] = get_pointcloud_positions_const(pointcloud); return (int)(co - positions); } @@ -55,11 +65,25 @@ static int rna_PointCloud_points_length(PointerRNA *ptr) static void rna_PointCloud_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - const PointCloud *pointcloud = rna_pointcloud(ptr); - const float(*positions)[3] = (const float(*)[3])CustomData_get_layer_named( - &pointcloud->pdata, CD_PROP_FLOAT3, "position"); - rna_iterator_array_begin( - iter, (void *)positions, sizeof(float[3]), pointcloud->totpoint, false, NULL); + PointCloud *pointcloud = rna_pointcloud(ptr); + rna_iterator_array_begin(iter, + get_pointcloud_positions(pointcloud), + sizeof(float[3]), + pointcloud->totpoint, + false, + NULL); +} + +int rna_PointCloud_points_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + PointCloud *pointcloud = rna_pointcloud(ptr); + if (index < 0 || index >= pointcloud->totpoint) { + return false; + } + r_ptr->owner_id = &pointcloud->id; + r_ptr->type = &RNA_Point; + r_ptr->data = &get_pointcloud_positions(pointcloud)[index]; + return true; } static void rna_Point_location_get(PointerRNA *ptr, float value[3]) @@ -157,7 +181,7 @@ static void rna_def_pointcloud(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_PointCloud_points_length", - NULL, + "rna_PointCloud_points_lookup_int", NULL, NULL); RNA_def_property_ui_text(prop, "Points", ""); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 57f75fe892c..54ccba24247 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -160,6 +160,7 @@ const EnumPropertyItem rna_enum_property_flag_items[] = { 0, "Update on every keystroke in textedit 'mode'", ""}, + {PROP_PATH_OUTPUT, "OUTPUT_PATH", 0, "Output Path", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -464,7 +465,7 @@ static void rna_Struct_property_tags_begin(CollectionPropertyIterator *iter, Poi /* here ptr->data should always be the same as iter->parent.type */ StructRNA *srna = (StructRNA *)ptr->data; const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna); - unsigned int tag_count = tag_defines ? RNA_enum_items_count(tag_defines) : 0; + uint tag_count = tag_defines ? RNA_enum_items_count(tag_defines) : 0; rna_iterator_array_begin( iter, (void *)tag_defines, sizeof(EnumPropertyItem), tag_count, 0, NULL); @@ -729,6 +730,12 @@ static bool rna_Property_is_library_editable_flag_get(PointerRNA *ptr) return (prop->flag & PROP_LIB_EXCEPTION) != 0; } +static bool rna_Property_is_path_output_flag_get(PointerRNA *ptr) +{ + PropertyRNA *prop = (PropertyRNA *)ptr->data; + return (prop->flag & PROP_PATH_OUTPUT) != 0; +} + static int rna_Property_tags_get(PointerRNA *ptr) { return RNA_property_tags(ptr->data); @@ -3023,6 +3030,12 @@ static void rna_def_property(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Library Editable", "Property is editable from linked instances (changes not saved)"); + prop = RNA_def_property(srna, "is_path_output", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Property_is_path_output_flag_get", NULL); + RNA_def_property_ui_text( + prop, "Path Output", "Property is a filename, filepath or directory output"); + prop = RNA_def_property(srna, "tags", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, dummy_prop_tags); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index e2b3276c45f..fde8fcf651c 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -476,6 +476,20 @@ const EnumPropertyItem rna_enum_bake_save_mode_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_bake_view_from_items[] = { + {R_BAKE_VIEW_FROM_ABOVE_SURFACE, + "ABOVE_SURFACE", + 0, + "Above Surface", + "Cast rays from above the surface"}, + {R_BAKE_VIEW_FROM_ACTIVE_CAMERA, + "ACTIVE_CAMERA", + 0, + "Active Camera", + "Use the active camera's position to cast rays"}, + {0, NULL, 0, NULL, NULL}, +}; + #define R_IMF_VIEWS_ENUM_IND \ {R_IMF_VIEWS_INDIVIDUAL, \ "INDIVIDUAL", \ @@ -706,7 +720,9 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UN static void rna_Gpencil_extend_selection(bContext *C, PointerRNA *UNUSED(ptr)) { /* Extend selection to all points in all selected strokes. */ + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); if ((ob) && (ob->type == OB_GPENCIL)) { bGPdata *gpd = (bGPdata *)ob->data; @@ -1236,8 +1252,10 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) (is_render ? IMA_CHAN_FLAG_BW : 0); /* ensure depth and color settings match */ - if (((imf->planes == R_IMF_PLANES_BW) && !(chan_flag & IMA_CHAN_FLAG_BW)) || - ((imf->planes == R_IMF_PLANES_RGBA) && !(chan_flag & IMA_CHAN_FLAG_ALPHA))) { + if ((imf->planes == R_IMF_PLANES_BW) && !(chan_flag & IMA_CHAN_FLAG_BW)) { + imf->planes = R_IMF_PLANES_RGBA; + } + if ((imf->planes == R_IMF_PLANES_RGBA) && !(chan_flag & IMA_CHAN_FLAG_RGBA)) { imf->planes = R_IMF_PLANES_RGB; } @@ -1317,12 +1335,12 @@ static const EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext RenderData *rd = &scene->r; if (BKE_ffmpeg_alpha_channel_is_supported(rd)) { - chan_flag |= IMA_CHAN_FLAG_ALPHA; + chan_flag |= IMA_CHAN_FLAG_RGBA; } } # endif - if (chan_flag == (IMA_CHAN_FLAG_BW | IMA_CHAN_FLAG_RGB | IMA_CHAN_FLAG_ALPHA)) { + if (chan_flag == (IMA_CHAN_FLAG_BW | IMA_CHAN_FLAG_RGB | IMA_CHAN_FLAG_RGBA)) { return rna_enum_image_color_mode_items; } else { @@ -1335,7 +1353,7 @@ static const EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext if (chan_flag & IMA_CHAN_FLAG_RGB) { RNA_enum_item_add(&item, &totitem, &IMAGE_COLOR_MODE_RGB); } - if (chan_flag & IMA_CHAN_FLAG_ALPHA) { + if (chan_flag & IMA_CHAN_FLAG_RGBA) { RNA_enum_item_add(&item, &totitem, &IMAGE_COLOR_MODE_RGBA); } @@ -1862,13 +1880,17 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const bool *valu /* Update select mode in all the workspaces in mesh edit mode. */ wmWindowManager *wm = G_MAIN->wm.first; LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { + const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); - - if (view_layer && view_layer->basact) { - Mesh *me = BKE_mesh_from_object(view_layer->basact->object); - if (me && me->edit_mesh && me->edit_mesh->selectmode != flag) { - me->edit_mesh->selectmode = flag; - EDBM_selectmode_set(me->edit_mesh); + if (view_layer) { + BKE_view_layer_synced_ensure(scene, view_layer); + Object *object = BKE_view_layer_active_object_get(view_layer); + if (object) { + Mesh *me = BKE_mesh_from_object(object); + if (me && me->edit_mesh && me->edit_mesh->selectmode != flag) { + me->edit_mesh->selectmode = flag; + EDBM_selectmode_set(me->edit_mesh); + } } } } @@ -1877,11 +1899,14 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const bool *valu static void rna_Scene_editmesh_select_mode_update(bContext *C, PointerRNA *UNUSED(ptr)) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Mesh *me = NULL; - if (view_layer->basact) { - me = BKE_mesh_from_object(view_layer->basact->object); + BKE_view_layer_synced_ensure(scene, view_layer); + Object *object = BKE_view_layer_active_object_get(view_layer); + if (object) { + me = BKE_mesh_from_object(object); if (me && me->edit_mesh == NULL) { me = NULL; } @@ -2220,11 +2245,14 @@ static char *rna_SequencerToolSettings_path(const PointerRNA *UNUSED(ptr)) /* generic function to recalc geometry */ static void rna_EditMesh_update(bContext *C, PointerRNA *UNUSED(ptr)) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Mesh *me = NULL; - if (view_layer->basact) { - me = BKE_mesh_from_object(view_layer->basact->object); + BKE_view_layer_synced_ensure(scene, view_layer); + Object *object = BKE_view_layer_active_object_get(view_layer); + if (object) { + me = BKE_mesh_from_object(object); if (me && me->edit_mesh == NULL) { me = NULL; } @@ -2248,7 +2276,9 @@ static char *rna_MeshStatVis_path(const PointerRNA *UNUSED(ptr)) * given its own notifier. */ static void rna_Scene_update_active_object_data(bContext *C, PointerRNA *UNUSED(ptr)) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); if (ob) { @@ -2565,8 +2595,8 @@ static const EnumPropertyItem *rna_TransformOrientation_impl_itemf(Scene *scene, if (include_default) { tmp.identifier = "DEFAULT"; - tmp.name = "Default"; - tmp.description = "Use the scene orientation"; + tmp.name = N_("Default"); + tmp.description = N_("Use the scene orientation"); tmp.value = V3D_ORIENT_DEFAULT; tmp.icon = ICON_OBJECT_ORIGIN; RNA_enum_item_add(&item, &totitem, &tmp); @@ -4587,6 +4617,7 @@ void rna_def_view_layer_common(BlenderRNA *brna, StructRNA *srna, const bool sce prop = RNA_def_property(srna, "use_pass_object_index", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXOB); RNA_def_property_ui_text(prop, "Object Index", "Deliver object index pass"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SCENE); if (scene) { RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update"); } @@ -5397,6 +5428,11 @@ static void rna_def_bake_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Save Mode", "Where to save baked image textures"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + prop = RNA_def_property(srna, "view_from", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_bake_view_from_items); + RNA_def_property_ui_text(prop, "View From", "Source of reflection ray directions"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + /* flags */ prop = RNA_def_property(srna, "use_selected_to_active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", R_BAKE_TO_ACTIVE); @@ -5909,7 +5945,8 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {AV_CODEC_ID_PNG, "PNG", 0, "PNG", ""}, {AV_CODEC_ID_QTRLE, "QTRLE", 0, "QT rle / QT Animation", ""}, {AV_CODEC_ID_THEORA, "THEORA", 0, "Theora", ""}, - {AV_CODEC_ID_VP9, "WEBM", 0, "WEBM / VP9", ""}, + {AV_CODEC_ID_VP9, "WEBM", 0, "WebM / VP9", ""}, + {AV_CODEC_ID_AV1, "AV1", 0, "AV1", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -6539,6 +6576,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) "Output Path", "Directory/name to save animations, # characters defines the position " "and length of frame numbers"); + RNA_def_property_flag(prop, PROP_PATH_OUTPUT); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* Render result EXR cache. */ @@ -7824,6 +7862,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_ui_text(prop, "World", "World used for rendering the scene"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WORLD); RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_world_update"); prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 42523508c14..c5e7c6a6e91 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -9,6 +9,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -33,6 +34,8 @@ #include "bmesh.h" +extern const EnumPropertyItem RNA_automasking_flags[]; + const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[] = { {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs"}, {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth hairs"}, @@ -165,6 +168,7 @@ static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr)) Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); PTCacheEdit *edit = PE_get_current(depsgraph, scene, ob); @@ -185,6 +189,7 @@ static void rna_ParticleEdit_update(bContext *C, PointerRNA *UNUSED(ptr)) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); if (ob) { @@ -215,7 +220,9 @@ static const EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); # if 0 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); @@ -374,6 +381,7 @@ static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr)) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); if (ob) { @@ -389,12 +397,13 @@ static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr)) static void rna_Sculpt_ShowMask_update(bContext *C, PointerRNA *UNUSED(ptr)) { + Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *object = BKE_view_layer_active_object_get(view_layer); if (object == NULL || object->sculpt == NULL) { return; } - Scene *scene = CTX_data_scene(C); Sculpt *sd = scene->toolsettings->sculpt; object->sculpt->show_mask = ((sd->flags & SCULPT_HIDE_MASK) == 0); if (object->sculpt->pbvh != NULL) { @@ -488,6 +497,7 @@ static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr)) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); if (ob && ob->type == OB_MESH) { @@ -505,6 +515,7 @@ static void rna_ImaPaint_stencil_update(bContext *C, PointerRNA *UNUSED(ptr)) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); if (ob && ob->type == OB_MESH) { @@ -524,25 +535,11 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr)) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); - bScreen *screen; Image *ima = scene->toolsettings->imapaint.canvas; - for (screen = bmain->screens.first; screen; screen = screen->id.next) { - ScrArea *area; - for (area = screen->areabase.first; area; area = area->next) { - SpaceLink *slink; - for (slink = area->spacedata.first; slink; slink = slink->next) { - if (slink->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)slink; - - if (!sima->pin) { - ED_space_image_set(bmain, sima, ima, true); - } - } - } - } - } + ED_space_image_sync(bmain, ima, false); if (ob && ob->type == OB_MESH) { ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); @@ -589,6 +586,31 @@ static char *rna_GPencilSculptGuide_path(const PointerRNA *UNUSED(ptr)) return BLI_strdup("tool_settings.gpencil_sculpt.guide"); } +static void rna_Sculpt_automasking_invert_cavity_set(PointerRNA *ptr, bool val) +{ + Sculpt *sd = (Sculpt *)ptr->data; + + if (val) { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + sd->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_INVERTED; + } + else { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + } +} + +static void rna_Sculpt_automasking_cavity_set(PointerRNA *ptr, bool val) +{ + Sculpt *sd = (Sculpt *)ptr->data; + + if (val) { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + sd->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_NORMAL; + } + else { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + } +} #else static void rna_def_paint_curve(BlenderRNA *brna) @@ -874,32 +896,98 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); - prop = RNA_def_property(srna, "use_automasking_topology", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_TOPOLOGY); - RNA_def_property_ui_text(prop, - "Topology Auto-Masking", - "Affect only vertices connected to the active vertex under the brush"); + const EnumPropertyItem *entry = RNA_automasking_flags; + do { + prop = RNA_def_property(srna, entry->identifier, PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", entry->value); + RNA_def_property_ui_text(prop, entry->name, entry->description); + + if (entry->value == BRUSH_AUTOMASKING_CAVITY_NORMAL) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Sculpt_automasking_cavity_set"); + } + else if (entry->value == BRUSH_AUTOMASKING_CAVITY_INVERTED) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Sculpt_automasking_invert_cavity_set"); + } + + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + } while ((++entry)->identifier); + + prop = RNA_def_property(srna, "automasking_cavity_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "automasking_cavity_factor"); + RNA_def_property_ui_text(prop, "Cavity Factor", "The contrast of the cavity mask"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.0f, 5.0f); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Auto-Masking", - "Affect only vertices that share Face Sets with the active vertex"); + prop = RNA_def_property(srna, "automasking_cavity_blur_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "automasking_cavity_blur_steps"); + RNA_def_property_ui_text(prop, "Blur Steps", "The number of times the cavity mask is blurred"); + RNA_def_property_int_default(prop, 0); + RNA_def_property_range(prop, 0, 25); + RNA_def_property_ui_range(prop, 0, 10, 1, 1); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "automasking_cavity_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "automasking_cavity_curve"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Cavity Curve", "Curve used for the sensitivity"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_boundary_edges", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_EDGES); + prop = RNA_def_property(srna, "automasking_cavity_curve_op", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "automasking_cavity_curve_op"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Cavity Curve", "Curve used for the sensitivity"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_start_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BRUSH_NORMAL); RNA_def_property_ui_text( - prop, "Mesh Boundary Auto-Masking", "Do not affect non manifold boundary edges"); + prop, + "Area Normal", + "Affect only vertices with a similar normal to where the stroke starts"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_boundary_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Boundary Auto-Masking", - "Do not affect vertices that belong to a Face Set boundary"); + prop = RNA_def_property(srna, "use_automasking_view_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_VIEW_NORMAL); + RNA_def_property_ui_text( + prop, "View Normal", "Affect only vertices with a normal that faces the viewer"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_view_occlusion", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_VIEW_OCCLUSION); + RNA_def_property_ui_text( + prop, + "Occlusion", + "Only affect vertices that are not occluded by other faces. (Slower performance)"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "automasking_start_normal_limit", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "automasking_start_normal_limit"); + RNA_def_property_range(prop, 0.0001f, M_PI); + RNA_def_property_ui_text(prop, "Area Normal Limit", "The range of angles that will be affected"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "automasking_start_normal_falloff", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "automasking_start_normal_falloff"); + RNA_def_property_range(prop, 0.0001f, 1.0f); + RNA_def_property_ui_text( + prop, "Area Normal Falloff", "Extend the angular range with a falloff gradient"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "automasking_view_normal_limit", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "automasking_view_normal_limit"); + RNA_def_property_range(prop, 0.0001f, M_PI); + RNA_def_property_ui_text(prop, "View Normal Limit", "The range of angles that will be affected"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "automasking_view_normal_falloff", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "automasking_view_normal_falloff"); + RNA_def_property_range(prop, 0.0001f, 1.0f); + RNA_def_property_ui_text( + prop, "View Normal Falloff", "Extend the angular range with a falloff gradient"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE); @@ -1550,6 +1638,36 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + prop = RNA_def_property(srna, "use_automasking_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE); + RNA_def_property_ui_text(prop, "Auto-Masking Strokes", "Affect only strokes below the cursor"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_layer_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_STROKE); + RNA_def_property_ui_text(prop, "Auto-Masking Layer", "Affect only strokes below the cursor"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_material_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_STROKE); + RNA_def_property_ui_text(prop, "Auto-Masking Material", "Affect only strokes below the cursor"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_layer_active", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_ACTIVE); + RNA_def_property_ui_text(prop, "Auto-Masking Layer", "Affect only the Active Layer"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + + prop = RNA_def_property(srna, "use_automasking_material_active", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE); + RNA_def_property_ui_text(prop, "Auto-Masking Material", "Affect only the Active Material"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + /* custom falloff curve */ prop = RNA_def_property(srna, "multiframe_falloff_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "cur_falloff"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index aa40ee846bf..a10c64e292e 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -330,7 +330,6 @@ static void rna_Sequence_start_frame_final_set(PointerRNA *ptr, int value) Scene *scene = (Scene *)ptr->owner_id; SEQ_time_left_handle_frame_set(scene, seq, value); - SEQ_transform_fix_single_image_seq_offsets(scene, seq); do_sequence_frame_change_update(scene, seq); SEQ_relations_invalidate_cache_composite(scene, seq); } @@ -341,7 +340,6 @@ static void rna_Sequence_end_frame_final_set(PointerRNA *ptr, int value) Scene *scene = (Scene *)ptr->owner_id; SEQ_time_right_handle_frame_set(scene, seq, value); - SEQ_transform_fix_single_image_seq_offsets(scene, seq); do_sequence_frame_change_update(scene, seq); SEQ_relations_invalidate_cache_composite(scene, seq); } @@ -778,7 +776,7 @@ static void rna_Sequence_filepath_get(PointerRNA *ptr, char *value) { Sequence *seq = (Sequence *)(ptr->data); - BLI_join_dirfile(value, FILE_MAX, seq->strip->dir, seq->strip->stripdata->name); + BLI_path_join(value, FILE_MAX, seq->strip->dir, seq->strip->stripdata->name); } static int rna_Sequence_filepath_length(PointerRNA *ptr) @@ -786,7 +784,7 @@ static int rna_Sequence_filepath_length(PointerRNA *ptr) Sequence *seq = (Sequence *)(ptr->data); char path[FILE_MAX]; - BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_join(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); return strlen(path); } @@ -804,7 +802,7 @@ static void rna_Sequence_proxy_filepath_get(PointerRNA *ptr, char *value) { StripProxy *proxy = (StripProxy *)(ptr->data); - BLI_join_dirfile(value, FILE_MAX, proxy->dir, proxy->file); + BLI_path_join(value, FILE_MAX, proxy->dir, proxy->file); } static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr) @@ -812,7 +810,7 @@ static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr) StripProxy *proxy = (StripProxy *)(ptr->data); char path[FILE_MAX]; - BLI_join_dirfile(path, sizeof(path), proxy->dir, proxy->file); + BLI_path_join(path, sizeof(path), proxy->dir, proxy->file); return strlen(path); } @@ -2247,6 +2245,7 @@ static void rna_def_editor(BlenderRNA *brna) prop = RNA_def_property(srna, "proxy_storage", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, editing_storage_items); RNA_def_property_ui_text(prop, "Proxy Storage", "How to store proxies for this project"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SEQUENCE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_update_cache"); prop = RNA_def_property(srna, "proxy_dir", PROP_STRING, PROP_DIRPATH); @@ -2892,6 +2891,7 @@ static void rna_def_wipe(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "forward"); RNA_def_property_enum_items(prop, wipe_direction_items); RNA_def_property_ui_text(prop, "Direction", "Wipe direction"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SEQUENCE); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update"); prop = RNA_def_property(srna, "transition_type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5fa1033bcd4..af15311031b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -19,6 +19,7 @@ #include "BKE_movieclip.h" #include "BKE_node.h" #include "BKE_studiolight.h" +#include "BKE_viewer_path.h" #include "ED_asset.h" #include "ED_spreadsheet.h" @@ -430,7 +431,11 @@ static const EnumPropertyItem rna_enum_shading_color_type_items[] = { {V3D_SHADING_OBJECT_COLOR, "OBJECT", 0, "Object", "Show object color"}, {V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"}, {V3D_SHADING_VERTEX_COLOR, "VERTEX", 0, "Attribute", "Show active color attribute"}, - {V3D_SHADING_TEXTURE_COLOR, "TEXTURE", 0, "Texture", "Show texture"}, + {V3D_SHADING_TEXTURE_COLOR, + "TEXTURE", + 0, + "Texture", + "Show the texture from the active image texture node using the active UV map coordinates"}, {0, NULL, 0, NULL, NULL}, }; @@ -540,6 +545,7 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = { # include "BLI_string.h" # include "BKE_anim_data.h" +# include "BKE_asset.h" # include "BKE_brush.h" # include "BKE_colortools.h" # include "BKE_context.h" @@ -1006,6 +1012,13 @@ static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_RegionView3D, regiondata); } +static void rna_SpaceView3D_object_type_visibility_update(Main *UNUSED(bmain), + Scene *scene, + PointerRNA *UNUSED(ptr)) +{ + DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); +} + static void rna_SpaceView3D_region_quadviews_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { @@ -1550,7 +1563,7 @@ static void rna_SpaceView3D_use_local_collections_update(bContext *C, PointerRNA View3D *v3d = (View3D *)ptr->data; if (ED_view3d_local_collections_set(bmain, v3d)) { - BKE_layer_collection_local_sync(view_layer, v3d); + BKE_layer_collection_local_sync(scene, view_layer, v3d); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); } } @@ -1694,7 +1707,9 @@ static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) Object *obedit = NULL; wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); if (win != NULL) { + Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); + BKE_view_layer_synced_ensure(scene, view_layer); obedit = BKE_view_layer_edit_object_get(view_layer); } return ED_space_image_show_uvedit(sima, obedit); @@ -1707,7 +1722,9 @@ static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) Object *obedit = NULL; wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); if (win != NULL) { + Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); + BKE_view_layer_synced_ensure(scene, view_layer); obedit = BKE_view_layer_edit_object_get(view_layer); } return ED_space_image_check_show_maskedit(sima, obedit); @@ -1903,6 +1920,15 @@ static void rna_SpaceUVEditor_tile_grid_shape_set(PointerRNA *ptr, const int *va } } +static void rna_SpaceUVEditor_custom_grid_subdiv_set(PointerRNA *ptr, const int *values) +{ + SpaceImage *data = (SpaceImage *)(ptr->data); + + for (int i = 0; i < 2; i++) { + data->custom_grid_subdiv[i] = CLAMPIS(values[i], 1, 5000); + } +} + /* Space Text Editor */ static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, bool value) @@ -2205,9 +2231,11 @@ static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Main *bmain = CTX_data_main(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *obact = BKE_view_layer_active_object_get(view_layer); if (obact == NULL) { return; @@ -2280,7 +2308,9 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr) { SpaceAction *saction = (SpaceAction *)(ptr->data); ScrArea *area = CTX_wm_area(C); + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_synced_ensure(scene, view_layer); Object *obact = BKE_view_layer_active_object_get(view_layer); /* special exceptions for ShapeKey Editor mode */ @@ -2753,18 +2783,24 @@ static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr { const FileDirEntry *entry = ptr->data; + if (!entry->asset) { + return PointerRNA_NULL; + } + + AssetMetaData *asset_data = BKE_asset_representation_metadata_get(entry->asset); + /* Note that the owning ID of the RNA pointer (`ptr->owner_id`) has to be set carefully: * Local IDs (`entry->id`) own their asset metadata themselves. Asset metadata from other blend * files are owned by the file browser (`entry`). Only if this is set correctly, we can tell from * the metadata RNA pointer if the metadata is stored locally and can thus be edited or not. */ - if (entry->id) { + if (BKE_asset_representation_is_local_id(entry->asset)) { PointerRNA id_ptr; RNA_id_pointer_create(entry->id, &id_ptr); - return rna_pointer_inherit_refine(&id_ptr, &RNA_AssetMetaData, entry->asset_data); + return rna_pointer_inherit_refine(&id_ptr, &RNA_AssetMetaData, asset_data); } - return rna_pointer_inherit_refine(ptr, &RNA_AssetMetaData, entry->asset_data); + return rna_pointer_inherit_refine(ptr, &RNA_AssetMetaData, asset_data); } static int rna_FileBrowser_FileSelectEntry_name_editable(PointerRNA *ptr, const char **r_info) @@ -2774,7 +2810,7 @@ static int rna_FileBrowser_FileSelectEntry_name_editable(PointerRNA *ptr, const /* This actually always returns 0 (the name is never editable) but we want to get a disabled * message returned to `r_info` in some cases. */ - if (entry->asset_data) { + if (entry->asset) { PointerRNA asset_data_ptr = rna_FileBrowser_FileSelectEntry_asset_data_get(ptr); /* Get disabled hint from asset metadata polling. */ rna_AssetMetaData_editable(&asset_data_ptr, r_info); @@ -3283,59 +3319,21 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *UN return item_array; } -static SpreadsheetContext *rna_SpaceSpreadsheet_context_path_append(SpaceSpreadsheet *sspreadsheet, - int type) -{ - SpreadsheetContext *context = ED_spreadsheet_context_new(type); - BLI_addtail(&sspreadsheet->context_path, context); - ED_spreadsheet_context_path_update_tag(sspreadsheet); - WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); - return context; -} - -static void rna_SpaceSpreadsheet_context_path_clear(SpaceSpreadsheet *sspreadsheet) +static StructRNA *rna_viewer_path_elem_refine(PointerRNA *ptr) { - ED_spreadsheet_context_path_clear(sspreadsheet); - ED_spreadsheet_context_path_update_tag(sspreadsheet); - WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); -} - -static StructRNA *rna_spreadsheet_context_refine(PointerRNA *ptr) -{ - SpreadsheetContext *context = ptr->data; - switch (context->type) { - case SPREADSHEET_CONTEXT_OBJECT: - return &RNA_SpreadsheetContextObject; - case SPREADSHEET_CONTEXT_MODIFIER: - return &RNA_SpreadsheetContextModifier; - case SPREADSHEET_CONTEXT_NODE: - return &RNA_SpreadsheetContextNode; + ViewerPathElem *elem = ptr->data; + switch (elem->type) { + case VIEWER_PATH_ELEM_TYPE_ID: + return &RNA_IDViewerPathElem; + case VIEWER_PATH_ELEM_TYPE_MODIFIER: + return &RNA_ModifierViewerPathElem; + case VIEWER_PATH_ELEM_TYPE_NODE: + return &RNA_NodeViewerPathElem; } BLI_assert_unreachable(); return NULL; } -static void rna_spreadsheet_context_update(Main *UNUSED(bmain), - Scene *UNUSED(scene), - PointerRNA *ptr) -{ - bScreen *screen = (bScreen *)ptr->owner_id; - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - SpaceLink *sl = area->spacedata.first; - if (sl->spacetype == SPACE_SPREADSHEET) { - SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl; - ED_spreadsheet_context_path_update_tag(sspreadsheet); - } - } -} - -static void rna_SpaceSpreadsheet_context_path_guess(SpaceSpreadsheet *sspreadsheet, bContext *C) -{ - ED_spreadsheet_context_path_guess(C, sspreadsheet); - ED_spreadsheet_context_path_update_tag(sspreadsheet); - WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); -} - static void rna_FileAssetSelectParams_catalog_id_get(PointerRNA *ptr, char *value) { const FileAssetSelectParams *params = ptr->data; @@ -3571,10 +3569,17 @@ static void rna_def_space_image_uv(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; - static const EnumPropertyItem pixel_snap_mode_items[] = { - {SI_PIXEL_SNAP_DISABLED, "DISABLED", 0, "Disabled", "Don't snap to pixels"}, - {SI_PIXEL_SNAP_CORNER, "CORNER", 0, "Corner", "Snap to pixel corners"}, - {SI_PIXEL_SNAP_CENTER, "CENTER", 0, "Center", "Snap to pixel centers"}, + static const EnumPropertyItem pixel_round_mode_items[] = { + {SI_PIXEL_ROUND_DISABLED, "DISABLED", 0, "Disabled", "Don't round to pixels"}, + {SI_PIXEL_ROUND_CORNER, "CORNER", 0, "Corner", "Round to pixel corners"}, + {SI_PIXEL_ROUND_CENTER, "CENTER", 0, "Center", "Round to pixel centers"}, + {0, NULL, 0, NULL, NULL}, + }; + + static const EnumPropertyItem grid_shape_source_items[] = { + {SI_GRID_SHAPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", "Dynamic grid"}, + {SI_GRID_SHAPE_FIXED, "FIXED", 0, "Fixed", "Manually set grid divisions"}, + {SI_GRID_SHAPE_PIXEL, "PIXEL", 0, "Pixel", "Grid aligns with pixels from image"}, {0, NULL, 0, NULL, NULL}, }; @@ -3645,15 +3650,23 @@ static void rna_def_space_image_uv(BlenderRNA *brna) prop, "Tile Grid Shape", "How many tiles will be shown in the background"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "use_custom_grid", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CUSTOM_GRID); + prop = RNA_def_property(srna, "show_grid_over_image", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_GRID_OVER_IMAGE); RNA_def_property_boolean_default(prop, true); - RNA_def_property_ui_text(prop, "Custom Grid", "Use a grid with a user-defined number of steps"); + RNA_def_property_ui_text(prop, "Grid Over Image", "Show the grid over the image"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); + + prop = RNA_def_property(srna, "grid_shape_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, grid_shape_source_items); + RNA_def_property_ui_text(prop, "Grid Shape Source", "Specify source for the grid shape"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - prop = RNA_def_property(srna, "custom_grid_subdivisions", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "custom_grid_subdivisions", PROP_INT, PROP_XYZ); RNA_def_property_int_sdna(prop, NULL, "custom_grid_subdiv"); + RNA_def_property_array(prop, 2); + RNA_def_property_int_default(prop, 10); RNA_def_property_range(prop, 1, 5000); + RNA_def_property_int_funcs(prop, NULL, "rna_SpaceUVEditor_custom_grid_subdiv_set", NULL); RNA_def_property_ui_text( prop, "Dynamic Grid Size", "Number of grid units in UV space that make one UV Unit"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); @@ -3664,11 +3677,9 @@ static void rna_def_space_image_uv(BlenderRNA *brna) RNA_def_property_ui_text(prop, "UV Opacity", "Opacity of UV overlays"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - /* TODO: move edge and face drawing options here from `G.f`. */ - - prop = RNA_def_property(srna, "pixel_snap_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, pixel_snap_mode_items); - RNA_def_property_ui_text(prop, "Snap to Pixels", "Snap UVs to pixels while editing"); + prop = RNA_def_property(srna, "pixel_round_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, pixel_round_mode_items); + RNA_def_property_ui_text(prop, "Round to Pixels", "Round UVs to pixels while editing"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "lock_bounds", PROP_BOOLEAN, PROP_NONE); @@ -4038,6 +4049,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) prop = RNA_def_property(srna, "cavity_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, cavity_type_items); RNA_def_property_ui_text(prop, "Cavity Type", "Way to display the cavity shading"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_EDITOR_VIEW3D); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL); prop = RNA_def_property(srna, "curvature_ridge_factor", PROP_FLOAT, PROP_FACTOR); @@ -4147,6 +4159,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) prop = RNA_def_property(srna, "background_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, background_type_items); RNA_def_property_ui_text(prop, "Background", "Way to display the background"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_EDITOR_VIEW3D); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL); prop = RNA_def_property(srna, "background_color", PROP_FLOAT, PROP_COLOR); @@ -4479,6 +4492,20 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_viewer_attribute", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_VIEWER_ATTRIBUTE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Viewer Node", "Show attribute overlay for active viewer node"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "viewer_attribute_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.viewer_attribute_opacity"); + RNA_def_property_ui_text( + prop, "Viewer Attribute Opacity", "Opacity of the attribute that is currently visualized"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_paint_wire", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "overlay.paint_flag", V3D_OVERLAY_PAINT_WIRE); RNA_def_property_ui_text(prop, "Show Wire", "Use wireframe display in painting modes"); @@ -5121,7 +5148,8 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_mirror_xr_session_update"); rna_def_object_type_visibility_flags_common(srna, - NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING); + NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, + "rna_SpaceView3D_object_type_visibility_update"); /* Helper for drawing the icon. */ prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE); @@ -5130,6 +5158,11 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Visibility Icon", ""); + prop = RNA_def_property(srna, "show_viewer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_VIEWER); + RNA_def_property_ui_text(prop, "Show Viewer", "Display non-final geometry from viewer nodes"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL); + /* Nested Structs */ prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -5306,6 +5339,7 @@ static void rna_def_space_properties(BlenderRNA *brna) RNA_def_property_enum_funcs( prop, NULL, "rna_SpaceProperties_context_set", "rna_SpaceProperties_context_itemf"); RNA_def_property_ui_text(prop, "", ""); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); RNA_def_property_update( prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update"); @@ -6056,7 +6090,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) RNA_def_struct_sdna(srna, "SpaceAction"); RNA_def_struct_ui_text(srna, "Space Dope Sheet Editor", "Dope Sheet space data"); - rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI)); + rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD)); /* data */ prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); @@ -6369,7 +6403,7 @@ static void rna_def_space_nla(BlenderRNA *brna) RNA_def_struct_sdna(srna, "SpaceNla"); RNA_def_struct_ui_text(srna, "Space Nla Editor", "NLA editor space data"); - rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI)); + rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD)); /* display */ prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); @@ -6603,6 +6637,7 @@ static void rna_def_fileselect_entry(BlenderRNA *brna) prop, "Data-block Type", "The type of the data-block, if the file represents one ('NONE' otherwise)"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); @@ -6673,7 +6708,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Title", "Title for the file browser"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - /* Use BYTESTRING rather than DIRPATH as subtype so UI code doesn't add OT_directory_browse + /* Use BYTESTRING rather than DIRPATH as sub-type so UI code doesn't add OT_directory_browse * button when displaying this prop in the file browser (it would just open a file browser). That * should be the only effective difference between the two. */ prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_BYTESTRING); @@ -7355,12 +7390,14 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "texfrom"); RNA_def_property_enum_items(prop, texture_id_type_items); RNA_def_property_ui_text(prop, "Texture Type", "Type of data to take texture from"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); prop = RNA_def_property(srna, "shader_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "shaderfrom"); RNA_def_property_enum_items(prop, shader_type_items); RNA_def_property_ui_text(prop, "Shader Type", "Type of data to take shader from"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); @@ -7556,6 +7593,7 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, rna_enum_clip_editor_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_clip_mode_update"); /* view */ @@ -7906,93 +7944,77 @@ static void rna_def_spreadsheet_row_filter(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); } -static const EnumPropertyItem spreadsheet_context_type_items[] = { - {SPREADSHEET_CONTEXT_OBJECT, "OBJECT", ICON_NONE, "Object", ""}, - {SPREADSHEET_CONTEXT_MODIFIER, "MODIFIER", ICON_NONE, "Modifier", ""}, - {SPREADSHEET_CONTEXT_NODE, "NODE", ICON_NONE, "Node", ""}, +static const EnumPropertyItem viewer_path_elem_type_items[] = { + {VIEWER_PATH_ELEM_TYPE_ID, "ID", ICON_NONE, "ID", ""}, + {VIEWER_PATH_ELEM_TYPE_MODIFIER, "MODIFIER", ICON_NONE, "Modifier", ""}, + {VIEWER_PATH_ELEM_TYPE_NODE, "NODE", ICON_NONE, "Node", ""}, {0, NULL, 0, NULL, NULL}, }; -static void rna_def_space_spreadsheet_context(BlenderRNA *brna) +static void rna_def_viewer_path_elem(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpreadsheetContext", NULL); - RNA_def_struct_ui_text(srna, "Spreadsheet Context", "Element of spreadsheet context path"); - RNA_def_struct_refine_func(srna, "rna_spreadsheet_context_refine"); + srna = RNA_def_struct(brna, "ViewerPathElem", NULL); + RNA_def_struct_ui_text(srna, "Viewer Path Element", "Element of a viewer path"); + RNA_def_struct_refine_func(srna, "rna_viewer_path_elem_refine"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, spreadsheet_context_type_items); - RNA_def_property_ui_text(prop, "Type", "Type of the context"); + RNA_def_property_enum_items(prop, viewer_path_elem_type_items); + RNA_def_property_ui_text(prop, "Type", "Type of the path element"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - rna_def_space_generic_show_region_toggles(srna, - (1 << RGN_TYPE_CHANNELS) | (1 << RGN_TYPE_FOOTER)); } -static void rna_def_space_spreadsheet_context_object(BlenderRNA *brna) +static void rna_def_id_viewer_path_elem(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpreadsheetContextObject", "SpreadsheetContext"); + srna = RNA_def_struct(brna, "IDViewerPathElem", "ViewerPathElem"); - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, "rna_spreadsheet_context_update"); + prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "ID", ""); } -static void rna_def_space_spreadsheet_context_modifier(BlenderRNA *brna) +static void rna_def_modifier_viewer_path_elem(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpreadsheetContextModifier", "SpreadsheetContext"); + srna = RNA_def_struct(brna, "ModifierViewerPathElem", "ViewerPathElem"); prop = RNA_def_property(srna, "modifier_name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Modifier Name", ""); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, "rna_spreadsheet_context_update"); } -static void rna_def_space_spreadsheet_context_node(BlenderRNA *brna) +static void rna_def_node_viewer_path_elem(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpreadsheetContextNode", "SpreadsheetContext"); + srna = RNA_def_struct(brna, "NodeViewerPathElem", "ViewerPathElem"); prop = RNA_def_property(srna, "node_name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Node Name", ""); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, "rna_spreadsheet_context_update"); } -static void rna_def_space_spreadsheet_context_path(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_viewer_path(BlenderRNA *brna) { StructRNA *srna; - PropertyRNA *parm; - FunctionRNA *func; - - RNA_def_property_srna(cprop, "SpreadsheetContextPath"); - srna = RNA_def_struct(brna, "SpreadsheetContextPath", NULL); - RNA_def_struct_sdna(srna, "SpaceSpreadsheet"); + PropertyRNA *prop; - func = RNA_def_function(srna, "append", "rna_SpaceSpreadsheet_context_path_append"); - RNA_def_function_ui_description(func, "Append a context path element"); - parm = RNA_def_property(func, "type", PROP_ENUM, PROP_NONE); - RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - RNA_def_property_enum_items(parm, spreadsheet_context_type_items); - parm = RNA_def_pointer( - func, "context", "SpreadsheetContext", "", "Newly created context path element"); - RNA_def_function_return(func, parm); + rna_def_viewer_path_elem(brna); + rna_def_id_viewer_path_elem(brna); + rna_def_modifier_viewer_path_elem(brna); + rna_def_node_viewer_path_elem(brna); - func = RNA_def_function(srna, "clear", "rna_SpaceSpreadsheet_context_path_clear"); - RNA_def_function_ui_description(func, "Clear entire context path"); + srna = RNA_def_struct(brna, "ViewerPath", NULL); + RNA_def_struct_ui_text(srna, "Viewer Path", "Path to data that is viewed"); - func = RNA_def_function(srna, "guess", "rna_SpaceSpreadsheet_context_path_guess"); - RNA_def_function_ui_description(func, "Guess the context path from the current context"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT); + prop = RNA_def_property(srna, "path", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "ViewerPathElem"); + RNA_def_property_ui_text(prop, "Viewer Path", NULL); } static void rna_def_space_spreadsheet(BlenderRNA *brna) @@ -8019,11 +8041,6 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; - rna_def_space_spreadsheet_context(brna); - rna_def_space_spreadsheet_context_object(brna); - rna_def_space_spreadsheet_context_modifier(brna); - rna_def_space_spreadsheet_context_node(brna); - srna = RNA_def_struct(brna, "SpaceSpreadsheet", "Space"); RNA_def_struct_ui_text(srna, "Space Spreadsheet", "Spreadsheet space data"); @@ -8040,15 +8057,14 @@ static void rna_def_space_spreadsheet(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Filter", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); - prop = RNA_def_property(srna, "display_context_path_collapsed", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "display_viewer_path_collapsed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SPREADSHEET_FLAG_CONTEXT_PATH_COLLAPSED); RNA_def_property_ui_text(prop, "Display Context Path Collapsed", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); - prop = RNA_def_property(srna, "context_path", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "SpreadsheetContext"); - RNA_def_property_ui_text(prop, "Context Path", "Context path to the data being displayed"); - rna_def_space_spreadsheet_context_path(brna, prop); + prop = RNA_def_property(srna, "viewer_path", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text( + prop, "Viewer Path", "Path to the data that is displayed in the spreadsheet"); prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", SPREADSHEET_FILTER_SELECTED_ONLY); @@ -8173,6 +8189,7 @@ static void rna_def_space_assets(BlenderRNA *brna) void RNA_def_space(BlenderRNA *brna) { rna_def_space(brna); + rna_def_viewer_path(brna); rna_def_space_image(brna); rna_def_space_sequencer(brna); rna_def_space_text(brna); diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c index b3896919275..9790a85e1c8 100644 --- a/source/blender/makesrna/intern/rna_space_api.c +++ b/source/blender/makesrna/intern/rna_space_api.c @@ -119,7 +119,9 @@ void RNA_api_space_text(StructRNA *srna) RNA_def_function_output(func, parm); } -void rna_def_object_type_visibility_flags_common(StructRNA *srna, int noteflag) +void rna_def_object_type_visibility_flags_common(StructRNA *srna, + int noteflag, + const char *update_func) { PropertyRNA *prop; @@ -173,7 +175,7 @@ void rna_def_object_type_visibility_flags_common(StructRNA *srna, int noteflag) RNA_def_property_boolean_negative_sdna( prop, NULL, view_mask_member[mask_index], info[type_index].type_mask); RNA_def_property_ui_text(prop, info[type_index].name, ""); - RNA_def_property_update(prop, noteflag, NULL); + RNA_def_property_update(prop, noteflag, update_func); } } } diff --git a/source/blender/makesrna/intern/rna_test.c b/source/blender/makesrna/intern/rna_test.c index ed3be815235..96b732c3aba 100644 --- a/source/blender/makesrna/intern/rna_test.c +++ b/source/blender/makesrna/intern/rna_test.c @@ -103,7 +103,7 @@ void RNA_def_test(BlenderRNA *brna) # ifdef UNIT_TEST StructRNA *srna; PropertyRNA *prop; - unsigned short dimsize[] = {MARRAY_DIMSIZE}; + ushort dimsize[] = {MARRAY_DIMSIZE}; srna = RNA_def_struct(brna, "Test", NULL); RNA_def_struct_sdna(srna, "Test"); diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c index e9c67d71ceb..4f756c163d1 100644 --- a/source/blender/makesrna/intern/rna_text.c +++ b/source/blender/makesrna/intern/rna_text.c @@ -231,6 +231,7 @@ static void rna_def_text(BlenderRNA *brna) prop = RNA_def_property(srna, "indentation", PROP_ENUM, PROP_NONE); /* as an enum */ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags"); RNA_def_property_enum_items(prop, indentation_items); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT); RNA_def_property_ui_text(prop, "Indentation", "Use tabs or spaces for indentation"); prop = RNA_def_property(srna, "lines", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 3b28dc70e9e..2254db4edaf 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -24,6 +24,8 @@ #include "BKE_node_tree_update.h" #include "BKE_paint.h" +#include "BLT_translation.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -1191,6 +1193,7 @@ static void rna_def_texture_image(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_image_extension); RNA_def_property_ui_text( prop, "Extension", "How the image is extrapolated past its original bounds"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_IMAGE); RNA_def_property_update(prop, 0, "rna_Texture_update"); prop = RNA_def_property(srna, "repeat_x", PROP_INT, PROP_NONE); @@ -1235,7 +1238,7 @@ static void rna_def_texture_image(BlenderRNA *brna) # if 0 /* XXX: did this as an array, but needs better descriptions than "1 2 3 4" - * perhaps a new subtype could be added? + * perhaps a new sub-type could be added? * --I actually used single values for this, maybe change later with a RNA_Rect thing? */ prop = RNA_def_property(srna, "crop_rectangle", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "cropxmin"); diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index b9acd57430b..44df0db9ade 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -13,6 +13,8 @@ #include "BKE_node_tree_update.h" #include "BKE_tracking.h" +#include "BLT_translation.h" + #include "RNA_access.h" #include "RNA_define.h" @@ -1638,7 +1640,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); /* color */ - prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text( @@ -2197,6 +2199,7 @@ static void rna_def_trackingTracks(BlenderRNA *brna) prop, "rna_tracking_active_track_get", "rna_tracking_active_track_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Track", "Active track in this tracking data object"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP); } static void rna_def_trackingPlaneTracks(BlenderRNA *brna) @@ -2257,6 +2260,7 @@ static void rna_def_trackingObjectTracks(BlenderRNA *brna) prop, "rna_tracking_active_track_get", "rna_tracking_active_track_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Track", "Active track in this tracking data object"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP); } static void rna_def_trackingObjectPlaneTracks(BlenderRNA *brna) @@ -2278,6 +2282,7 @@ static void rna_def_trackingObjectPlaneTracks(BlenderRNA *brna) NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Track", "Active track in this tracking data object"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP); } static void rna_def_trackingObject(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index fc68e8421d7..eac29ac5e61 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -1785,6 +1785,10 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_pointer(func, "socket", "NodeSocket", "", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + func = RNA_def_function(srna, "template_node_asset_menu_items", "uiTemplateNodeAssetMenuItems"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + parm = RNA_def_string(func, "catalog_path", NULL, 0, "", ""); + func = RNA_def_function(srna, "template_texture_user", "uiTemplateTextureUser"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index a0acbdcd2a3..fdb98781943 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -403,11 +403,11 @@ static void rna_userdef_anim_update(Main *UNUSED(bmain), USERDEF_TAG_DIRTY; } -static void rna_userdef_tablet_api_update(Main *UNUSED(bmain), - Scene *UNUSED(scene), - PointerRNA *UNUSED(ptr)) +static void rna_userdef_input_devices(Main *UNUSED(bmain), + Scene *UNUSED(scene), + PointerRNA *UNUSED(ptr)) { - WM_init_tablet_api(); + WM_init_input_devices(); USERDEF_TAG_DIRTY; } @@ -574,7 +574,7 @@ static void rna_Userdef_disk_cache_dir_update(Main *UNUSED(bmain), { if (U.sequencer_disk_cache_dir[0] != '\0') { BLI_path_abs(U.sequencer_disk_cache_dir, BKE_main_blendfile_path_from_global()); - BLI_path_slash_ensure(U.sequencer_disk_cache_dir); + BLI_path_slash_ensure(U.sequencer_disk_cache_dir, sizeof(U.sequencer_disk_cache_dir)); BLI_path_make_safe(U.sequencer_disk_cache_dir); } @@ -1685,7 +1685,7 @@ static void rna_def_userdef_theme_space_common(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); /* buttons */ - /* if (! ELEM(spacetype, SPACE_PROPERTIES, SPACE_OUTLINER)) { */ + // if (!ELEM(spacetype, SPACE_PROPERTIES, SPACE_OUTLINER)) { prop = RNA_def_property(srna, "button", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Region Background", ""); @@ -1737,7 +1737,7 @@ static void rna_def_userdef_theme_space_common(StructRNA *srna) RNA_def_property_ui_text(prop, "Tab Outline", ""); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); - /* } */ + // } } static void rna_def_userdef_theme_space_gradient(BlenderRNA *brna) @@ -4085,6 +4085,7 @@ static void rna_def_userdef_studiolights(BlenderRNA *brna) STUDIOLIGHT_TYPE_WORLD, "Type", "The type for the new studio light"); + RNA_def_property_translation_context(parm, BLT_I18NCONTEXT_ID_LIGHT); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer(func, "studio_light", "StudioLight", "", "Newly created StudioLight"); RNA_def_function_return(func, parm); @@ -4145,6 +4146,7 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_type_get", NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_LIGHT); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs( @@ -5259,6 +5261,12 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Duplicate Volume", "Causes volume data to be duplicated with the object"); + prop = RNA_def_property(srna, "use_duplicate_node_tree", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_NTREE); + RNA_def_property_ui_text(prop, + "Duplicate Node Tree", + "Make copies of node groups when duplicating nodes in the node editor"); + /* Currently only used for insert offset (aka auto-offset), * maybe also be useful for later stuff though. */ prop = RNA_def_property(srna, "node_margin", PROP_INT, PROP_PIXEL); @@ -5767,6 +5775,14 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_enum_items(prop, view_zoom_axes); RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on"); + prop = RNA_def_property(srna, "use_multitouch_gestures", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_NO_MULTITOUCH_GESTURES); + RNA_def_property_ui_text( + prop, + "Multi-touch Gestures", + "Use multi-touch gestures for navigation with touchpad, instead of scroll wheel emulation"); + RNA_def_property_update(prop, 0, "rna_userdef_input_devices"); + prop = RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT); RNA_def_property_ui_text( @@ -5902,7 +5918,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) "Tablet API", "Select the tablet API to use for pressure sensitivity (may require " "restarting Blender for changes to take effect)"); - RNA_def_property_update(prop, 0, "rna_userdef_tablet_api_update"); + RNA_def_property_update(prop, 0, "rna_userdef_input_devices"); # ifdef WITH_INPUT_NDOF /* 3D mouse settings */ diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index ac1803b0a11..eebe595820e 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -99,13 +99,6 @@ static const EnumPropertyItem event_ndof_type_items[] = { {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "Dominant", ""}, {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "Plus", ""}, {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "Minus", ""}, -# if 0 /* Never used (converted to keyboard events by GHOST). */ - /* keyboard emulation */ - {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "Esc"}, - {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "Alt"}, - {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "Shift"}, - {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "Ctrl"}, -# endif /* general-purpose buttons */ {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "Button 1", ""}, {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "Button 2", ""}, @@ -120,6 +113,21 @@ static const EnumPropertyItem event_ndof_type_items[] = { {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "Button A", ""}, {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "Button B", ""}, {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "Button C", ""}, + /* View buttons. */ + {NDOF_BUTTON_V1, "NDOF_BUTTON_V1", 0, "View 1", ""}, + {NDOF_BUTTON_V2, "NDOF_BUTTON_V2", 0, "View 2", ""}, + {NDOF_BUTTON_V3, "NDOF_BUTTON_V3", 0, "View 3", ""}, +# if 0 /* Never used (converted to keyboard events by GHOST). */ + /* keyboard emulation */ + {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "Esc"}, + {NDOF_BUTTON_ENTER, "NDOF_BUTTON_ENTER", 0, "Enter"}, + {NDOF_BUTTON_DELETE, "NDOF_BUTTON_DELETE", 0, "Delete"}, + {NDOF_BUTTON_TAB, "NDOF_BUTTON_TAB", 0, "Tab"}, + {NDOF_BUTTON_SPACE, "NDOF_BUTTON_SPACE", 0, "Space"}, + {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "Alt"}, + {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "Shift"}, + {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "Ctrl"}, +# endif {0, NULL, 0, NULL, NULL}, }; #endif /* RNA_RUNTIME */ @@ -1644,12 +1652,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, return NULL; } - if (strlen(identifier) >= sizeof(dummyop.idname)) { - BKE_reportf(reports, - RPT_ERROR, - "Registering operator class: '%s' is too long, maximum length is %d", - identifier, - (int)sizeof(dummyop.idname)); + if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) { return NULL; } @@ -1661,10 +1664,6 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, } } - if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) { - return NULL; - } - char idname_conv[sizeof(dummyop.idname)]; WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */ @@ -1867,8 +1866,9 @@ static void rna_def_operator_common(StructRNA *srna) /* Registration */ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->idname"); - /* Without setting the length the pointer size would be used. -3 because `.` -> `_OT_`. */ - RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME - 3); + /* String stored here is the 'BL' identifier (`OPMODULE_OT_my_op`), + * not the 'python' identifier (`opmodule.my_op`). */ + RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set"); // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_REGISTER); @@ -2357,6 +2357,7 @@ static void rna_def_window(BlenderRNA *brna) "rna_Window_screen_set", NULL, "rna_Window_screen_assign_poll"); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SCREEN); RNA_def_property_flag(prop, PROP_NEVER_NULL | PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_workspace_screen_update"); diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c index dcfa1bbca51..c803e5dc9a8 100644 --- a/source/blender/makesrna/intern/rna_xr.c +++ b/source/blender/makesrna/intern/rna_xr.c @@ -2052,7 +2052,7 @@ static void rna_def_xr_session_settings(BlenderRNA *brna) "Allow the VR tracking origin to be defined independently of the headset location"); RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL); - rna_def_object_type_visibility_flags_common(srna, NC_WM | ND_XR_DATA_CHANGED); + rna_def_object_type_visibility_flags_common(srna, NC_WM | ND_XR_DATA_CHANGED, NULL); /* Helper for drawing the icon. */ prop = RNA_def_property(srna, "icon_from_show_object_viewport", PROP_INT, PROP_NONE); |