diff options
Diffstat (limited to 'source/blender/makesrna')
34 files changed, 619 insertions, 336 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index eb25733a88a..bc4e7314512 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -997,7 +997,7 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char * /** * Same as RNA_property_editable(), except this checks individual items in an array. */ -bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index); +bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, const int index); /** * Without lib check, only checks the flag. diff --git a/source/blender/makesrna/RNA_enum_items.h b/source/blender/makesrna/RNA_enum_items.h index 4b68416f5d7..31db8e39e6f 100644 --- a/source/blender/makesrna/RNA_enum_items.h +++ b/source/blender/makesrna/RNA_enum_items.h @@ -87,10 +87,11 @@ DEF_ENUM(rna_enum_keying_flag_items_api) DEF_ENUM(rna_enum_fmodifier_type_items) DEF_ENUM(rna_enum_motionpath_bake_location_items) +DEF_ENUM(rna_enum_motionpath_display_type_items) +DEF_ENUM(rna_enum_motionpath_range_items) -DEF_ENUM(rna_enum_event_value_all_items) -DEF_ENUM(rna_enum_event_value_keymouse_items) -DEF_ENUM(rna_enum_event_value_tweak_items) +DEF_ENUM(rna_enum_event_value_items) +DEF_ENUM(rna_enum_event_direction_items) DEF_ENUM(rna_enum_event_type_items) DEF_ENUM(rna_enum_event_type_mask_items) @@ -107,6 +108,7 @@ DEF_ENUM(rna_enum_brush_gpencil_types_items) DEF_ENUM(rna_enum_brush_gpencil_vertex_types_items) DEF_ENUM(rna_enum_brush_gpencil_sculpt_types_items) DEF_ENUM(rna_enum_brush_gpencil_weight_types_items) +DEF_ENUM(rna_enum_brush_curves_sculpt_tool_items); DEF_ENUM(rna_enum_brush_image_tool_items) DEF_ENUM(rna_enum_axis_xy_items) diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 90e979e9fbe..94ffa330064 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -35,7 +35,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""}, {ID_CA, "CAMERA", ICON_CAMERA_DATA, "Camera", ""}, {ID_CF, "CACHEFILE", ICON_FILE, "Cache File", ""}, - {ID_CU, "CURVE", ICON_CURVE_DATA, "Curve", ""}, + {ID_CU_LEGACY, "CURVE", ICON_CURVE_DATA, "Curve", ""}, {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""}, {ID_GD, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""}, {ID_GR, "COLLECTION", ICON_OUTLINER_COLLECTION, "Collection", ""}, @@ -126,7 +126,7 @@ const struct IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = { {FILTER_ID_BR, "filter_brush", ICON_BRUSH_DATA, "Brushes", "Show Brushes data-blocks"}, {FILTER_ID_CA, "filter_camera", ICON_CAMERA_DATA, "Cameras", "Show Camera data-blocks"}, {FILTER_ID_CF, "filter_cachefile", ICON_FILE, "Cache Files", "Show Cache File data-blocks"}, - {FILTER_ID_CU, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"}, + {FILTER_ID_CU_LEGACY, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"}, {FILTER_ID_GD, "filter_grease_pencil", ICON_GREASEPENCIL, @@ -348,7 +348,7 @@ short RNA_type_to_ID_code(const StructRNA *type) return ID_CA; } if (base_type == &RNA_Curve) { - return ID_CU; + return ID_CU_LEGACY; } if (base_type == &RNA_GreasePencil) { return ID_GD; @@ -472,7 +472,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) return &RNA_Camera; case ID_CF: return &RNA_CacheFile; - case ID_CU: + case ID_CU_LEGACY: return &RNA_Curve; case ID_GD: return &RNA_GreasePencil; @@ -696,7 +696,7 @@ static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages) } static ID *rna_ID_override_hierarchy_create( - ID *id, Main *bmain, Scene *scene, ViewLayer *view_layer, ID *id_reference) + ID *id, Main *bmain, Scene *scene, ViewLayer *view_layer, ID *id_instance_hint) { if (!ID_IS_OVERRIDABLE_LIBRARY(id)) { return NULL; @@ -706,7 +706,7 @@ static ID *rna_ID_override_hierarchy_create( ID *id_root_override = NULL; BKE_lib_override_library_create( - bmain, scene, view_layer, NULL, id, id_reference, &id_root_override); + bmain, scene, view_layer, NULL, id, id, id_instance_hint, &id_root_override); WM_main_add_notifier(NC_ID | NA_ADDED, NULL); WM_main_add_notifier(NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); @@ -2057,7 +2057,7 @@ static void rna_def_ID(BlenderRNA *brna) "reference", "ID", "", - "Another ID (usually an Object or Collection) used to decide where to " + "Another ID (usually an Object or Collection) used as a hint to decide where to " "instantiate the new overrides"); func = RNA_def_function(srna, "override_template_create", "rna_ID_override_template_create"); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 6c3b46c4408..7ccb8181b51 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1898,59 +1898,63 @@ int RNA_property_ui_icon(const PropertyRNA *prop) return rna_ensure_property((PropertyRNA *)prop)->icon; } -bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop_orig) +static bool rna_property_editable_do(PointerRNA *ptr, + PropertyRNA *prop_orig, + const int index, + const char **r_info) { ID *id = ptr->owner_id; - int flag; - const char *dummy_info; PropertyRNA *prop = rna_ensure_property(prop_orig); - flag = prop->editable ? prop->editable(ptr, &dummy_info) : prop->flag; - - return ( - (flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0 && - (!id || ((!ID_IS_LINKED(id) || (prop->flag & PROP_LIB_EXCEPTION)) && - (!ID_IS_OVERRIDE_LIBRARY(id) || RNA_property_overridable_get(ptr, prop_orig))))); -} - -bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info) -{ - ID *id = ptr->owner_id; - int flag; - - PropertyRNA *prop_type = rna_ensure_property(prop); - *r_info = ""; - /* get flag */ - if (prop_type->editable) { - flag = prop_type->editable(ptr, r_info); + const char *info = ""; + const int flag = (prop->itemeditable != NULL && index >= 0) ? + prop->itemeditable(ptr, index) : + (prop->editable != NULL ? prop->editable(ptr, &info) : prop->flag); + if (r_info != NULL) { + *r_info = info; } - else { - flag = prop_type->flag; - if ((flag & PROP_EDITABLE) == 0 || (flag & PROP_REGISTER)) { + + /* Early return if the property itself is not editable. */ + if ((flag & PROP_EDITABLE) == 0 || (flag & PROP_REGISTER) != 0) { + if (r_info != NULL && (*r_info)[0] == '\0') { *r_info = N_("This property is for internal use only and can't be edited"); } + return false; } - /* property from linked data-block */ - if (id) { - if (ID_IS_LINKED(id) && (prop_type->flag & PROP_LIB_EXCEPTION) == 0) { - if (!(*r_info)[0]) { - *r_info = N_("Can't edit this property from a linked data-block"); - } - return false; + /* If there is no owning ID, the property is editable at this point. */ + if (id == NULL) { + return true; + } + + /* Handle linked or liboverride ID cases. */ + const bool is_linked_prop_exception = (prop->flag & PROP_LIB_EXCEPTION) != 0; + if (ID_IS_LINKED(id) && !is_linked_prop_exception) { + if (r_info != NULL && (*r_info)[0] == '\0') { + *r_info = N_("Can't edit this property from a linked data-block"); } - if (ID_IS_OVERRIDE_LIBRARY(id)) { - if (!RNA_property_overridable_get(ptr, prop)) { - if (!(*r_info)[0]) { - *r_info = N_("Can't edit this property from an override data-block"); - } - return false; - } + return false; + } + if (ID_IS_OVERRIDE_LIBRARY(id) && !RNA_property_overridable_get(ptr, prop_orig)) { + if (r_info != NULL && (*r_info)[0] == '\0') { + *r_info = N_("Can't edit this property from an override data-block"); } + return false; } - return ((flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0); + /* At this point, property is owned by a local ID and therefore fully editable. */ + return true; +} + +bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) +{ + return rna_property_editable_do(ptr, prop, -1, NULL); +} + +bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info) +{ + return rna_property_editable_do(ptr, prop, -1, r_info); } bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop) @@ -1963,29 +1967,11 @@ bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop) return (flag & PROP_EDITABLE) != 0; } -bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) +bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, const int index) { - ID *id; - int flag; - BLI_assert(index >= 0); - prop = rna_ensure_property(prop); - - flag = prop->flag; - - if (prop->editable) { - const char *dummy_info; - flag &= prop->editable(ptr, &dummy_info); - } - - if (prop->itemeditable) { - flag &= prop->itemeditable(ptr, index); - } - - id = ptr->owner_id; - - return (flag & PROP_EDITABLE) && (!id || !ID_IS_LINKED(id) || (prop->flag & PROP_LIB_EXCEPTION)); + return rna_property_editable_do(ptr, prop, index, NULL); } bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) @@ -4918,7 +4904,7 @@ static char *rna_path_token_in_brackets(const char **path, } /** - * \return true when when the key in the path is correctly parsed and found in the collection + * \return true when the key in the path is correctly parsed and found in the collection * or when the path is empty. */ static bool rna_path_parse_collection_key(const char **path, diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 1aa51c93ee8..fd65cc464f2 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -218,7 +218,7 @@ bool RNA_property_copy( /* IDprops: destination may not exist, if source does and is set, try to create it. */ /* NOTE: this is sort of quick hack/bandage to fix the issue, - * we need to rethink how IDProps are handled in 'diff' RNA code completely, imho... */ + * we need to rethink how IDProps are handled in 'diff' RNA code completely, IMHO. */ if (prop_src != NULL && prop_dst == NULL && RNA_property_is_set(fromptr, prop)) { BLI_assert(prop_src->magic != RNA_MAGIC); IDProperty *idp_dst = RNA_struct_idprops(ptr, true); diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c index cb993931296..0453b327b45 100644 --- a/source/blender/makesrna/intern/rna_animviz.c +++ b/source/blender/makesrna/intern/rna_animviz.c @@ -36,6 +36,27 @@ const EnumPropertyItem rna_enum_motionpath_bake_location_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_motionpath_display_type_items[] = { + {MOTIONPATH_TYPE_ACFRA, + "CURRENT_FRAME", + 0, + "Around Frame", + "Display Paths of poses within a fixed number of frames around the current frame"}, + {MOTIONPATH_TYPE_RANGE, + "RANGE", + 0, + "In Range", + "Display Paths of poses within specified range"}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_motionpath_range_items[] = { + {MOTIONPATH_RANGE_KEYS_ALL, "KEYS_ALL", 0, "All keys range", ""}, + {MOTIONPATH_RANGE_KEYS_SELECTED, "KEYS_SELECTED", 0, "Selected keys range", ""}, + {MOTIONPATH_RANGE_SCENE, "SCENE", 0, "Scene frame range", ""}, + {0, NULL, 0, NULL, NULL}, +}; + #ifdef RNA_RUNTIME static PointerRNA rna_AnimViz_motion_paths_get(PointerRNA *ptr) @@ -173,20 +194,6 @@ static void rna_def_animviz_paths(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const EnumPropertyItem prop_type_items[] = { - {MOTIONPATH_TYPE_ACFRA, - "CURRENT_FRAME", - 0, - "Around Frame", - "Display Paths of poses within a fixed number of frames around the current frame"}, - {MOTIONPATH_TYPE_RANGE, - "RANGE", - 0, - "In Range", - "Display Paths of poses within specified range"}, - {0, NULL, 0, NULL, NULL}, - }; - srna = RNA_def_struct(brna, "AnimVizMotionPaths", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); RNA_def_struct_nested(brna, srna, "AnimViz"); @@ -198,10 +205,16 @@ static void rna_def_animviz_paths(BlenderRNA *brna) /* Enums */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "path_type"); - RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_enum_items(prop, rna_enum_motionpath_display_type_items); RNA_def_property_ui_text(prop, "Paths Type", "Type of range to show for Motion Paths"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW_ANIMVIZ, NULL); + prop = RNA_def_property(srna, "range", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "path_range"); + RNA_def_property_enum_items(prop, rna_enum_motionpath_range_items); + RNA_def_property_ui_text(prop, "Paths Range", "Type of range to calculate for Motion Paths"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW_ANIMVIZ, NULL); + prop = RNA_def_property(srna, "bake_location", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "path_bakeflag"); RNA_def_property_enum_items(prop, rna_enum_motionpath_bake_location_items); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index f3c7d2747ac..667114a3598 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -243,6 +243,12 @@ const EnumPropertyItem rna_enum_brush_gpencil_weight_types_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_brush_curves_sculpt_tool_items[] = { + {CURVES_SCULPT_TOOL_TEST1, "TEST1", ICON_NONE, "Test 1", ""}, + {CURVES_SCULPT_TOOL_TEST2, "TEST2", ICON_NONE, "Test 2", ""}, + {0, NULL, 0, NULL, NULL}, +}; + #ifndef RNA_RUNTIME static EnumPropertyItem rna_enum_gpencil_brush_eraser_modes_items[] = { {GP_BRUSH_ERASER_SOFT, @@ -2312,6 +2318,11 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Grease Pencil Weight Paint Tool", ""); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "curves_sculpt_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_enum_brush_curves_sculpt_tool_items); + RNA_def_property_ui_text(prop, "Curves Sculpt Tool", ""); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + /** End per mode tool properties. */ prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index edcf121a8c4..114fe30acf7 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -2969,7 +2969,7 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem splineik_xz_scale_mode[] = { - {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes (Default)"}, + {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes"}, {CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index bc4bd9ad3d6..e723be2ab71 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -21,6 +21,7 @@ const EnumPropertyItem rna_enum_context_mode_items[] = { {CTX_MODE_EDIT_MESH, "EDIT_MESH", 0, "Mesh Edit", ""}, {CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""}, + {CTX_MODE_EDIT_CURVES, "EDIT_CURVES", 0, "Curves Edit", ""}, {CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""}, {CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Text Edit", ""}, /* PARSKEL reuse will give issues */ diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index b37a6e5fd0e..891de95a2a2 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -441,7 +441,7 @@ static void rna_Curve_bevelObject_set(PointerRNA *ptr, if (ob) { /* If bevel object has got the save curve, as object, for which it's set as bevobj, * there could be infinity loop in #DispList calculation. */ - if (ob->type == OB_CURVE && ob->data != cu) { + if (ob->type == OB_CURVES_LEGACY && ob->data != cu) { cu->bevobj = ob; id_lib_extern((ID *)ob); } @@ -486,7 +486,7 @@ static bool rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)value.data; if (ob) { - if (ob->type == OB_CURVE && ob->data != cu) { + if (ob->type == OB_CURVES_LEGACY && ob->data != cu) { return 1; } } @@ -516,7 +516,7 @@ static void rna_Curve_taperObject_set(PointerRNA *ptr, if (ob) { /* If taper object has got the save curve, as object, for which it's set as bevobj, * there could be infinity loop in #DispList calculation. */ - if (ob->type == OB_CURVE && ob->data != cu) { + if (ob->type == OB_CURVES_LEGACY && ob->data != cu) { cu->taperobj = ob; id_lib_extern((ID *)ob); } diff --git a/source/blender/makesrna/intern/rna_curves.c b/source/blender/makesrna/intern/rna_curves.c index 8e7fb415c7d..7a1a368551f 100644 --- a/source/blender/makesrna/intern/rna_curves.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -16,6 +16,8 @@ #include "BLI_math_base.h" #include "BLI_string.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME # include "BLI_math_vector.h" @@ -43,7 +45,7 @@ static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter, { const Curves *curves = rna_curves(ptr); rna_iterator_array_begin(iter, - (void *)curves->geometry.offsets, + (void *)curves->geometry.curve_offsets, sizeof(int), curves->geometry.curve_size + 1, false, @@ -95,7 +97,7 @@ static char *rna_CurvePoint_path(PointerRNA *ptr) static int rna_CurveSlice_index_get(PointerRNA *ptr) { Curves *curves = rna_curves(ptr); - return (int)((int *)ptr->data - curves->geometry.offsets); + return (int)((int *)ptr->data - curves->geometry.curve_offsets); } static char *rna_CurveSlice_path(PointerRNA *ptr) @@ -220,7 +222,7 @@ static void rna_def_curves(BlenderRNA *brna) /* Point and Curve RNA API helpers. */ prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", "geometry.curve_size"); + RNA_def_property_collection_sdna(prop, NULL, "geometry.curve_offsets", "geometry.curve_size"); RNA_def_property_struct_type(prop, "CurveSlice"); RNA_def_property_ui_text(prop, "Curves", "All curves in the data-block"); @@ -243,7 +245,7 @@ static void rna_def_curves(BlenderRNA *brna) RNA_define_verify_sdna(1); prop = RNA_def_property(srna, "curve_offset_data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", NULL); + RNA_def_property_collection_sdna(prop, NULL, "geometry.curve_offsets", NULL); RNA_def_property_struct_type(prop, "IntAttributeValue"); RNA_def_property_collection_funcs(prop, "rna_Curves_curve_offset_data_begin", @@ -265,6 +267,13 @@ static void rna_def_curves(BlenderRNA *brna) RNA_def_property_collection_funcs( prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); + prop = RNA_def_property(srna, "surface", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); + RNA_def_property_ui_text(prop, "Surface", "Mesh object that the curves can be attached to"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + /* attributes */ rna_def_attributes_common(srna); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 850accd0b24..5127b418b7f 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -4391,24 +4391,21 @@ void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropert if (tot == 0) { *items = MEM_callocN(sizeof(EnumPropertyItem[8]), __func__); + /* Ensure we get crashes on missing calls to 'RNA_enum_item_end', see T74227. */ +#ifdef DEBUG + memset(*items, 0xff, sizeof(EnumPropertyItem[8])); +#endif } else if (tot >= 8 && (tot & (tot - 1)) == 0) { /* power of two > 8 */ *items = MEM_recallocN_id(*items, sizeof(EnumPropertyItem) * tot * 2, __func__); +#ifdef DEBUG + memset((*items) + tot, 0xff, sizeof(EnumPropertyItem) * tot); +#endif } (*items)[tot] = *item; *totitem = tot + 1; - - /* Ensure we get crashes on missing calls to 'RNA_enum_item_end', see T74227. */ -#ifdef DEBUG - static const EnumPropertyItem item_error = { - -1, POINTER_FROM_INT(-1), -1, POINTER_FROM_INT(-1), POINTER_FROM_INT(-1)}; - if (item != &item_error) { - RNA_enum_item_add(items, totitem, &item_error); - *totitem -= 1; - } -#endif } void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index f24803af654..8f418fcc7c7 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -1880,7 +1880,7 @@ static void rna_def_drivervar(BlenderRNA *brna) "SINGLE_PROP", ICON_RNA, "Single Property", - "Use the value from some RNA property (Default)"}, + "Use the value from some RNA property"}, {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", ICON_DRIVER_TRANSFORM, diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 6a0e5156234..a619d179a33 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -1223,6 +1223,14 @@ static void rna_def_modifier_gpencilsimplify(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Length", "Length of each segment"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "sharp_threshold", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "sharp_threshold"); + RNA_def_property_range(prop, 0, M_PI); + RNA_def_property_ui_range(prop, 0, M_PI, 1.0, 1); + RNA_def_property_ui_text( + prop, "Sharp Threshold", "Preserve corners that have sharper angle than this threshold"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + /* Merge */ prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "distance"); @@ -2482,7 +2490,8 @@ static void rna_def_modifier_gpencilhook(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, modifier_gphook_falloff_items); /* share the enum */ RNA_def_property_ui_text(prop, "Falloff Type", ""); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index e40fafd2069..56e23278176 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -103,6 +103,7 @@ static void rna_Image_generated_update(Main *bmain, Scene *UNUSED(scene), Pointe { Image *ima = (Image *)ptr->owner_id; BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE); + BKE_image_partial_update_mark_full_update(ima); } static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -141,6 +142,7 @@ static void rna_Image_views_format_update(Main *bmain, Scene *scene, PointerRNA } BKE_image_release_ibuf(ima, ibuf, lock); + BKE_image_partial_update_mark_full_update(ima); } static void rna_ImageUser_update(Main *bmain, Scene *scene, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 2c5f264f7e9..44bf51d9770 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -649,7 +649,7 @@ const char *rna_translate_ui_text(const char *text, struct PropertyRNA *prop, bool translate); -/* Internal functions that cycles uses so we need to declare (tsk tsk) */ +/* Internal functions that cycles uses so we need to declare (tsk!). */ void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values); #ifdef RNA_RUNTIME diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 51dcfd13657..7687dcbb11f 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -47,7 +47,7 @@ static Key *rna_ShapeKey_find_key(ID *id) { switch (GS(id->name)) { - case ID_CU: + case ID_CU_LEGACY: return ((Curve *)id)->key; case ID_KE: return (Key *)id; @@ -556,7 +556,7 @@ static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA KeyBlock *kb = (KeyBlock *)ptr->data; int tot = kb->totelem, size = key->elemsize; - if (GS(key->from->name) == ID_CU && tot > 0) { + if (GS(key->from->name) == ID_CU_LEGACY && tot > 0) { Curve *cu = (Curve *)key->from; StructRNA *type = NULL; NurbInfo info = {0}; @@ -593,7 +593,7 @@ static int rna_ShapeKey_data_length(PointerRNA *ptr) KeyBlock *kb = (KeyBlock *)ptr->data; int tot = kb->totelem; - if (GS(key->from->name) == ID_CU) { + if (GS(key->from->name) == ID_CU_LEGACY) { tot = rna_ShapeKey_curve_find_index(key, tot); } @@ -613,7 +613,7 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter) return rna_pointer_inherit_refine(&iter->parent, point->type, point->data); } - if (GS(key->from->name) == ID_CU) { + if (GS(key->from->name) == ID_CU_LEGACY) { Curve *cu = (Curve *)key->from; type = rna_ShapeKey_curve_point_type(cu->nurb.first); @@ -635,7 +635,7 @@ int rna_ShapeKey_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) return false; } - if (GS(key->from->name) == ID_CU) { + if (GS(key->from->name) == ID_CU_LEGACY) { NurbInfo info; rna_ShapeKey_NurbInfo_find_index(key, index, false, &info); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index e9d39d708a9..b239260c8eb 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -322,7 +322,7 @@ static Mesh *rna_Main_meshes_new_from_object(Main *bmain, { switch (object->type) { case OB_FONT: - case OB_CURVE: + case OB_CURVES_LEGACY: case OB_SURF: case OB_MBALL: case OB_MESH: @@ -822,7 +822,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(screens, screens, ID_SCR) RNA_MAIN_ID_TAG_FUNCS_DEF(window_managers, wm, ID_WM) RNA_MAIN_ID_TAG_FUNCS_DEF(images, images, ID_IM) RNA_MAIN_ID_TAG_FUNCS_DEF(lattices, lattices, ID_LT) -RNA_MAIN_ID_TAG_FUNCS_DEF(curves, curves, ID_CU) +RNA_MAIN_ID_TAG_FUNCS_DEF(curves, curves, ID_CU_LEGACY) RNA_MAIN_ID_TAG_FUNCS_DEF(metaballs, metaballs, ID_MB) RNA_MAIN_ID_TAG_FUNCS_DEF(fonts, fonts, ID_VF) RNA_MAIN_ID_TAG_FUNCS_DEF(textures, textures, ID_TE) diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index e8b8c6e3274..2247a16a7a0 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -1025,7 +1025,8 @@ static void rna_def_mask_layer(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "falloff"); RNA_def_property_enum_items(prop, rna_enum_proportional_falloff_curve_only_items); RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL); /* filling options */ diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 6b3ae373295..87459587a9e 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -456,6 +456,7 @@ static void rna_MeshPolygon_flip(ID *id, MPoly *mp) BKE_mesh_polygon_flip(mp, me->mloop, &me->ldata); BKE_mesh_tessface_clear(me); BKE_mesh_runtime_clear_geometry(me); + BKE_mesh_normals_tag_dirty(me); } static void rna_MeshLoopTriangle_verts_get(PointerRNA *ptr, int *values) diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index ebacced8b3f..8447074a3ef 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -167,7 +167,7 @@ static void rna_Mesh_flip_normals(Mesh *mesh) { BKE_mesh_polygons_flip(mesh->mpoly, mesh->mloop, &mesh->ldata, mesh->totpoly); BKE_mesh_tessface_clear(mesh); - BKE_mesh_calc_normals(mesh); + BKE_mesh_normals_tag_dirty(mesh); BKE_mesh_runtime_clear_geometry(mesh); DEG_id_tag_update(&mesh->id, 0); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 45d22981205..b12b33c67af 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -869,10 +869,10 @@ static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRN RNA_MOD_OBJECT_SET(Armature, object, OB_ARMATURE); RNA_MOD_OBJECT_SET(Array, start_cap, OB_MESH); RNA_MOD_OBJECT_SET(Array, end_cap, OB_MESH); -RNA_MOD_OBJECT_SET(Array, curve_ob, OB_CURVE); +RNA_MOD_OBJECT_SET(Array, curve_ob, OB_CURVES_LEGACY); RNA_MOD_OBJECT_SET(Boolean, object, OB_MESH); RNA_MOD_OBJECT_SET(Cast, object, OB_EMPTY); -RNA_MOD_OBJECT_SET(Curve, object, OB_CURVE); +RNA_MOD_OBJECT_SET(Curve, object, OB_CURVES_LEGACY); RNA_MOD_OBJECT_SET(DataTransfer, ob_source, OB_MESH); RNA_MOD_OBJECT_SET(Lattice, object, OB_LATTICE); RNA_MOD_OBJECT_SET(Mask, ob_arm, OB_ARMATURE); @@ -1849,7 +1849,8 @@ static void rna_def_modifier_warp(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, modifier_warp_falloff_items); RNA_def_property_ui_text(prop, "Falloff Type", ""); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); @@ -2567,7 +2568,8 @@ static void rna_def_modifier_hook(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, modifier_warp_falloff_items); /* share the enum */ RNA_def_property_ui_text(prop, "Falloff Type", ""); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); @@ -4947,6 +4949,7 @@ static void rna_def_modifier_uvwarp(BlenderRNA *brna) static void rna_def_modifier_weightvg_mask(BlenderRNA *UNUSED(brna), StructRNA *srna, const char *mask_flags, + const int invert_vgroup_mask_flag, const char *mask_vgroup_setter, const char *mask_uvlayer_setter) { @@ -4992,7 +4995,7 @@ static void rna_def_modifier_weightvg_mask(BlenderRNA *UNUSED(brna), RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "invert_mask_vertex_group", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, mask_flags, MOD_WVG_EDIT_INVERT_VGROUP_MASK); + RNA_def_property_boolean_sdna(prop, NULL, mask_flags, invert_vgroup_mask_flag); RNA_def_property_ui_text(prop, "Invert", "Invert vertex group mask influence"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -5076,7 +5079,8 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, weightvg_edit_falloff_type_items); RNA_def_property_ui_text(prop, "Falloff Type", "How weights are mapped to their new values"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "invert_falloff", PROP_BOOLEAN, PROP_NONE); @@ -5148,6 +5152,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) rna_def_modifier_weightvg_mask(brna, srna, "edit_flags", + MOD_WVG_EDIT_INVERT_VGROUP_MASK, "rna_WeightVGEditModifier_mask_defgrp_name_set", "rna_WeightVGEditModifier_mask_tex_uvlayer_name_set"); } @@ -5166,6 +5171,8 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna) "Difference", "Difference between VGroup A's and VGroup B's weights"}, {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weights"}, + {MOD_WVG_MIX_MIN, "MIN", 0, "Minimum", "Minimum of VGroup A's and VGroup B's weights"}, + {MOD_WVG_MIX_MAX, "MAX", 0, "Maximum", "Maximum of VGroup A's and VGroup B's weights"}, {0, NULL, 0, NULL, NULL}, }; @@ -5263,6 +5270,7 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna) rna_def_modifier_weightvg_mask(brna, srna, "flag", + MOD_WVG_MIX_INVERT_VGROUP_MASK, "rna_WeightVGMixModifier_mask_defgrp_name_set", "rna_WeightVGMixModifier_mask_tex_uvlayer_name_set"); } @@ -5364,7 +5372,8 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna) prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, weightvg_proximity_falloff_type_items); RNA_def_property_ui_text(prop, "Falloff Type", "How weights are mapped to their new values"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "invert_falloff", PROP_BOOLEAN, PROP_NONE); @@ -5392,6 +5401,7 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna) rna_def_modifier_weightvg_mask(brna, srna, "proximity_flags", + MOD_WVG_PROXIMITY_INVERT_VGROUP_MASK, "rna_WeightVGProximityModifier_mask_defgrp_name_set", "rna_WeightVGProximityModifier_mask_tex_uvlayer_name_set"); } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 3ae9ab3cec2..387166e77b4 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -7196,7 +7196,8 @@ static void def_cmp_dilate_erode(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "falloff"); RNA_def_property_enum_items(prop, rna_enum_proportional_falloff_curve_only_items); RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -8974,7 +8975,8 @@ static void def_cmp_keying(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "feather_falloff"); RNA_def_property_enum_items(prop, rna_enum_proportional_falloff_curve_only_items); RNA_def_property_ui_text(prop, "Feather Falloff", "Falloff type the feather"); - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */ + RNA_def_property_translation_context(prop, + BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "feather_distance", PROP_INT, PROP_NONE); @@ -11285,6 +11287,27 @@ static void def_geo_delete_geometry(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_geo_duplicate_elements(StructRNA *srna) +{ + PropertyRNA *prop; + + static const EnumPropertyItem domain_items[] = { + {ATTR_DOMAIN_POINT, "POINT", 0, "Point", ""}, + {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", ""}, + {ATTR_DOMAIN_FACE, "FACE", 0, "Face", ""}, + {ATTR_DOMAIN_CURVE, "SPLINE", 0, "Spline", ""}, + {ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", ""}, + {0, NULL, 0, NULL, NULL}, + }; + RNA_def_struct_sdna_from(srna, "NodeGeometryDuplicateElements", "storage"); + + prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, domain_items); + RNA_def_property_enum_default(prop, ATTR_DOMAIN_POINT); + RNA_def_property_ui_text(prop, "Domain", "Which domain to duplicate"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + static void def_geo_string_to_curves(StructRNA *srna) { static const EnumPropertyItem rna_node_geometry_string_to_curves_overflow_items[] = { diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9c4ebf79a08..c598e63a32a 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -241,7 +241,7 @@ const EnumPropertyItem rna_enum_lightprobes_type_items[] = { /* used for 2 enums */ #define OBTYPE_CU_CURVE \ { \ - OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve", "" \ + OB_CURVES_LEGACY, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve", "" \ } #define OBTYPE_CU_SURF \ { \ @@ -479,7 +479,7 @@ static void rna_Object_active_shape_update(Main *bmain, Scene *UNUSED(scene), Po BKE_editmesh_looptri_and_normals_calc(em); break; } - case OB_CURVE: + case OB_CURVES_LEGACY: case OB_SURF: ED_curve_editnurb_load(bmain, ob); ED_curve_editnurb_make(ob); @@ -571,7 +571,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value, struct Report ob->data = id; BKE_object_materials_test(G_MAIN, ob, id); - if (GS(id->name) == ID_CU) { + if (GS(id->name) == ID_CU_LEGACY) { BKE_curve_type_test(ob); } else if (ob->type == OB_ARMATURE) { @@ -590,7 +590,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) return &RNA_Image; case OB_MESH: return &RNA_Mesh; - case OB_CURVE: + case OB_CURVES_LEGACY: return &RNA_Curve; case OB_SURF: return &RNA_Curve; @@ -2182,7 +2182,7 @@ bool rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) bool rna_Curve_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { - return ((Object *)value.owner_id)->type == OB_CURVE; + return ((Object *)value.owner_id)->type == OB_CURVES_LEGACY; } bool rna_Armature_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 9676be69d05..ece1c5e5815 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -407,7 +407,7 @@ static Mesh *rna_Object_to_mesh(Object *object, * rna_Main_meshes_new_from_object. */ switch (object->type) { case OB_FONT: - case OB_CURVE: + case OB_CURVES_LEGACY: case OB_SURF: case OB_MBALL: case OB_MESH: @@ -430,7 +430,7 @@ static Curve *rna_Object_to_curve(Object *object, Depsgraph *depsgraph, bool apply_modifiers) { - if (!ELEM(object->type, OB_FONT, OB_CURVE)) { + if (!ELEM(object->type, OB_FONT, OB_CURVES_LEGACY)) { BKE_report(reports, RPT_ERROR, "Object is not a curve or a text"); return NULL; } @@ -785,7 +785,7 @@ bool rna_Object_generate_gpencil_strokes(Object *ob, float scale_thickness, float sample) { - if (ob->type != OB_CURVE) { + if (ob->type != OB_CURVES_LEGACY) { BKE_reportf(reports, RPT_ERROR, "Object '%s' is not valid for this operation! Only curves are supported", diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 9ca78033199..8579f188428 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -691,7 +691,7 @@ static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, Point rna_FieldSettings_shape_update(bmain, scene, ptr); - if (ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE) { + if (ob->type == OB_CURVES_LEGACY && ob->pd->forcefield == PFIELD_GUIDE) { DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); } else { @@ -899,7 +899,7 @@ static const EnumPropertyItem *rna_Effector_shape_itemf(bContext *UNUSED(C), ob = (Object *)ptr->owner_id; - if (ob->type == OB_CURVE) { + if (ob->type == OB_CURVES_LEGACY) { if (ob->pd->forcefield == PFIELD_VORTEX) { return curve_vortex_shape_items; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 178029ef340..29b06060256 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1466,18 +1466,6 @@ static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, bool value) else { rd->ffcodecdata.flags &= ~FFMPEG_LOSSLESS_OUTPUT; } - - BKE_ffmpeg_codec_settings_verify(rd); -} - -static void rna_FFmpegSettings_codec_settings_update(Main *UNUSED(bmain), - Scene *UNUSED(scene_unused), - PointerRNA *ptr) -{ - Scene *scene = (Scene *)ptr->owner_id; - RenderData *rd = &scene->r; - - BKE_ffmpeg_codec_settings_verify(rd); } # endif @@ -1659,7 +1647,7 @@ static void rna_Scene_mesh_quality_update(Main *bmain, Scene *UNUSED(scene), Poi Scene *scene = (Scene *)ptr->owner_id; FOREACH_SCENE_OBJECT_BEGIN (scene, ob) { - if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_VOLUME, OB_MBALL)) { + if (ELEM(ob->type, OB_MESH, OB_CURVES_LEGACY, OB_VOLUME, OB_MBALL)) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } } @@ -2910,6 +2898,10 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Sculpt"); RNA_def_property_ui_text(prop, "Sculpt", ""); + prop = RNA_def_property(srna, "curves_sculpt", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "CurvesSculpt"); + RNA_def_property_ui_text(prop, "Curves Sculpt", ""); + prop = RNA_def_property(srna, "use_auto_normalize", PROP_BOOLEAN, PROP_NONE); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "auto_normalize", 1); @@ -3072,7 +3064,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Proportional Editing Falloff", "Falloff type for proportional editing mode"); /* Abusing id_curve :/ */ - RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE_LEGACY); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "proportional_size", PROP_FLOAT, PROP_DISTANCE); @@ -5727,8 +5719,6 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, ffmpeg_format_items); RNA_def_property_enum_default(prop, FFMPEG_MKV); RNA_def_property_ui_text(prop, "Container", "Output file container"); - RNA_def_property_update( - prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); prop = RNA_def_property(srna, "codec", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "codec"); @@ -5736,8 +5726,6 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, ffmpeg_codec_items); RNA_def_property_enum_default(prop, AV_CODEC_ID_H264); RNA_def_property_ui_text(prop, "Video Codec", "FFmpeg codec to use for video output"); - RNA_def_property_update( - prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); prop = RNA_def_property(srna, "video_bitrate", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "video_bitrate"); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 1e7c67ef95e..473711fb74b 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -352,6 +352,12 @@ static bool rna_Brush_mode_with_tool_poll(PointerRNA *ptr, PointerRNA value) } mode = OB_MODE_WEIGHT_GPENCIL; } + else if (paint_contains_brush_slot(&ts->curves_sculpt->paint, tslot, &slot_index)) { + if (slot_index != brush->curves_sculpt_tool) { + return false; + } + mode = OB_MODE_SCULPT_CURVES; + } return brush->ob_mode & mode; } @@ -417,6 +423,11 @@ static char *rna_UvSculpt_path(PointerRNA *UNUSED(ptr)) return BLI_strdup("tool_settings.uv_sculpt"); } +static char *rna_CurvesSculpt_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_strdup("tool_settings.curves_sculpt"); +} + static char *rna_GpPaint_path(PointerRNA *UNUSED(ptr)) { return BLI_strdup("tool_settings.gpencil_paint"); @@ -1492,6 +1503,15 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); } +static void rna_def_curves_sculpt(BlenderRNA *brna) +{ + StructRNA *srna; + + srna = RNA_def_struct(brna, "CurvesSculpt", "Paint"); + RNA_def_struct_path_func(srna, "rna_CurvesSculpt_path"); + RNA_def_struct_ui_text(srna, "Curves Sculpt Paint", ""); +} + void RNA_def_sculpt_paint(BlenderRNA *brna) { /* *** Non-Animated *** */ @@ -1510,6 +1530,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna) rna_def_particle_edit(brna); rna_def_gpencil_guides(brna); rna_def_gpencil_sculpt(brna); + rna_def_curves_sculpt(brna); RNA_define_animate_sdna(true); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index c51f0c00498..2344aa42838 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3263,8 +3263,8 @@ static struct IDFilterEnumPropertyItem rna_enum_space_file_id_filter_categories[ ICON_OUTLINER_COLLECTION, "Objects & Collections", "Show objects and collections"}, - {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_CV | - FILTER_ID_PT | FILTER_ID_VO, + {FILTER_ID_AR | FILTER_ID_CU_LEGACY | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | + FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO, "category_geometry", ICON_NODETREE, "Geometry", @@ -4959,7 +4959,9 @@ static void rna_def_space_view3d(BlenderRNA *brna) const char *identifier[2]; } info[] = { {"Mesh", (1 << OB_MESH), {"show_object_viewport_mesh", "show_object_select_mesh"}}, - {"Curve", (1 << OB_CURVE), {"show_object_viewport_curve", "show_object_select_curve"}}, + {"Curve", + (1 << OB_CURVES_LEGACY), + {"show_object_viewport_curve", "show_object_select_curve"}}, {"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}}, {"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}}, {"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}}, @@ -5467,7 +5469,7 @@ static void rna_def_space_sequencer_preview_overlay(BlenderRNA *brna) prop = RNA_def_property(srna, "show_cursor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_PREVIEW_SHOW_2D_CURSOR); - RNA_def_property_ui_text(prop, "2D cursor", ""); + RNA_def_property_ui_text(prop, "2D Cursor", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index e32bedf3ed0..2a759dde39a 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -6040,6 +6040,13 @@ static void rna_def_userdef_input(BlenderRNA *brna) "Helicopter Mode", "Device up/down directly controls the Z position of the 3D viewport"); + prop = RNA_def_property(srna, "ndof_lock_camera_pan_zoom", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_CAMERA_PAN_ZOOM); + RNA_def_property_ui_text( + prop, + "Lock Camera Pan/Zoom", + "Pan/zoom the camera view instead of leaving the camera view when orbiting"); + /* let Python know whether NDOF is enabled */ prop = RNA_def_boolean(srna, "use_ndof", true, "", ""); # else diff --git a/source/blender/makesrna/intern/rna_volume.c b/source/blender/makesrna/intern/rna_volume.c index ca3b09c61c5..5b323629a80 100644 --- a/source/blender/makesrna/intern/rna_volume.c +++ b/source/blender/makesrna/intern/rna_volume.c @@ -26,7 +26,6 @@ const EnumPropertyItem rna_enum_volume_grid_data_type_items[] = { {VOLUME_GRID_INT, "INT", 0, "Integer", "32-bit integer"}, {VOLUME_GRID_INT64, "INT64", 0, "Integer 64-bit", "64-bit integer"}, {VOLUME_GRID_MASK, "MASK", 0, "Mask", "No data, boolean mask of active voxels"}, - {VOLUME_GRID_STRING, "STRING", 0, "String", "Text string"}, {VOLUME_GRID_VECTOR_FLOAT, "VECTOR_FLOAT", 0, "Float Vector", "3D float vector"}, {VOLUME_GRID_VECTOR_DOUBLE, "VECTOR_DOUBLE", 0, "Double Vector", "3D double vector"}, {VOLUME_GRID_VECTOR_INT, "VECTOR_INT", 0, "Integer Vector", "3D integer vector"}, diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index b0021bd0f3d..8835591f303 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -28,13 +28,6 @@ #ifdef RNA_RUNTIME -static const EnumPropertyItem event_tweak_type_items[] = { - {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""}, - {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""}, - {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""}, - {0, NULL, 0, NULL, NULL}, -}; - static const EnumPropertyItem event_mouse_type_items[] = { {LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""}, {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""}, @@ -156,10 +149,6 @@ const EnumPropertyItem rna_enum_event_type_items[] = { {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", "WhIn"}, {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", "WhOut"}, {0, "", 0, NULL, NULL}, - {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", "TwkL"}, - {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", "TwkM"}, - {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", "TwkR"}, - {0, "", 0, NULL, NULL}, {EVT_AKEY, "A", 0, "A", ""}, {EVT_BKEY, "B", 0, "B", ""}, {EVT_CKEY, "C", 0, "C", ""}, @@ -362,26 +351,7 @@ const EnumPropertyItem rna_enum_event_type_items[] = { * This is needed for `km.keymap_items.new` value argument, * to accept values from different types. */ -const EnumPropertyItem rna_enum_event_value_all_items[] = { - {KM_ANY, "ANY", 0, "Any", ""}, - {KM_PRESS, "PRESS", 0, "Press", ""}, - {KM_RELEASE, "RELEASE", 0, "Release", ""}, - {KM_CLICK, "CLICK", 0, "Click", ""}, - {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""}, - {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""}, - {EVT_GESTURE_N, "NORTH", 0, "North", ""}, - {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""}, - {EVT_GESTURE_E, "EAST", 0, "East", ""}, - {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""}, - {EVT_GESTURE_S, "SOUTH", 0, "South", ""}, - {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""}, - {EVT_GESTURE_W, "WEST", 0, "West", ""}, - {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""}, - {KM_NOTHING, "NOTHING", 0, "Nothing", ""}, - {0, NULL, 0, NULL, NULL}, -}; - -const EnumPropertyItem rna_enum_event_value_keymouse_items[] = { +const EnumPropertyItem rna_enum_event_value_items[] = { {KM_ANY, "ANY", 0, "Any", ""}, {KM_PRESS, "PRESS", 0, "Press", ""}, {KM_RELEASE, "RELEASE", 0, "Release", ""}, @@ -393,16 +363,16 @@ const EnumPropertyItem rna_enum_event_value_keymouse_items[] = { {0, NULL, 0, NULL, NULL}, }; -const EnumPropertyItem rna_enum_event_value_tweak_items[] = { +const EnumPropertyItem rna_enum_event_direction_items[] = { {KM_ANY, "ANY", 0, "Any", ""}, - {EVT_GESTURE_N, "NORTH", 0, "North", ""}, - {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""}, - {EVT_GESTURE_E, "EAST", 0, "East", ""}, - {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""}, - {EVT_GESTURE_S, "SOUTH", 0, "South", ""}, - {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""}, - {EVT_GESTURE_W, "WEST", 0, "West", ""}, - {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""}, + {KM_DIRECTION_N, "NORTH", 0, "North", ""}, + {KM_DIRECTION_NE, "NORTH_EAST", 0, "North-East", ""}, + {KM_DIRECTION_E, "EAST", 0, "East", ""}, + {KM_DIRECTION_SE, "SOUTH_EAST", 0, "South-East", ""}, + {KM_DIRECTION_S, "SOUTH", 0, "South", ""}, + {KM_DIRECTION_SW, "SOUTH_WEST", 0, "South-West", ""}, + {KM_DIRECTION_W, "WEST", 0, "West", ""}, + {KM_DIRECTION_NW, "NORTH_WEST", 0, "North-West", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -420,7 +390,6 @@ const EnumPropertyItem rna_enum_event_type_mask_items[] = { {EVT_TYPE_MASK_MOUSE_BUTTON, "MOUSE_BUTTON", 0, "Mouse Button", ""}, {EVT_TYPE_MASK_MOUSE, "MOUSE", 0, "Mouse", ""}, {EVT_TYPE_MASK_NDOF, "NDOF", 0, "NDOF", ""}, - {EVT_TYPE_MASK_TWEAK, "TWEAK", 0, "Tweak", ""}, {EVT_TYPE_MASK_ACTIONZONE, "ACTIONZONE", 0, "Action Zone", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -612,18 +581,6 @@ static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr) return result; } -static const EnumPropertyItem *rna_Event_value_itemf(bContext *UNUSED(C), - PointerRNA *ptr, - PropertyRNA *UNUSED(prop), - bool *UNUSED(r_free)) -{ - const wmEvent *event = ptr->data; - if (ISTWEAK(event->type)) { - return rna_enum_event_value_tweak_items; - } - return rna_enum_event_value_all_items; -} - static void rna_Event_ascii_get(PointerRNA *ptr, char *value) { const wmEvent *event = ptr->data; @@ -668,7 +625,7 @@ static int rna_Event_unicode_length(PointerRNA *ptr) static bool rna_Event_is_repeat_get(PointerRNA *ptr) { const wmEvent *event = ptr->data; - return event->is_repeat; + return (event->flag & WM_EVENT_IS_REPEAT) != 0; } static float rna_Event_pressure_get(PointerRNA *ptr) @@ -915,10 +872,6 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) kmi->type = EVT_AKEY; kmi->val = KM_PRESS; break; - case KMI_TYPE_TWEAK: - kmi->type = EVT_TWEAK_L; - kmi->val = KM_ANY; - break; case KMI_TYPE_MOUSE: kmi->type = LEFTMOUSE; kmi->val = KM_PRESS; @@ -969,9 +922,6 @@ static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), if (map_type == KMI_TYPE_MOUSE) { return event_mouse_type_items; } - if (map_type == KMI_TYPE_TWEAK) { - return event_tweak_type_items; - } if (map_type == KMI_TYPE_TIMER) { return event_timer_type_items; } @@ -986,24 +936,6 @@ static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), } } -static const EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C), - PointerRNA *ptr, - PropertyRNA *UNUSED(prop), - bool *UNUSED(r_free)) -{ - int map_type = rna_wmKeyMapItem_map_type_get(ptr); - - if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF) { - return rna_enum_event_value_keymouse_items; - } - if (map_type == KMI_TYPE_TWEAK) { - return rna_enum_event_value_tweak_items; - } - else { - return rna_enum_event_value_all_items; - } -} - static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), @@ -2106,8 +2038,7 @@ static void rna_def_event(BlenderRNA *brna) /* enums */ prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "val"); - RNA_def_property_enum_items(prop, rna_enum_event_value_all_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Event_value_itemf"); + RNA_def_property_enum_items(prop, rna_enum_event_value_items); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some"); @@ -2118,6 +2049,12 @@ static void rna_def_event(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Type", ""); + prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "direction"); + RNA_def_property_enum_items(prop, rna_enum_event_direction_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Direction", "The direction (only applies to drag events)"); + /* keyboard */ prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -2194,23 +2131,23 @@ static void rna_def_event(BlenderRNA *brna) /* modifiers */ prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "shift", 1); + RNA_def_property_boolean_sdna(prop, NULL, "modifier", KM_SHIFT); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held"); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_WINDOWMANAGER); prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1); + RNA_def_property_boolean_sdna(prop, NULL, "modifier", KM_CTRL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held"); prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "alt", 1); + RNA_def_property_boolean_sdna(prop, NULL, "modifier", KM_ALT); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held"); prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1); + RNA_def_property_boolean_sdna(prop, NULL, "modifier", KM_OSKEY); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held"); @@ -2538,7 +2475,6 @@ static void rna_def_keyconfig(BlenderRNA *brna) static const EnumPropertyItem map_type_items[] = { {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""}, - {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""}, {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""}, {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""}, {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""}, @@ -2679,11 +2615,16 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "val"); - RNA_def_property_enum_items(prop, rna_enum_event_value_all_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf"); + RNA_def_property_enum_items(prop, rna_enum_event_value_items); RNA_def_property_ui_text(prop, "Value", ""); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); + prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "direction"); + RNA_def_property_enum_items(prop, rna_enum_event_direction_items); + RNA_def_property_ui_text(prop, "Direction", "The direction (only applies to drag events)"); + RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); + prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "id"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 81cc72088a6..0589fa7a96e 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -258,6 +258,7 @@ static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, int alt, int oskey, int keymodifier, + int direction, bool repeat, bool head) { @@ -275,7 +276,7 @@ static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, WM_operator_bl_idname(idname_bl, idname); /* create keymap item */ - kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier); + kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier, direction); if (!repeat) { kmi->flag |= KMI_REPEAT_IGNORE; @@ -324,6 +325,7 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, int alt, int oskey, int keymodifier, + int direction, bool repeat) { /* only modal maps */ @@ -338,13 +340,14 @@ static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, /* not initialized yet, do delayed lookup */ if (!km->modal_items) { - kmi = WM_modalkeymap_add_item_str(km, type, value, modifier, keymodifier, propvalue_str); + kmi = WM_modalkeymap_add_item_str( + km, type, value, modifier, keymodifier, direction, propvalue_str); } else { if (RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue) == 0) { BKE_report(reports, RPT_WARNING, "Property value not in enumeration"); } - kmi = WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue); + kmi = WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, direction, propvalue); } if (!repeat) { @@ -635,14 +638,23 @@ static wmEvent *rna_Window_event_add_simulate(wmWindow *win, wmEvent e = *win->eventstate; e.type = type; e.val = value; - e.is_repeat = false; + e.flag = 0; e.xy[0] = x; e.xy[1] = y; - e.shift = shift; - e.ctrl = ctrl; - e.alt = alt; - e.oskey = oskey; + e.modifier = 0; + if (shift) { + e.modifier |= KM_SHIFT; + } + if (ctrl) { + e.modifier |= KM_CTRL; + } + if (alt) { + e.modifier |= KM_ALT; + } + if (oskey) { + e.modifier |= KM_OSKEY; + } e.ascii = '\0'; e.utf8_buf[0] = '\0'; @@ -720,7 +732,7 @@ void RNA_api_window(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", ""); + parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_string(func, "unicode", NULL, 0, "", ""); RNA_def_parameter_clear_flags(parm, PROP_NEVER_NULL, 0); @@ -1125,7 +1137,7 @@ void RNA_api_keymapitems(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", ""); + parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_boolean(func, "any", 0, "Any", ""); RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD); @@ -1133,6 +1145,7 @@ void RNA_api_keymapitems(StructRNA *srna) RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD); RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD); RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", ""); + RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", ""); RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events"); RNA_def_boolean(func, "head", @@ -1149,7 +1162,7 @@ void RNA_api_keymapitems(StructRNA *srna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); - parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", ""); + parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_boolean(func, "any", 0, "Any", ""); RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD); @@ -1157,6 +1170,7 @@ void RNA_api_keymapitems(StructRNA *srna) RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD); RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD); RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", ""); + RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", ""); RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events"); parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item"); RNA_def_function_return(func, parm); diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c index 87d8bc8d844..9fe3153eb1e 100644 --- a/source/blender/makesrna/intern/rna_xr.c +++ b/source/blender/makesrna/intern/rna_xr.c @@ -46,6 +46,43 @@ static wmXrData *rna_XrSession_wm_xr_data_get(PointerRNA *ptr) /** \name XR Action Map * \{ */ +static XrComponentPath *rna_XrComponentPath_new(XrActionMapBinding *amb, const char *path_str) +{ +# ifdef WITH_XR_OPENXR + XrComponentPath *component_path = MEM_callocN(sizeof(XrComponentPath), __func__); + BLI_strncpy(component_path->path, path_str, sizeof(component_path->path)); + BLI_addtail(&amb->component_paths, component_path); + return component_path; +# else + UNUSED_VARS(amb, path_str); + return NULL; +# endif +} + +static void rna_XrComponentPath_remove(XrActionMapBinding *amb, PointerRNA *component_path_ptr) +{ +# ifdef WITH_XR_OPENXR + XrComponentPath *component_path = component_path_ptr->data; + int idx = BLI_findindex(&amb->component_paths, component_path); + if (idx != -1) { + BLI_freelinkN(&amb->component_paths, component_path); + } + RNA_POINTER_INVALIDATE(component_path_ptr); +# else + UNUSED_VARS(amb, component_path_ptr); +# endif +} + +static XrComponentPath *rna_XrComponentPath_find(XrActionMapBinding *amb, const char *path_str) +{ +# ifdef WITH_XR_OPENXR + return BLI_findstring(&amb->component_paths, path_str, offsetof(XrComponentPath, path)); +# else + UNUSED_VARS(amb, path_str); + return NULL; +# endif +} + static XrActionMapBinding *rna_XrActionMapBinding_new(XrActionMapItem *ami, const char *name, bool replace_existing) @@ -99,6 +136,28 @@ static XrActionMapBinding *rna_XrActionMapBinding_find(XrActionMapItem *ami, con # endif } +static void rna_XrActionMapBinding_component_paths_begin(CollectionPropertyIterator *iter, + PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMapBinding *amb = (XrActionMapBinding *)ptr->data; + rna_iterator_listbase_begin(iter, &amb->component_paths, NULL); +# else + UNUSED_VARS(iter, ptr); +# endif +} + +static int rna_XrActionMapBinding_component_paths_length(PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMapBinding *amb = (XrActionMapBinding *)ptr->data; + return BLI_listbase_count(&amb->component_paths); +# else + UNUSED_VARS(ptr); + return 0; +# endif +} + static int rna_XrActionMapBinding_axis0_region_get(PointerRNA *ptr) { # ifdef WITH_XR_OPENXR @@ -174,6 +233,43 @@ static void rna_XrActionMapBinding_name_update(Main *bmain, Scene *UNUSED(scene) # endif } +static XrUserPath *rna_XrUserPath_new(XrActionMapItem *ami, const char *path_str) +{ +# ifdef WITH_XR_OPENXR + XrUserPath *user_path = MEM_callocN(sizeof(XrUserPath), __func__); + BLI_strncpy(user_path->path, path_str, sizeof(user_path->path)); + BLI_addtail(&ami->user_paths, user_path); + return user_path; +# else + UNUSED_VARS(ami, path_str); + return NULL; +# endif +} + +static void rna_XrUserPath_remove(XrActionMapItem *ami, PointerRNA *user_path_ptr) +{ +# ifdef WITH_XR_OPENXR + XrUserPath *user_path = user_path_ptr->data; + int idx = BLI_findindex(&ami->user_paths, user_path); + if (idx != -1) { + BLI_freelinkN(&ami->user_paths, user_path); + } + RNA_POINTER_INVALIDATE(user_path_ptr); +# else + UNUSED_VARS(ami, user_path_ptr); +# endif +} + +static XrUserPath *rna_XrUserPath_find(XrActionMapItem *ami, const char *path_str) +{ +# ifdef WITH_XR_OPENXR + return BLI_findstring(&ami->user_paths, path_str, offsetof(XrUserPath, path)); +# else + UNUSED_VARS(ami, path_str); + return NULL; +# endif +} + static XrActionMapItem *rna_XrActionMapItem_new(XrActionMap *am, const char *name, bool replace_existing) @@ -222,6 +318,27 @@ static XrActionMapItem *rna_XrActionMapItem_find(XrActionMap *am, const char *na # endif } +static void rna_XrActionMapItem_user_paths_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMapItem *ami = (XrActionMapItem *)ptr->data; + rna_iterator_listbase_begin(iter, &ami->user_paths, NULL); +# else + UNUSED_VARS(iter, ptr); +# endif +} + +static int rna_XrActionMapItem_user_paths_length(PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMapItem *ami = (XrActionMapItem *)ptr->data; + return BLI_listbase_count(&ami->user_paths); +# else + UNUSED_VARS(ptr); + return 0; +# endif +} + static void rna_XrActionMapItem_op_name_get(PointerRNA *ptr, char *value) { # ifdef WITH_XR_OPENXR @@ -395,6 +512,27 @@ static void rna_XrActionMapItem_pose_is_controller_aim_set(PointerRNA *ptr, bool # endif } +static void rna_XrActionMapItem_bindings_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMapItem *ami = (XrActionMapItem *)ptr->data; + rna_iterator_listbase_begin(iter, &ami->bindings, NULL); +# else + UNUSED_VARS(iter, ptr); +# endif +} + +static int rna_XrActionMapItem_bindings_length(PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMapItem *ami = (XrActionMapItem *)ptr->data; + return BLI_listbase_count(&ami->bindings); +# else + UNUSED_VARS(ptr); + return 0; +# endif +} + static void rna_XrActionMapItem_name_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { # ifdef WITH_XR_OPENXR @@ -471,6 +609,27 @@ static XrActionMap *rna_XrActionMap_find(PointerRNA *ptr, const char *name) # endif } +static void rna_XrActionMap_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMap *actionmap = (XrActionMap *)ptr->data; + rna_iterator_listbase_begin(iter, &actionmap->items, NULL); +# else + UNUSED_VARS(iter, ptr); +# endif +} + +static int rna_XrActionMap_items_length(PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + XrActionMap *actionmap = (XrActionMap *)ptr->data; + return BLI_listbase_count(&actionmap->items); +# else + UNUSED_VARS(ptr); + return 0; +# endif +} + static void rna_XrActionMap_name_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { # ifdef WITH_XR_OPENXR @@ -576,26 +735,8 @@ static bool rna_XrSessionState_action_create(bContext *C, { # ifdef WITH_XR_OPENXR wmWindowManager *wm = CTX_wm_manager(C); - unsigned int count_subaction_paths = 0; - const char *subaction_paths[2]; - - if (ami->user_path0[0]) { - subaction_paths[0] = ami->user_path0; - ++count_subaction_paths; - - if (ami->user_path1[0]) { - subaction_paths[1] = ami->user_path1; - ++count_subaction_paths; - } - } - else { - if (ami->user_path1[0]) { - subaction_paths[0] = ami->user_path1; - ++count_subaction_paths; - } - else { - return false; - } + if (BLI_listbase_is_empty(&ami->user_paths)) { + return false; } const bool is_float_action = (ami->type == XR_FLOAT_INPUT || ami->type == XR_VECTOR2F_INPUT); @@ -621,8 +762,7 @@ static bool rna_XrSessionState_action_create(bContext *C, actionmap->name, ami->name, ami->type, - count_subaction_paths, - subaction_paths, + &ami->user_paths, ot, op_properties, is_button_action ? ami->haptic_name : NULL, @@ -645,30 +785,10 @@ static bool rna_XrSessionState_action_binding_create(bContext *C, { # ifdef WITH_XR_OPENXR wmWindowManager *wm = CTX_wm_manager(C); - unsigned int count_subaction_paths = 0; - const char *subaction_paths[2]; - const char *component_paths[2]; - - if (ami->user_path0[0]) { - subaction_paths[0] = ami->user_path0; - component_paths[0] = amb->component_path0; - ++count_subaction_paths; - - if (ami->user_path1[0]) { - subaction_paths[1] = ami->user_path1; - component_paths[1] = amb->component_path1; - ++count_subaction_paths; - } - } - else { - if (ami->user_path1[0]) { - subaction_paths[0] = ami->user_path1; - component_paths[0] = amb->component_path1; - ++count_subaction_paths; - } - else { - return false; - } + const int count_user_paths = BLI_listbase_count(&ami->user_paths); + const int count_component_paths = BLI_listbase_count(&amb->component_paths); + if (count_user_paths < 1 || (count_user_paths != count_component_paths)) { + return false; } const bool is_float_action = (ami->type == XR_FLOAT_INPUT || ami->type == XR_VECTOR2F_INPUT); @@ -695,9 +815,8 @@ static bool rna_XrSessionState_action_binding_create(bContext *C, actionmap->name, ami->name, amb->profile, - count_subaction_paths, - subaction_paths, - component_paths, + &ami->user_paths, + &amb->component_paths, is_float_action ? float_thresholds : NULL, is_button_action ? axis_flags : NULL, is_pose_action ? poses : NULL); @@ -954,6 +1073,18 @@ static void rna_XrSessionState_actionmaps_begin(CollectionPropertyIterator *iter # endif } +static int rna_XrSessionState_actionmaps_length(PointerRNA *ptr) +{ +# ifdef WITH_XR_OPENXR + wmXrData *xr = rna_XrSession_wm_xr_data_get(ptr); + ListBase *lb = WM_xr_actionmaps_get(xr->runtime); + return BLI_listbase_count(lb); +# else + UNUSED_VARS(ptr); + return 0; +# endif +} + static int rna_XrSessionState_active_actionmap_get(PointerRNA *ptr) { # ifdef WITH_XR_OPENXR @@ -1240,6 +1371,42 @@ static const EnumPropertyItem rna_enum_xr_axis1_flags[] = { /** \name XR Action Map * \{ */ +static void rna_def_xr_component_paths(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "XrComponentPaths"); + srna = RNA_def_struct(brna, "XrComponentPaths", NULL); + RNA_def_struct_sdna(srna, "XrActionMapBinding"); + RNA_def_struct_ui_text(srna, "XR Component Paths", "Collection of OpenXR component paths"); + + func = RNA_def_function(srna, "new", "rna_XrComponentPath_new"); + parm = RNA_def_string( + func, "path", NULL, XR_MAX_COMPONENT_PATH_LENGTH, "Path", "OpenXR component path"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer( + func, "component_path", "XrComponentPath", "Component Path", "Added component path"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_XrComponentPath_remove"); + parm = RNA_def_pointer(func, "component_path", "XrComponentPath", "Component Path", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + + func = RNA_def_function(srna, "find", "rna_XrComponentPath_find"); + parm = RNA_def_string( + func, "path", NULL, XR_MAX_COMPONENT_PATH_LENGTH, "Path", "OpenXR component path"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, + "component_path", + "XrComponentPath", + "Component Path", + "The component path with the given path"); + RNA_def_function_return(func, parm); +} + static void rna_def_xr_actionmap_bindings(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -1289,6 +1456,36 @@ static void rna_def_xr_actionmap_bindings(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); } +static void rna_def_xr_user_paths(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "XrUserPaths"); + srna = RNA_def_struct(brna, "XrUserPaths", NULL); + RNA_def_struct_sdna(srna, "XrActionMapItem"); + RNA_def_struct_ui_text(srna, "XR User Paths", "Collection of OpenXR user paths"); + + func = RNA_def_function(srna, "new", "rna_XrUserPath_new"); + parm = RNA_def_string(func, "path", NULL, XR_MAX_USER_PATH_LENGTH, "Path", "OpenXR user path"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "user_path", "XrUserPath", "User Path", "Added user path"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_XrUserPath_remove"); + parm = RNA_def_pointer(func, "user_path", "XrUserPath", "User Path", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + + func = RNA_def_function(srna, "find", "rna_XrUserPath_find"); + parm = RNA_def_string(func, "path", NULL, XR_MAX_USER_PATH_LENGTH, "Path", "OpenXR user path"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer( + func, "user_path", "XrUserPath", "User Path", "The user path with the given path"); + RNA_def_function_return(func, parm); +} + static void rna_def_xr_actionmap_items(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -1404,6 +1601,15 @@ static void rna_def_xr_actionmap(BlenderRNA *brna) prop = RNA_def_property(srna, "actionmap_items", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "items", NULL); RNA_def_property_struct_type(prop, "XrActionMapItem"); + RNA_def_property_collection_funcs(prop, + "rna_XrActionMap_items_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_iterator_listbase_get", + "rna_XrActionMap_items_length", + NULL, + NULL, + NULL); RNA_def_property_ui_text( prop, "Items", @@ -1414,6 +1620,15 @@ static void rna_def_xr_actionmap(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "selitem"); RNA_def_property_ui_text(prop, "Selected Item", ""); + /* XrUserPath */ + srna = RNA_def_struct(brna, "XrUserPath", NULL); + RNA_def_struct_sdna(srna, "XrUserPath"); + RNA_def_struct_ui_text(srna, "XR User Path", ""); + + prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE); + RNA_def_property_string_maxlength(prop, XR_MAX_USER_PATH_LENGTH); + RNA_def_property_ui_text(prop, "Path", "OpenXR user path"); + /* XrActionMapItem */ srna = RNA_def_struct(brna, "XrActionMapItem", NULL); RNA_def_struct_sdna(srna, "XrActionMapItem"); @@ -1429,13 +1644,19 @@ static void rna_def_xr_actionmap(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Action type"); RNA_def_property_update(prop, 0, "rna_XrActionMapItem_update"); - prop = RNA_def_property(srna, "user_path0", PROP_STRING, PROP_NONE); - RNA_def_property_string_maxlength(prop, 64); - RNA_def_property_ui_text(prop, "User Path 0", "OpenXR user path"); - - prop = RNA_def_property(srna, "user_path1", PROP_STRING, PROP_NONE); - RNA_def_property_string_maxlength(prop, 64); - RNA_def_property_ui_text(prop, "User Path 1", "OpenXR user path"); + prop = RNA_def_property(srna, "user_paths", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "XrUserPath"); + RNA_def_property_collection_funcs(prop, + "rna_XrActionMapItem_user_paths_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_iterator_listbase_get", + "rna_XrActionMapItem_user_paths_length", + NULL, + NULL, + NULL); + RNA_def_property_ui_text(prop, "User Paths", "OpenXR user paths"); + rna_def_xr_user_paths(brna, prop); prop = RNA_def_property(srna, "op", PROP_STRING, PROP_NONE); RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); @@ -1520,6 +1741,15 @@ static void rna_def_xr_actionmap(BlenderRNA *brna) prop = RNA_def_property(srna, "bindings", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "XrActionMapBinding"); + RNA_def_property_collection_funcs(prop, + "rna_XrActionMapItem_bindings_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_iterator_listbase_get", + "rna_XrActionMapItem_bindings_length", + NULL, + NULL, + NULL); RNA_def_property_ui_text( prop, "Bindings", "Bindings for the action map item, mapping the action to an XR input"); rna_def_xr_actionmap_bindings(brna, prop); @@ -1528,6 +1758,15 @@ static void rna_def_xr_actionmap(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "selbinding"); RNA_def_property_ui_text(prop, "Selected Binding", "Currently selected binding"); + /* XrComponentPath */ + srna = RNA_def_struct(brna, "XrComponentPath", NULL); + RNA_def_struct_sdna(srna, "XrComponentPath"); + RNA_def_struct_ui_text(srna, "XR Component Path", ""); + + prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE); + RNA_def_property_string_maxlength(prop, XR_MAX_COMPONENT_PATH_LENGTH); + RNA_def_property_ui_text(prop, "Path", "OpenXR component path"); + /* XrActionMapBinding */ srna = RNA_def_struct(brna, "XrActionMapBinding", NULL); RNA_def_struct_sdna(srna, "XrActionMapBinding"); @@ -1542,13 +1781,19 @@ static void rna_def_xr_actionmap(BlenderRNA *brna) RNA_def_property_string_maxlength(prop, 256); RNA_def_property_ui_text(prop, "Profile", "OpenXR interaction profile path"); - prop = RNA_def_property(srna, "component_path0", PROP_STRING, PROP_NONE); - RNA_def_property_string_maxlength(prop, 192); - RNA_def_property_ui_text(prop, "Component Path 0", "OpenXR component path"); - - prop = RNA_def_property(srna, "component_path1", PROP_STRING, PROP_NONE); - RNA_def_property_string_maxlength(prop, 192); - RNA_def_property_ui_text(prop, "Component Path 1", "OpenXR component path"); + prop = RNA_def_property(srna, "component_paths", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "XrComponentPath"); + RNA_def_property_collection_funcs(prop, + "rna_XrActionMapBinding_component_paths_begin", + "rna_iterator_listbase_next", + "rna_iterator_listbase_end", + "rna_iterator_listbase_get", + "rna_XrActionMapBinding_component_paths_length", + NULL, + NULL, + NULL); + RNA_def_property_ui_text(prop, "Component Paths", "OpenXR component paths"); + rna_def_xr_component_paths(brna, prop); prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "float_threshold"); @@ -1812,7 +2057,7 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_set", NULL, 64, "Action Set", "Action set name"); + parm = RNA_def_string(func, "action_set", NULL, MAX_NAME, "Action Set", "Action set name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); @@ -1823,19 +2068,19 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_set", NULL, 64, "Action Set", "Action set name"); + parm = RNA_def_string(func, "action_set", NULL, MAX_NAME, "Action Set", "Action set name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_string(func, "grip_action", NULL, - 64, + MAX_NAME, "Grip Action", "Name of the action representing the controller grips"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_string(func, "aim_action", NULL, - 64, + MAX_NAME, "Aim Action", "Name of the action representing the controller aims"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); @@ -1847,11 +2092,12 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_set_name", NULL, 64, "Action Set", "Action set name"); + parm = RNA_def_string(func, "action_set_name", NULL, MAX_NAME, "Action Set", "Action set name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_name", NULL, 64, "Action", "Action name"); + parm = RNA_def_string(func, "action_name", NULL, MAX_NAME, "Action", "Action name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "user_path", NULL, 64, "User Path", "OpenXR user path"); + parm = RNA_def_string( + func, "user_path", NULL, XR_MAX_USER_PATH_LENGTH, "User Path", "OpenXR user path"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_float_array( func, @@ -1871,15 +2117,15 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_set_name", NULL, 64, "Action Set", "Action set name"); + parm = RNA_def_string(func, "action_set_name", NULL, MAX_NAME, "Action Set", "Action set name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_name", NULL, 64, "Action", "Action name"); + parm = RNA_def_string(func, "action_name", NULL, MAX_NAME, "Action", "Action name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_string( func, "user_path", NULL, - 64, + XR_MAX_USER_PATH_LENGTH, "User Path", "Optional OpenXR user path. If not set, the action will be applied to all paths"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); @@ -1922,15 +2168,15 @@ static void rna_def_xr_session_state(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_set_name", NULL, 64, "Action Set", "Action set name"); + parm = RNA_def_string(func, "action_set_name", NULL, MAX_NAME, "Action Set", "Action set name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); - parm = RNA_def_string(func, "action_name", NULL, 64, "Action", "Action name"); + parm = RNA_def_string(func, "action_name", NULL, MAX_NAME, "Action", "Action name"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); parm = RNA_def_string( func, "user_path", NULL, - 64, + XR_MAX_USER_PATH_LENGTH, "User Path", "Optional OpenXR user path. If not set, the action will be stopped for all paths"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); @@ -2068,16 +2314,16 @@ static void rna_def_xr_session_state(BlenderRNA *brna) "Additional scale multiplier to apply to base scale when determining viewer scale"); prop = RNA_def_property(srna, "actionmaps", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "XrActionMap"); RNA_def_property_collection_funcs(prop, "rna_XrSessionState_actionmaps_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", - NULL, + "rna_XrSessionState_actionmaps_length", NULL, NULL, NULL); - RNA_def_property_struct_type(prop, "XrActionMap"); RNA_def_property_ui_text(prop, "XR Action Maps", ""); rna_def_xr_actionmaps(brna, prop); |