diff options
author | Martijn Versteegh <blender@aaltjegron.nl> | 2022-09-23 10:37:51 +0300 |
---|---|---|
committer | Martijn Versteegh <blender@aaltjegron.nl> | 2022-09-23 14:03:34 +0300 |
commit | 257c06166939cab750d4cd37f2f14eaf0e4f319b (patch) | |
tree | 2a39a764de0fa0e55b7fd1bff693d6a717720988 /source/blender/makesrna | |
parent | a5269f81dbe4c8884820469f9fedc2c836d5a366 (diff) | |
parent | 319ee296fd0cebbfccf2c0604618deac1ab2e3b6 (diff) |
Merge branch 'master' into refactor-mesh-uv-map-generic
Diffstat (limited to 'source/blender/makesrna')
23 files changed, 438 insertions, 162 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_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..2b06daf34e3 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) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 835265b1986..e5932f33604 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -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 */ diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index 5e17f22ecf5..03bb1a44526 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[] = { @@ -194,7 +196,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 +323,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 +747,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 +798,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..bd0e14e4b59 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -286,6 +286,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_RADIUS, "RADIUS", 0, "Radius", "Connect endpoints that are close together"}, + {GP_FILL_EMODE_EXTEND, "EXTEND", 0, "Extend", "Extend strokes in straight lines"}, + {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 +977,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; @@ -1484,14 +1491,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 +1642,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. */ 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_curves.c b/source/blender/makesrna/intern/rna_curves.c index 17290d1c582..3d29add3427 100644 --- a/source/blender/makesrna/intern/rna_curves.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -60,12 +60,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 +86,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 +151,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 +317,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 +332,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_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index ff107d0b833..d277f2f7bd7 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -740,14 +740,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_layer.c b/source/blender/makesrna/intern/rna_layer.c index 6ab9d3a46ad..ae0366bebad 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,18 @@ 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; } #else @@ -442,6 +459,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_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index de3deea28ee..fc1e9414e7c 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1574,6 +1574,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); @@ -1587,6 +1600,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_PROP_FLOAT2); @@ -3559,7 +3585,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); @@ -3576,7 +3602,7 @@ 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); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index caeee35a80a..892d523bdcf 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1892,7 +1892,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, @@ -3585,7 +3585,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; @@ -7060,6 +7060,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); @@ -9614,6 +9615,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; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 90b93afee6c..ca3d34425b7 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -381,7 +381,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); } } @@ -497,12 +497,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 +2922,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}, }; diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 6967f78026a..c99c5fb723d 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,13 +192,9 @@ 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; } @@ -195,17 +202,9 @@ static bool rna_Object_holdout_get(Object *ob, bContext *C, ViewLayer *view_laye return ((base->flag & BASE_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_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..8d5e82cbfa8 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}, }; @@ -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..a1612159806 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -706,7 +706,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; @@ -1862,13 +1864,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 +1883,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 +2229,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 +2260,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) { @@ -6539,6 +6553,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. */ diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 42523508c14..a4298c8c3aa 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -165,6 +165,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 +186,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 +217,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 +378,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 +394,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 +494,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 +512,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,6 +532,7 @@ 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; diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index aa40ee846bf..ea508bf117c 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -2247,6 +2247,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); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 51acb4da5c3..9bbe37b5187 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -455,6 +455,9 @@ static const EnumPropertyItem rna_enum_view3dshading_render_pass_type_items[] = RNA_ENUM_ITEM_HEADING(N_("Data"), NULL), {EEVEE_RENDER_PASS_NORMAL, "NORMAL", 0, "Normal", ""}, {EEVEE_RENDER_PASS_MIST, "MIST", 0, "Mist", ""}, + {EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT, "CryptoObject", 0, "CryptoObject", ""}, + {EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET, "CryptoAsset", 0, "CryptoAsset", ""}, + {EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL, "CryptoMaterial", 0, "CryptoMaterial", ""}, RNA_ENUM_ITEM_HEADING(N_("Shader AOV"), NULL), {EEVEE_RENDER_PASS_AOV, "AOV", 0, "AOV", ""}, @@ -1423,6 +1426,7 @@ static const EnumPropertyItem *rna_3DViewShading_render_pass_itemf(bContext *C, const bool bloom_enabled = scene->eevee.flag & SCE_EEVEE_BLOOM_ENABLED; const bool aov_available = BKE_view_layer_has_valid_aov(view_layer); + const bool eevee_next_active = STREQ(scene->r.engine, "BLENDER_EEVEE_NEXT"); int totitem = 0; EnumPropertyItem *result = NULL; @@ -1443,6 +1447,12 @@ static const EnumPropertyItem *rna_3DViewShading_render_pass_itemf(bContext *C, aov_template.value++; } } + else if (ELEM(item->value, + EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT, + EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET, + EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL) && + !eevee_next_active) { + } else if (!((!bloom_enabled && (item->value == EEVEE_RENDER_PASS_BLOOM || STREQ(item->name, "Effects"))) || (!aov_available && STREQ(item->name, "Shader AOV")))) { @@ -1519,7 +1529,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); } } @@ -1663,7 +1673,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); @@ -1676,7 +1688,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); @@ -1872,6 +1886,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) @@ -2174,9 +2197,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; @@ -2249,7 +2274,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 */ @@ -3513,10 +3540,10 @@ 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}, }; @@ -3587,15 +3614,24 @@ 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, "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, "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, "use_custom_grid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CUSTOM_GRID); 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_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); @@ -3606,11 +3642,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); @@ -3980,6 +4014,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); @@ -5998,7 +6033,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); @@ -6311,7 +6346,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); @@ -6615,7 +6650,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); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 3b28dc70e9e..26849bfa622 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1235,7 +1235,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_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0031e023d39..b2f37ee2ae1 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -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) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index ac1803b0a11..7fd590005fd 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -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"); |