diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index f98719ff4f0..411eb16cd9d 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -803,6 +803,16 @@ static void attr_create_generic(Scene *scene, num_curves, num_keys, data, element, [&](int i) { return float(src[i]); }); break; } + case BL::Attribute::data_type_INT32_2D: { + BL::Int2Attribute b_int2_attribute{b_attribute}; + const int2 *src = static_cast(b_int2_attribute.data[0].ptr.data); + Attribute *attr = attributes.add(name, TypeFloat2, element); + float2 *data = attr->data_float2(); + fill_generic_attribute(num_curves, num_keys, data, element, [&](int i) { + return make_float2(float(src[i][0]), float(src[i][1])); + }); + break; + } case BL::Attribute::data_type_FLOAT_VECTOR: { BL::FloatVectorAttribute b_vector_attribute{b_attribute}; const float(*src)[3] = static_cast(b_vector_attribute.data[0].ptr.data); diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index 7e1b73ea40b..8692e84debe 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -528,6 +528,19 @@ static void attr_create_generic(Scene *scene, }); break; } + case BL::Attribute::data_type_INT32_2D: { + BL::Int2Attribute b_int2_attribute{b_attribute}; + if (b_int2_attribute.data.length() == 0) { + continue; + } + const int2 *src = static_cast(b_int2_attribute.data[0].ptr.data); + Attribute *attr = attributes.add(name, TypeFloat2, element); + float2 *data = attr->data_float2(); + fill_generic_attribute(b_mesh, data, b_domain, subdivision, [&](int i) { + return make_float2(float(src[i][0]), float(src[i][1])); + }); + break; + } default: /* Not supported. */ break; diff --git a/intern/cycles/blender/pointcloud.cpp b/intern/cycles/blender/pointcloud.cpp index f8b656ce688..32caebc0358 100644 --- a/intern/cycles/blender/pointcloud.cpp +++ b/intern/cycles/blender/pointcloud.cpp @@ -102,6 +102,16 @@ static void copy_attributes(PointCloud *pointcloud, } break; } + case BL::Attribute::data_type_INT32_2D: { + BL::Int2Attribute b_int2_attribute{b_attribute}; + const int2 *src = static_cast(b_int2_attribute.data[0].ptr.data); + Attribute *attr = attributes.add(name, TypeFloat2, element); + float2 *data = attr->data_float2(); + for (int i = 0; i < num_points; i++) { + data[i] = make_float2(float(src[i][0]), float(src[i][1])); + } + break; + } case BL::Attribute::data_type_FLOAT_VECTOR: { BL::FloatVectorAttribute b_vector_attribute{b_attribute}; const float(*src)[3] = static_cast(b_vector_attribute.data[0].ptr.data); diff --git a/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 93ab0392c66..6ea767433ea 100644 --- a/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -31,21 +31,44 @@ def generate_from_enum_ex( type, attr, cursor='DEFAULT', - tooldef_keywords={}, - exclude_filter={}, + tooldef_keywords=None, + icon_map=None, + use_separators=True, ): + if tooldef_keywords is None: + tooldef_keywords = {} + tool_defs = [] - for enum in type.bl_rna.properties[attr].enum_items_static: - name = enum.name - idname = enum.identifier - if idname in exclude_filter: - continue + + enum_items = getattr( + type.bl_rna.properties[attr], + "enum_items_static_ui" if use_separators else + "enum_items_static", + ) + + for enum in enum_items: + if use_separators: + if not (name := enum.name): + # Empty string for a UI Separator. + tool_defs.append(None) + continue + if not (idname := enum.identifier): + # This is a heading, there is no purpose in showing headings here. + continue + else: + name = enum.name + idname = enum.identifier + + icon = icon_prefix + idname.lower() + if icon_map is not None: + icon = icon_map.get(icon, icon) + tool_defs.append( ToolDef.from_dict( dict( idname=idname_prefix + name, label=name, - icon=icon_prefix + idname.lower(), + icon=icon, cursor=cursor, data_block=idname, **tooldef_keywords, @@ -1316,6 +1339,9 @@ class _defs_sculpt: icon_prefix="brush.sculpt.", type=bpy.types.Brush, attr="sculpt_tool", + # TODO(@ideasman42): we may want to enable this, + # it causes awkward grouping with 2x column button layout. + use_separators=False, ) @ToolDef.from_fn @@ -2326,103 +2352,18 @@ class _defs_gpencil_weight: class _defs_curves_sculpt: - @ToolDef.from_fn - def selection_paint(): - return dict( - idname="builtin_brush.selection_paint", - label="Selection Paint", - icon="ops.generic.select_paint", - data_block="SELECTION_PAINT", - ) - - @ToolDef.from_fn - def comb(): - return dict( - idname="builtin_brush.comb", - label="Comb", - icon="ops.curves.sculpt_comb", - data_block='COMB', - ) - - @ToolDef.from_fn - def add(): - return dict( - idname="builtin_brush.add", - label="Add", - icon="ops.curves.sculpt_add", - data_block='ADD', - ) - - @ToolDef.from_fn - def delete(): - return dict( - idname="builtin_brush.delete", - label="Delete", - icon="ops.curves.sculpt_delete", - data_block='DELETE', - ) - - @ToolDef.from_fn - def snake_hook(): - return dict( - idname="builtin_brush.snake_hook", - label="Snake Hook", - icon="ops.curves.sculpt_snake_hook", - data_block='SNAKE_HOOK', - ) - - @ToolDef.from_fn - def grow_shrink(): - return dict( - idname="builtin_brush.grow_shrink", - label="Grow/Shrink", - icon="ops.curves.sculpt_grow_shrink", - data_block='GROW_SHRINK', - ) - - @ToolDef.from_fn - def pinch(): - return dict( - idname="builtin_brush.pinch", - label="Pinch", - icon="ops.curves.sculpt_pinch", - data_block='PINCH', - ) - - @ToolDef.from_fn - def smooth(): - return dict( - idname="builtin_brush.smooth", - label="Smooth", - icon="ops.curves.sculpt_smooth", - data_block='SMOOTH', - ) - - @ToolDef.from_fn - def puff(): - return dict( - idname="builtin_brush.puff", - label="Puff", - icon="ops.curves.sculpt_puff", - data_block='PUFF', - ) - - @ToolDef.from_fn - def density(): - return dict( - idname="builtin_brush.density", - label="Density", - icon="ops.curves.sculpt_density", - data_block="DENSITY", - ) - - @ToolDef.from_fn - def slide(): - return dict( - idname="builtin_brush.slide", - label="Slide", - icon="ops.curves.sculpt_slide", - data_block="SLIDE", + @staticmethod + def generate_from_brushes(context): + return generate_from_enum_ex( + context, + idname_prefix="builtin_brush.", + icon_prefix="ops.curves.sculpt_", + type=bpy.types.Brush, + attr="curves_sculpt_tool", + icon_map={ + # Use the generic icon for selection painting. + "ops.curves.sculpt_selection_paint": "ops.generic.select_paint", + }, ) @@ -3193,19 +3134,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): ), ], 'SCULPT_CURVES': [ - _defs_curves_sculpt.selection_paint, - None, - _defs_curves_sculpt.add, - _defs_curves_sculpt.delete, - _defs_curves_sculpt.density, - None, - _defs_curves_sculpt.comb, - _defs_curves_sculpt.snake_hook, - _defs_curves_sculpt.grow_shrink, - _defs_curves_sculpt.pinch, - _defs_curves_sculpt.puff, - _defs_curves_sculpt.smooth, - _defs_curves_sculpt.slide, + _defs_curves_sculpt.generate_from_brushes, None, *_tools_annotate, ], diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index 9b0699e8f35..679496ee783 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -147,7 +147,7 @@ add_subdirectory(imbuf) add_subdirectory(imbuf/intern/oiio) add_subdirectory(nodes) add_subdirectory(modifiers) -add_subdirectory(gpencil_modifiers) +add_subdirectory(gpencil_modifiers_legacy) add_subdirectory(sequencer) add_subdirectory(shader_fx) add_subdirectory(io) diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh index ef0744f21a6..8b576f4f586 100644 --- a/source/blender/blenkernel/BKE_attribute_math.hh +++ b/source/blender/blenkernel/BKE_attribute_math.hh @@ -23,6 +23,7 @@ inline void convert_to_static_type(const CPPType &cpp_type, const Func &func) float2, float3, int, + int2, bool, int8_t, ColorGeometry4f, @@ -68,6 +69,11 @@ template<> inline int mix2(const float factor, const int &a, const int &b) return int(std::round((1.0f - factor) * a + factor * b)); } +template<> inline int2 mix2(const float factor, const int2 &a, const int2 &b) +{ + return math::interpolate(a, b, factor); +} + template<> inline float mix2(const float factor, const float &a, const float &b) { return (1.0f - factor) * a + factor * b; @@ -121,6 +127,11 @@ template<> inline int mix3(const float3 &weights, const int &v0, const int &v1, return int(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2)); } +template<> inline int2 mix3(const float3 &weights, const int2 &v0, const int2 &v1, const int2 &v2) +{ + return int2(weights.x * float2(v0) + weights.y * float2(v1) + weights.z * float2(v2)); +} + template<> inline float mix3(const float3 &weights, const float &v0, const float &v1, const float &v2) { @@ -194,6 +205,14 @@ inline int mix4(const float4 &weights, const int &v0, const int &v1, const int & return int(std::round(weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3)); } +template<> +inline int2 mix4( + const float4 &weights, const int2 &v0, const int2 &v1, const int2 &v2, const int2 &v3) +{ + return int2(weights.x * float2(v0) + weights.y * float2(v1) + weights.z * float2(v2) + + weights.w * float2(v3)); +} + template<> inline float mix4( const float4 &weights, const float &v0, const float &v1, const float &v2, const float &v3) @@ -382,7 +401,7 @@ class SimpleMixerWithAccumulationType { private: struct Item { /* Store both values together, because they are accessed together. */ - AccumulationT value = {0}; + AccumulationT value = AccumulationT(0); float weight = 0.0f; }; @@ -517,6 +536,15 @@ template<> struct DefaultMixerStruct { * uses double instead of float so that it is accurate for all 32 bit integers. */ using type = SimpleMixerWithAccumulationType; }; +template<> struct DefaultMixerStruct { + static int2 double_to_int(const double2 &value) + { + return int2(math::round(value)); + } + /* Store interpolated ints in a double temporarily, so that weights are handled correctly. It + * uses double instead of float so that it is accurate for all 32 bit integers. */ + using type = SimpleMixerWithAccumulationType; +}; template<> struct DefaultMixerStruct { static bool float_to_bool(const float &value) { diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index 16b0c212a6c..7d24da5600c 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -9,6 +9,7 @@ #include "BLI_bounds_types.hh" #include "BLI_generic_virtual_array.hh" +#include "BLI_implicit_sharing.hh" #include "BLI_index_mask.hh" #include "BLI_math_matrix_types.hh" #include "BLI_math_vector_types.hh" @@ -53,6 +54,9 @@ struct BasisCache { */ class CurvesGeometryRuntime { public: + /** Implicit sharing user count for #CurvesGeometry::curve_offsets. */ + ImplicitSharingInfo *curve_offsets_sharing_info = nullptr; + /** * The cached number of curves with each type. Unlike other caches here, this is not computed * lazily, since it is needed so often and types are not adjusted much anyway. diff --git a/source/blender/blenkernel/BKE_lib_query.h b/source/blender/blenkernel/BKE_lib_query.h index d5023dd6e2b..7dcd25434b8 100644 --- a/source/blender/blenkernel/BKE_lib_query.h +++ b/source/blender/blenkernel/BKE_lib_query.h @@ -54,37 +54,45 @@ enum { * This means callback shall not *do* anything, only use this as informative data if it needs it. */ IDWALK_CB_EMBEDDED = (1 << 4), + /** + * That ID pointer points to an embedded ID, but does not own it. + * + * E.g the `collection` pointer of the first ViewLayerCollection of a ViewLayer should always + * point to the scene's master collection, which is an embedded ID 'owned' by + * `Scene.master_collection`. + */ + IDWALK_CB_EMBEDDED_NOT_OWNING = (1 << 5), /** * That ID is not really used by its owner, it's just an internal hint/helper. * This marks the 'from' pointers issue, like Key->from. * How to handle that kind of cases totally depends on what caller code is doing... */ - IDWALK_CB_LOOPBACK = (1 << 5), + IDWALK_CB_LOOPBACK = (1 << 6), /** That ID is used as library override's reference by its owner. */ - IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE = (1 << 6), + IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE = (1 << 7), /** That ID pointer is not overridable. */ - IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE = (1 << 7), + IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE = (1 << 8), /** * Indicates that this is an internal runtime ID pointer, like e.g. `ID.newid` or `ID.original`. * \note Those should be ignored in most cases, and won't be processed/generated anyway unless * `IDWALK_DO_INTERNAL_RUNTIME_POINTERS` option is enabled. */ - IDWALK_CB_INTERNAL = (1 << 8), + IDWALK_CB_INTERNAL = (1 << 9), /** * This ID usage is fully refcounted. * Callback is responsible to deal accordingly with #ID.us if needed. */ - IDWALK_CB_USER = (1 << 9), + IDWALK_CB_USER = (1 << 10), /** * This ID usage is not refcounted, but at least one user should be generated by it (to avoid * e.g. losing the used ID on save/reload). * Callback is responsible to deal accordingly with #ID.us if needed. */ - IDWALK_CB_USER_ONE = (1 << 10), + IDWALK_CB_USER_ONE = (1 << 11), }; enum { @@ -123,7 +131,9 @@ typedef int (*LibraryIDLinkCallback)(LibraryIDLinkCallbackData *cb_data); /* Flags for the foreach function itself. */ enum { IDWALK_NOP = 0, - /** The callback will never modify the ID pointers it processes. */ + /** The callback will never modify the ID pointers it processes. + * WARNING: It is very important to pass this flag when valid, as it can lead to important + * optimizations and debug/assert code. */ IDWALK_READONLY = (1 << 0), /** Recurse into 'descendant' IDs. * Each ID is only processed once. Order of ID processing is not guaranteed. diff --git a/source/blender/blenkernel/BKE_lib_remap.h b/source/blender/blenkernel/BKE_lib_remap.h index dc3335aa231..98a27ec6d56 100644 --- a/source/blender/blenkernel/BKE_lib_remap.h +++ b/source/blender/blenkernel/BKE_lib_remap.h @@ -56,28 +56,38 @@ enum { */ ID_REMAP_FORCE_NEVER_NULL_USAGE = 1 << 3, /** Do not remap library override pointers. */ - ID_REMAP_SKIP_OVERRIDE_LIBRARY = 1 << 5, - /** Don't touch the special user counts (use when the 'old' remapped ID remains in use): - * - Do not transfer 'fake user' status from old to new ID. - * - Do not clear 'extra user' from old ID. */ - ID_REMAP_SKIP_USER_CLEAR = 1 << 6, + ID_REMAP_SKIP_OVERRIDE_LIBRARY = 1 << 4, /** * Force internal ID runtime pointers (like `ID.newid`, `ID.orig_id` etc.) to also be processed. * This should only be needed in some very specific cases, typically only BKE ID management code * should need it (e.g. required from `id_delete` to ensure no runtime pointer remains using * freed ones). */ - ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS = 1 << 7, - /** Force handling user count even for IDs that are outside of Main (used in some cases when - * dealing with IDs temporarily out of Main, but which will be put in it ultimately). - */ - ID_REMAP_FORCE_USER_REFCOUNT = 1 << 8, + ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS = 1 << 5, + /** Force remapping of 'UI-like' ID usages (ID pointers stored in editors data etc.). */ + ID_REMAP_FORCE_UI_POINTERS = 1 << 6, /** * Force obdata pointers to also be processed, even when object (`id_owner`) is in Edit mode. * This is required by some tools creating/deleting IDs while operating in Edit mode, like e.g. * the 'separate' mesh operator. */ - ID_REMAP_FORCE_OBDATA_IN_EDITMODE = 1 << 9, + ID_REMAP_FORCE_OBDATA_IN_EDITMODE = 1 << 7, + + /** Don't touch the special user counts (use when the 'old' remapped ID remains in use): + * - Do not transfer 'fake user' status from old to new ID. + * - Do not clear 'extra user' from old ID. */ + ID_REMAP_SKIP_USER_CLEAR = 1 << 16, + /** Force handling user count even for IDs that are outside of Main (used in some cases when + * dealing with IDs temporarily out of Main, but which will be put in it ultimately). + */ + ID_REMAP_FORCE_USER_REFCOUNT = 1 << 17, + /** Do NOT handle user count for IDs (used in some cases when dealing with IDs from different + * BMains, if usercount will be recomputed anyway afterwards, like e.g. in memfile reading during + * undo step decoding). */ + ID_REMAP_SKIP_USER_REFCOUNT = 1 << 18, + /** Do NOT tag IDs which had some of their ID pointers updated for update in the depsgraph, or ID + * type specific updates, like e.g. with node trees. */ + ID_REMAP_SKIP_UPDATE_TAGGING = 1 << 19, }; typedef enum eIDRemapType { @@ -95,12 +105,24 @@ typedef enum eIDRemapType { */ void BKE_libblock_remap_multiple_locked(struct Main *bmain, struct IDRemapper *mappings, - short remap_flags); + const int remap_flags); void BKE_libblock_remap_multiple(struct Main *bmain, struct IDRemapper *mappings, - short remap_flags); + const int remap_flags); +/** + * Bare raw remapping of IDs, with no other processing than actually updating the ID pointers. No + * usercount, direct vs indirect linked status update, depsgraph tagging, etc. + * + * This is way more efficient than regular remapping from #BKE_libblock_remap_multiple & co, but it + * implies that calling code handles all the other aspects described above. This is typically the + * case e.g. in readfile process. + * + * WARNING: This call will likely leave the given BMain in invalid state in many aspects. */ +void BKE_libblock_remap_multiple_raw(struct Main *bmain, + struct IDRemapper *mappings, + const int remap_flags); /** * Replace all references in given Main to \a old_id by \a new_id * (if \a new_id is NULL, it unlinks \a old_id). @@ -108,9 +130,9 @@ void BKE_libblock_remap_multiple(struct Main *bmain, * \note Requiring new_id to be non-null, this *may* not be the case ultimately, * but makes things simpler for now. */ -void BKE_libblock_remap_locked(struct Main *bmain, void *old_idv, void *new_idv, short remap_flags) +void BKE_libblock_remap_locked(struct Main *bmain, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(1, 2); -void BKE_libblock_remap(struct Main *bmain, void *old_idv, void *new_idv, short remap_flags) +void BKE_libblock_remap(struct Main *bmain, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(1, 2); /** @@ -130,12 +152,12 @@ void BKE_libblock_unlink(struct Main *bmain, * * \param old_idv: Unlike BKE_libblock_remap, can be NULL, * in which case all ID usages by given \a idv will be cleared. + * + * \param bmain: May be NULL, in which case there won't be depsgraph updates nor post-processing on + * some ID types (like collections or objects) to ensure their runtime data is valid. */ -void BKE_libblock_relink_ex(struct Main *bmain, - void *idv, - void *old_idv, - void *new_idv, - short remap_flags) ATTR_NONNULL(1, 2); +void BKE_libblock_relink_ex( + struct Main *bmain, void *idv, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(2); /** * Same as #BKE_libblock_relink_ex, but applies all rules defined in \a id_remapper to \a ids (or * does cleanup if `ID_REMAP_TYPE_CLEANUP` is specified as \a remap_type). @@ -144,7 +166,7 @@ void BKE_libblock_relink_multiple(struct Main *bmain, struct LinkNode *ids, eIDRemapType remap_type, struct IDRemapper *id_remapper, - short remap_flags); + int remap_flags); /** * Remaps ID usages of given ID to their `id->newid` pointer if not None, and proceeds recursively diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 4e670d8e2b6..6c6afce56f2 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -800,10 +800,7 @@ BLI_INLINE const int *BKE_mesh_poly_offsets(const Mesh *mesh) { return mesh->poly_offset_indices; } -BLI_INLINE int *BKE_mesh_poly_offsets_for_write(Mesh *mesh) -{ - return mesh->poly_offset_indices; -} +int *BKE_mesh_poly_offsets_for_write(Mesh *mesh); BLI_INLINE const int *BKE_mesh_corner_verts(const Mesh *mesh) { diff --git a/source/blender/blenkernel/BKE_mesh_types.h b/source/blender/blenkernel/BKE_mesh_types.h index 21ccc8f7da0..2d4788bd1d7 100644 --- a/source/blender/blenkernel/BKE_mesh_types.h +++ b/source/blender/blenkernel/BKE_mesh_types.h @@ -16,6 +16,7 @@ # include "BLI_array.hh" # include "BLI_bit_vector.hh" # include "BLI_bounds_types.hh" +# include "BLI_implicit_sharing.hh" # include "BLI_math_vector_types.hh" # include "BLI_shared_cache.hh" # include "BLI_span.hh" @@ -96,6 +97,9 @@ struct MeshRuntime { /** Needed to ensure some thread-safety during render data pre-processing. */ std::mutex render_mutex; + /** Implicit sharing user count for #Mesh::poly_offset_indices. */ + ImplicitSharingInfoHandle *poly_offsets_sharing_info; + /** * A cache of bounds shared between data-blocks with unchanged positions. When changing positions * affect the bounds, the cache is "un-shared" with other geometries. See #SharedCache comments. diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 9dd11437dd2..66562ef0702 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -12,7 +12,7 @@ set(INC ../depsgraph ../draw ../functions - ../gpencil_modifiers + ../gpencil_modifiers_legacy ../gpu ../ikplugin ../imbuf @@ -525,7 +525,7 @@ set(LIB bf_depsgraph bf_draw bf_functions - bf_gpencil_modifiers + bf_gpencil_modifiers_legacy bf_gpu bf_ikplugin bf_imbuf diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 55739083f1e..f016ed52fe7 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -92,17 +92,19 @@ static int attribute_data_type_complexity(const eCustomDataType data_type) return 2; case CD_PROP_FLOAT: return 3; - case CD_PROP_FLOAT2: + case CD_PROP_INT32_2D: return 4; - case CD_PROP_FLOAT3: + case CD_PROP_FLOAT2: return 5; - case CD_PROP_BYTE_COLOR: + case CD_PROP_FLOAT3: return 6; - case CD_PROP_COLOR: + case CD_PROP_BYTE_COLOR: return 7; + case CD_PROP_COLOR: + return 8; #if 0 /* These attribute types are not supported yet. */ case CD_PROP_STRING: - return 6; + return 9; #endif default: /* Only accept "generic" custom data types used by the attribute system. */ diff --git a/source/blender/blenkernel/intern/blendfile_link_append.c b/source/blender/blenkernel/intern/blendfile_link_append.c index c5d77a517dc..7fe9f514e2a 100644 --- a/source/blender/blenkernel/intern/blendfile_link_append.c +++ b/source/blender/blenkernel/intern/blendfile_link_append.c @@ -923,8 +923,8 @@ static int foreach_libblock_link_append_callback(LibraryIDLinkCallbackData *cb_d { /* NOTE: It is important to also skip liboverride references here, as those should never be made * local. */ - if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_INTERNAL | IDWALK_CB_LOOPBACK | - IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) { + if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING | IDWALK_CB_INTERNAL | + IDWALK_CB_LOOPBACK | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) { return IDWALK_RET_NOP; } @@ -1426,7 +1426,7 @@ static void blendfile_library_relocate_remap(Main *bmain, ID *new_id, ReportList *reports, const bool do_reload, - const short remap_flags) + const int remap_flags) { BLI_assert(old_id); if (do_reload) { @@ -1594,8 +1594,8 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, BKE_layer_collection_resync_forbid(); /* Note that in reload case, we also want to replace indirect usages. */ - const short remap_flags = ID_REMAP_SKIP_NEVER_NULL_USAGE | - (do_reload ? 0 : ID_REMAP_SKIP_INDIRECT_USAGE); + const int remap_flags = ID_REMAP_SKIP_NEVER_NULL_USAGE | + (do_reload ? 0 : ID_REMAP_SKIP_INDIRECT_USAGE); for (item_idx = 0, itemlink = lapp_context->items.list; itemlink; item_idx++, itemlink = itemlink->next) { BlendfileLinkAppendContextItem *item = itemlink->link; diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 4222be8ce8a..9f8ab69be98 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -60,13 +60,24 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num) CustomData_add_layer_named( &this->point_data, CD_PROP_FLOAT3, CD_CONSTRUCT, this->point_num, ATTR_POSITION.c_str()); - this->curve_offsets = (int *)MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__); -#ifdef DEBUG - this->offsets_for_write().fill(-1); -#endif - this->offsets_for_write().first() = 0; - this->runtime = MEM_new(__func__); + + if (curve_num > 0) { + this->curve_offsets = static_cast( + MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__)); + this->runtime->curve_offsets_sharing_info = implicit_sharing::info_for_mem_free( + this->curve_offsets); +#ifdef DEBUG + this->offsets_for_write().fill(-1); +#endif + /* Set common values for convenience. */ + this->curve_offsets[0] = 0; + this->curve_offsets[this->curve_num] = this->point_num; + } + else { + this->curve_offsets = nullptr; + } + /* Fill the type counts with the default so they're in a valid state. */ this->runtime->type_counts[CURVE_TYPE_CATMULL_ROM] = curve_num; } @@ -83,9 +94,10 @@ static void copy_curves_geometry(CurvesGeometry &dst, const CurvesGeometry &src) CustomData_copy(&src.point_data, &dst.point_data, CD_MASK_ALL, dst.point_num); CustomData_copy(&src.curve_data, &dst.curve_data, CD_MASK_ALL, dst.curve_num); - MEM_SAFE_FREE(dst.curve_offsets); - dst.curve_offsets = (int *)MEM_malloc_arrayN(dst.point_num + 1, sizeof(int), __func__); - dst.offsets_for_write().copy_from(src.offsets()); + implicit_sharing::copy_shared_pointer(src.curve_offsets, + src.runtime->curve_offsets_sharing_info, + &dst.curve_offsets, + &dst.runtime->curve_offsets_sharing_info); dst.tag_topology_changed(); @@ -127,7 +139,6 @@ static void move_curves_geometry(CurvesGeometry &dst, CurvesGeometry &src) src.curve_num = 0; std::swap(dst.curve_offsets, src.curve_offsets); - MEM_SAFE_FREE(src.curve_offsets); std::swap(dst.runtime, src.runtime); } @@ -149,7 +160,8 @@ CurvesGeometry::~CurvesGeometry() { CustomData_free(&this->point_data, this->point_num); CustomData_free(&this->curve_data, this->curve_num); - MEM_SAFE_FREE(this->curve_offsets); + implicit_sharing::free_shared_data(&this->curve_offsets, + &this->runtime->curve_offsets_sharing_info); MEM_delete(this->runtime); this->runtime = nullptr; } @@ -326,6 +338,8 @@ Span CurvesGeometry::offsets() const } MutableSpan CurvesGeometry::offsets_for_write() { + implicit_sharing::make_trivial_data_mutable( + &this->curve_offsets, &this->runtime->curve_offsets_sharing_info, this->curve_num + 1); return {this->curve_offsets, this->curve_num + 1}; } @@ -948,8 +962,14 @@ void CurvesGeometry::resize(const int points_num, const int curves_num) } if (curves_num != this->curve_num) { CustomData_realloc(&this->curve_data, this->curves_num(), curves_num); + implicit_sharing::resize_trivial_array(&this->curve_offsets, + &this->runtime->curve_offsets_sharing_info, + this->curve_num == 0 ? 0 : (this->curve_num + 1), + curves_num + 1); + /* Set common values for convenience. */ + this->curve_offsets[0] = 0; + this->curve_offsets[curves_num] = this->point_num; this->curve_num = curves_num; - this->curve_offsets = (int *)MEM_reallocN(this->curve_offsets, sizeof(int) * (curves_num + 1)); } this->tag_topology_changed(); } @@ -1585,7 +1605,11 @@ void CurvesGeometry::blend_read(BlendDataReader &reader) CustomData_blend_read(&reader, &this->point_data, this->point_num); CustomData_blend_read(&reader, &this->curve_data, this->curve_num); - BLO_read_int32_array(&reader, this->curve_num + 1, &this->curve_offsets); + if (this->curve_offsets) { + BLO_read_int32_array(&reader, this->curve_num + 1, &this->curve_offsets); + this->runtime->curve_offsets_sharing_info = implicit_sharing::info_for_mem_free( + this->curve_offsets); + } /* Recalculate curve type count cache that isn't saved in files. */ this->update_curve_types(); diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 28ae7bfa145..eda5e0482c0 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -1892,8 +1892,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(float), "MFloatProperty", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 45: CD_PROP_INT8 */ {sizeof(int8_t), "MInt8Property", 1, N_("Int8"), nullptr, nullptr, nullptr, nullptr, nullptr}, - /* 46: CD_HAIRMAPPING */ /* UNUSED */ - {-1, "", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, + /* 46: CD_PROP_INT32_2D */ + {sizeof(vec2i), "vec2i", 1, N_("Int 2D"), nullptr, nullptr, nullptr, nullptr, nullptr}, /* 47: CD_PROP_COLOR */ {sizeof(MPropCol), "MPropCol", @@ -5360,6 +5360,8 @@ const blender::CPPType *custom_data_type_to_cpp_type(const eCustomDataType type) return &CPPType::get(); case CD_PROP_INT32: return &CPPType::get(); + case CD_PROP_INT32_2D: + return &CPPType::get(); case CD_PROP_COLOR: return &CPPType::get(); case CD_PROP_BOOL: @@ -5389,6 +5391,9 @@ eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) if (type.is()) { return CD_PROP_INT32; } + if (type.is()) { + return CD_PROP_INT32_2D; + } if (type.is()) { return CD_PROP_COLOR; } diff --git a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc index 13f70cbf1bd..a502ca8f174 100644 --- a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc @@ -649,7 +649,7 @@ bool BKE_gpencil_stroke_stretch(bGPDstroke *gps, if (!isfinite(used_percent_length)) { /* #used_percent_length must always be finite, otherwise a segfault occurs. * Since this function should never segfault, set #used_percent_length to a safe fallback. */ - /* NOTE: This fallback is used if gps->totpoints == 2, see MOD_gpencillength.c */ + /* NOTE: This fallback is used if gps->totpoints == 2, see MOD_gpencil_legacy_length.c */ used_percent_length = 0.1f; } diff --git a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c index b9977f637bb..0fe854a7c3b 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c @@ -43,8 +43,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_gpencil_lineart.h" -#include "MOD_gpencil_modifiertypes.h" +#include "MOD_gpencil_legacy_lineart.h" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "BLO_read_write.h" @@ -329,7 +329,7 @@ void BKE_gpencil_frame_active_set(Depsgraph *depsgraph, bGPdata *gpd) void BKE_gpencil_modifier_init(void) { /* Initialize modifier types */ - gpencil_modifier_type_init(modifier_gpencil_types); /* MOD_gpencil_util.c */ + gpencil_modifier_type_init(modifier_gpencil_types); /* MOD_gpencil_legacy_util.c */ #if 0 /* Note that GPencil actually does not support these at the moment, diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 757d2390f22..0d9ff62a2ed 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -404,7 +404,7 @@ static int lib_id_expand_local_cb(LibraryIDLinkCallbackData *cb_data) return IDWALK_RET_NOP; } - if (cb_flag & IDWALK_CB_EMBEDDED) { + if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING)) { /* Embedded data-blocks need to be made fully local as well. * Note however that in some cases (when owner ID had to be duplicated instead of being made * local directly), its embedded IDs should also have already been duplicated, and hence be @@ -1494,12 +1494,11 @@ bool BKE_id_new_name_validate( return result; } - /* if no name given, use name of current ID - * else make a copy (tname args can be const) */ + /* If no name given, use name of current ID. */ if (tname == NULL) { tname = id->name + 2; } - + /* Make a copy of given name (tname args can be const). */ BLI_strncpy(name, tname, sizeof(name)); if (name[0] == '\0') { diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 2b6a4a7f4aa..a32ea01ce2a 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -696,7 +696,8 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain, /* An ID user is 'valid' (i.e. may affect the 'used'/'not used' status of the ID it uses) if it * does not match `ignored_usages`, and does match `required_usages`. */ - const int ignored_usages = (IDWALK_CB_LOOPBACK | IDWALK_CB_EMBEDDED); + const int ignored_usages = (IDWALK_CB_LOOPBACK | IDWALK_CB_EMBEDDED | + IDWALK_CB_EMBEDDED_NOT_OWNING); const int required_usages = (IDWALK_CB_USER | IDWALK_CB_USER_ONE); /* This ID may be tagged as unused if none of its users are 'valid', as defined above. diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index 7376ea3f39a..857ad6f1e6e 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -60,7 +60,7 @@ typedef struct IDRemap { /** The ID in which we are replacing old_id by new_id usages. */ ID *id_owner; - short flag; + int flag; } IDRemap; /* IDRemap->flag enums defined in BKE_lib.h */ @@ -104,30 +104,46 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner, const IDRemapperApplyOptions id_remapper_options, const int cb_flag, const bool is_indirect, - const bool violates_never_null, - const bool force_user_refcount) + const bool violates_never_null) { + const bool skip_update_tagging = (id_remap_data->flag & ID_REMAP_SKIP_UPDATE_TAGGING) != 0; + const bool skip_user_refcount = (id_remap_data->flag & ID_REMAP_SKIP_USER_REFCOUNT) != 0; + const bool force_user_refcount = (id_remap_data->flag & ID_REMAP_FORCE_USER_REFCOUNT) != 0; + BLI_assert(!skip_user_refcount || !force_user_refcount); + ID *old_id = *id_ptr; if (!violates_never_null) { BKE_id_remapper_apply_ex(mappings, id_ptr, id_remapper_options, id_self); - DEG_id_tag_update_ex(id_remap_data->bmain, - id_self, - ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - if (id_self != id_owner) { - DEG_id_tag_update_ex(id_remap_data->bmain, - id_owner, - ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - } - if (GS(id_owner->name) == ID_NT) { - /* Make sure that the node tree is updated after a property in it changed. Ideally, we would - * know which nodes property was changed so that only this node is tagged. */ - BKE_ntree_update_tag_all((bNodeTree *)id_owner); + if (!skip_update_tagging) { + if (id_remap_data->bmain != NULL) { + DEG_id_tag_update_ex(id_remap_data->bmain, + id_self, + ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + if (id_self != id_owner) { + DEG_id_tag_update_ex(id_remap_data->bmain, + id_owner, + ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + } + } + if (GS(id_owner->name) == ID_NT) { + /* Make sure that the node tree is updated after a property in it changed. Ideally, we + * would know which nodes property was changed so that only this node is tagged. */ + BKE_ntree_update_tag_all((bNodeTree *)id_owner); + } } } /* Get the new_id pointer. When the mapping is violating never null we should use a NULL * pointer otherwise the incorrect users are decreased and increased on the same instance. */ ID *new_id = violates_never_null ? NULL : *id_ptr; + if (!is_indirect && new_id) { + new_id->runtime.remap.status |= ID_REMAP_IS_LINKED_DIRECT; + } + + if (skip_user_refcount) { + return; + } + if (cb_flag & IDWALK_CB_USER) { /* NOTE: by default we don't user-count IDs which are not in the main database. * This is because in certain conditions we can have data-blocks in @@ -148,16 +164,13 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner, /* We cannot affect old_id->us directly, LIB_TAG_EXTRAUSER(_SET) * are assumed to be set as needed, that extra user is processed in final handling. */ } - if (!is_indirect && new_id) { - new_id->runtime.remap.status |= ID_REMAP_IS_LINKED_DIRECT; - } } static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) { const int cb_flag = cb_data->cb_flag; - if (cb_flag & IDWALK_CB_EMBEDDED) { + if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING)) { return IDWALK_RET_NOP; } @@ -218,7 +231,6 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0); const bool skip_reference = (id_remap_data->flag & ID_REMAP_SKIP_OVERRIDE_LIBRARY) != 0; const bool skip_never_null = (id_remap_data->flag & ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0; - const bool force_user_refcount = (id_remap_data->flag & ID_REMAP_FORCE_USER_REFCOUNT) != 0; #ifdef DEBUG_PRINT printf( @@ -264,8 +276,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) id_remapper_options, cb_flag, is_indirect, - violates_never_null, - force_user_refcount); + violates_never_null); } return IDWALK_RET_NOP; @@ -449,7 +460,8 @@ static void libblock_remap_reset_remapping_status_callback(ID *old_id, * (i.e. \a id does not references any other data-block anymore). * + If \a old_id is non-NULL, behavior is as with a NULL \a id, but only within given \a id. * - * \param bmain: the Main data storage to operate on (must never be NULL). + * \param bmain: the Main data storage to operate on (may be NULL, in which case part of the + * post-process/depsgraph update won't happen). * \param id: the data-block to operate on * (can be NULL, in which case we operate over all IDs from given bmain). * \param old_id: the data-block to dereference (may be NULL if \a id is non-NULL). @@ -457,17 +469,18 @@ static void libblock_remap_reset_remapping_status_callback(ID *old_id, * \param r_id_remap_data: if non-NULL, the IDRemap struct to use * (useful to retrieve info about remapping process). */ -ATTR_NONNULL(1) static void libblock_remap_data(Main *bmain, ID *id, eIDRemapType remap_type, struct IDRemapper *id_remapper, - const short remap_flags) + const int remap_flags) { IDRemap id_remap_data = {0}; - const int foreach_id_flags = ((remap_flags & ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS) != 0 ? - IDWALK_DO_INTERNAL_RUNTIME_POINTERS : - IDWALK_NOP); + const int foreach_id_flags = + (((remap_flags & ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS) != 0 ? + IDWALK_DO_INTERNAL_RUNTIME_POINTERS : + IDWALK_NOP) | + ((remap_flags & ID_REMAP_FORCE_UI_POINTERS) != 0 ? IDWALK_INCLUDE_UI : IDWALK_NOP)); id_remap_data.id_remapper = id_remapper; id_remap_data.type = remap_type; @@ -519,7 +532,7 @@ static void libblock_remap_data(Main *bmain, typedef struct LibblockRemapMultipleUserData { Main *bmain; - short remap_flags; + int remap_flags; } LibBlockRemapMultipleUserData; static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_data) @@ -530,7 +543,7 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ LibBlockRemapMultipleUserData *data = user_data; Main *bmain = data->bmain; - const short remap_flags = data->remap_flags; + const int remap_flags = data->remap_flags; BLI_assert(old_id != NULL); BLI_assert((new_id == NULL) || GS(old_id->name) == GS(new_id->name)); @@ -614,7 +627,7 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ void BKE_libblock_remap_multiple_locked(Main *bmain, struct IDRemapper *mappings, - const short remap_flags) + const int remap_flags) { if (BKE_id_remapper_is_empty(mappings)) { /* Early exit nothing to do. */ @@ -640,7 +653,23 @@ void BKE_libblock_remap_multiple_locked(Main *bmain, DEG_relations_tag_update(bmain); } -void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const short remap_flags) +void BKE_libblock_remap_multiple_raw(Main *bmain, + struct IDRemapper *mappings, + const int remap_flags) +{ + if (BKE_id_remapper_is_empty(mappings)) { + /* Early exit nothing to do. */ + return; + } + + libblock_remap_data(bmain, + NULL, + ID_REMAP_TYPE_REMAP, + mappings, + remap_flags | ID_REMAP_SKIP_USER_REFCOUNT | ID_REMAP_SKIP_UPDATE_TAGGING); +} + +void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const int remap_flags) { struct IDRemapper *remapper = BKE_id_remapper_create(); ID *old_id = old_idv; @@ -650,7 +679,7 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const BKE_id_remapper_free(remapper); } -void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const short remap_flags) +void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const int remap_flags) { BKE_main_lock(bmain); @@ -659,7 +688,7 @@ void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const short r BKE_main_unlock(bmain); } -void BKE_libblock_remap_multiple(Main *bmain, struct IDRemapper *mappings, const short remap_flags) +void BKE_libblock_remap_multiple(Main *bmain, struct IDRemapper *mappings, const int remap_flags) { BKE_main_lock(bmain); @@ -673,8 +702,8 @@ void BKE_libblock_unlink(Main *bmain, const bool do_flag_never_null, const bool do_skip_indirect) { - const short remap_flags = (do_skip_indirect ? ID_REMAP_SKIP_INDIRECT_USAGE : 0) | - (do_flag_never_null ? ID_REMAP_FLAG_NEVER_NULL_USAGE : 0); + const int remap_flags = (do_skip_indirect ? ID_REMAP_SKIP_INDIRECT_USAGE : 0) | + (do_flag_never_null ? ID_REMAP_FLAG_NEVER_NULL_USAGE : 0); BKE_main_lock(bmain); @@ -756,7 +785,7 @@ void BKE_libblock_relink_multiple(Main *bmain, LinkNode *ids, const eIDRemapType remap_type, struct IDRemapper *id_remapper, - const short remap_flags) + const int remap_flags) { BLI_assert(remap_type == ID_REMAP_TYPE_REMAP || BKE_id_remapper_is_empty(id_remapper)); @@ -765,6 +794,10 @@ void BKE_libblock_relink_multiple(Main *bmain, libblock_remap_data(bmain, id_iter, remap_type, id_remapper, remap_flags); } + if (bmain == NULL) { + return; + } + switch (remap_type) { case ID_REMAP_TYPE_REMAP: { LibBlockRelinkMultipleUserData user_data = {0}; @@ -815,7 +848,7 @@ void BKE_libblock_relink_multiple(Main *bmain, } void BKE_libblock_relink_ex( - Main *bmain, void *idv, void *old_idv, void *new_idv, const short remap_flags) + Main *bmain, void *idv, void *old_idv, void *new_idv, const int remap_flags) { /* Should be able to replace all _relink() functions (constraints, rigidbody, etc.) ? */ @@ -857,7 +890,8 @@ static void libblock_relink_to_newid_prepare_data(Main *bmain, static int id_relink_to_newid_looper(LibraryIDLinkCallbackData *cb_data) { const int cb_flag = cb_data->cb_flag; - if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) { + if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING | + IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) { return IDWALK_RET_NOP; } @@ -904,8 +938,8 @@ void BKE_libblock_relink_to_newid(Main *bmain, ID *id, const int remap_flag) libblock_relink_to_newid_prepare_data(bmain, id, &relink_data); - const short remap_flag_final = remap_flag | ID_REMAP_SKIP_INDIRECT_USAGE | - ID_REMAP_SKIP_OVERRIDE_LIBRARY; + const int remap_flag_final = remap_flag | ID_REMAP_SKIP_INDIRECT_USAGE | + ID_REMAP_SKIP_OVERRIDE_LIBRARY; BKE_libblock_relink_multiple( bmain, relink_data.ids, ID_REMAP_TYPE_REMAP, relink_data.id_remapper, remap_flag_final); diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 42af11294c9..0b777a803bf 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -137,8 +137,13 @@ static void light_blend_write(BlendWriter *writer, ID *id, const void *id_addres /* Node-tree is integral part of lights, no libdata. */ if (la->nodetree) { - BLO_write_struct(writer, bNodeTree, la->nodetree); - ntreeBlendWrite(writer, la->nodetree); + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &la->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address( + writer, bNodeTree, la->nodetree, BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite(writer, (bNodeTree *)BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } BKE_previewimg_blend_write(writer, la->preview); diff --git a/source/blender/blenkernel/intern/linestyle.cc b/source/blender/blenkernel/intern/linestyle.cc index 8f1c63bb406..de5cd553928 100644 --- a/source/blender/blenkernel/intern/linestyle.cc +++ b/source/blender/blenkernel/intern/linestyle.cc @@ -463,8 +463,17 @@ static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_ad } } if (linestyle->nodetree) { - BLO_write_struct(writer, bNodeTree, linestyle->nodetree); - ntreeBlendWrite(writer, linestyle->nodetree); + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &linestyle->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address(writer, + bNodeTree, + linestyle->nodetree, + BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite( + writer, + reinterpret_cast(BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer))); + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } } diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index 1b44c10bf28..fde5a40f765 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -185,8 +185,15 @@ static void material_blend_write(BlendWriter *writer, ID *id, const void *id_add /* nodetree is integral part of material, no libdata */ if (ma->nodetree) { - BLO_write_struct(writer, bNodeTree, ma->nodetree); - ntreeBlendWrite(writer, ma->nodetree); + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &ma->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address( + writer, bNodeTree, ma->nodetree, BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite( + writer, + reinterpret_cast(BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer))); + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } BKE_previewimg_blend_write(writer, ma->preview); diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index b1ed15eb31b..5f41ce1aa78 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -22,6 +22,7 @@ #include "BLI_endian_switch.h" #include "BLI_ghash.h" #include "BLI_hash.h" +#include "BLI_implicit_sharing.hh" #include "BLI_index_range.hh" #include "BLI_linklist.h" #include "BLI_listbase.h" @@ -154,7 +155,10 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int CustomData_copy(&mesh_src->edata, &mesh_dst->edata, mask.emask, mesh_dst->totedge); CustomData_copy(&mesh_src->ldata, &mesh_dst->ldata, mask.lmask, mesh_dst->totloop); CustomData_copy(&mesh_src->pdata, &mesh_dst->pdata, mask.pmask, mesh_dst->totpoly); - mesh_dst->poly_offset_indices = static_cast(MEM_dupallocN(mesh_src->poly_offset_indices)); + blender::implicit_sharing::copy_shared_pointer(mesh_src->poly_offset_indices, + mesh_src->runtime->poly_offsets_sharing_info, + &mesh_dst->poly_offset_indices, + &mesh_dst->runtime->poly_offsets_sharing_info); if (do_tessface) { CustomData_copy(&mesh_src->fdata, &mesh_dst->fdata, mask.fmask, mesh_dst->totface); } @@ -368,8 +372,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_list(reader, &mesh->vertex_group_names); - BLO_read_int32_array(reader, mesh->totpoly + 1, &mesh->poly_offset_indices); - CustomData_blend_read(reader, &mesh->vdata, mesh->totvert); CustomData_blend_read(reader, &mesh->edata, mesh->totedge); CustomData_blend_read(reader, &mesh->fdata, mesh->totface); @@ -388,6 +390,12 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id) mesh->runtime = new blender::bke::MeshRuntime(); + if (mesh->poly_offset_indices) { + BLO_read_int32_array(reader, mesh->totpoly + 1, &mesh->poly_offset_indices); + mesh->runtime->poly_offsets_sharing_info = blender::implicit_sharing::info_for_mem_free( + mesh->poly_offset_indices); + } + /* happens with old files */ if (mesh->mselect == nullptr) { mesh->totselect = 0; @@ -616,6 +624,16 @@ static int customdata_compare( BLI_edgehash_free(eh, nullptr); break; } + case CD_PROP_INT32_2D: { + const blender::int2 *l1_data = static_cast(l1->data); + const blender::int2 *l2_data = static_cast(l2->data); + for (int i = 0; i < total_length; i++) { + if (l1_data[i] != l2_data[i]) { + return MESHCMP_ATTRIBUTE_VALUE_MISMATCH; + } + } + break; + } case CD_PROP_BYTE_COLOR: { MLoopCol *lp1 = (MLoopCol *)l1->data; MLoopCol *lp2 = (MLoopCol *)l2->data; @@ -911,8 +929,10 @@ static void mesh_clear_geometry(Mesh &mesh) CustomData_free(&mesh.fdata, mesh.totface); CustomData_free(&mesh.ldata, mesh.totloop); CustomData_free(&mesh.pdata, mesh.totpoly); - MEM_SAFE_FREE(mesh.poly_offset_indices); - + if (mesh.poly_offset_indices) { + blender::implicit_sharing::free_shared_data(&mesh.poly_offset_indices, + &mesh.runtime->poly_offsets_sharing_info); + } MEM_SAFE_FREE(mesh.mselect); mesh.totvert = 0; @@ -966,20 +986,31 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name) void BKE_mesh_poly_offsets_ensure_alloc(Mesh *mesh) { BLI_assert(mesh->poly_offset_indices == nullptr); + BLI_assert(mesh->runtime->poly_offsets_sharing_info == nullptr); if (mesh->totpoly == 0) { return; } mesh->poly_offset_indices = static_cast( MEM_malloc_arrayN(mesh->totpoly + 1, sizeof(int), __func__)); + mesh->runtime->poly_offsets_sharing_info = blender::implicit_sharing::info_for_mem_free( + mesh->poly_offset_indices); #ifdef DEBUG /* Fill offsets with obviously bad values to simplify finding missing initialization. */ mesh->poly_offsets_for_write().fill(-1); #endif + /* Set common values for convenience. */ mesh->poly_offset_indices[0] = 0; mesh->poly_offset_indices[mesh->totpoly] = mesh->totloop; } +int *BKE_mesh_poly_offsets_for_write(Mesh *mesh) +{ + blender::implicit_sharing::make_trivial_data_mutable( + &mesh->poly_offset_indices, &mesh->runtime->poly_offsets_sharing_info, mesh->totpoly + 1); + return mesh->poly_offset_indices; +} + static void mesh_ensure_cdlayers_primary(Mesh &mesh) { if (!CustomData_get_layer_named(&mesh.vdata, CD_PROP_FLOAT3, "position")) { diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 343c4a7529f..0e8cbda75ff 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -1128,6 +1128,8 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob) CustomData_copy(&mesh_src->pdata, &mesh_dst->pdata, mask.pmask, mesh_src->totpoly); CustomData_copy(&mesh_src->ldata, &mesh_dst->ldata, mask.lmask, mesh_src->totloop); std::swap(mesh_dst->poly_offset_indices, mesh_src->poly_offset_indices); + std::swap(mesh_dst->runtime->poly_offsets_sharing_info, + mesh_src->runtime->poly_offsets_sharing_info); /* Make sure attribute names are moved. */ std::swap(mesh_dst->active_color_attribute, mesh_src->active_color_attribute); diff --git a/source/blender/blenkernel/intern/mesh_runtime.cc b/source/blender/blenkernel/intern/mesh_runtime.cc index 7935b6d692b..714d5edacb1 100644 --- a/source/blender/blenkernel/intern/mesh_runtime.cc +++ b/source/blender/blenkernel/intern/mesh_runtime.cc @@ -241,6 +241,7 @@ void BKE_mesh_tag_edges_split(struct Mesh *mesh) mesh->runtime->subsurf_optimal_display_edges.clear_and_shrink(); if (mesh->runtime->shrinkwrap_data) { BKE_shrinkwrap_boundary_data_free(mesh->runtime->shrinkwrap_data); + mesh->runtime->shrinkwrap_data = nullptr; } } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index b0d16a98b00..0550c2ed338 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -763,7 +763,7 @@ static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase * anyway... */ const int cb_flag = (lc->collection != nullptr && (lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ? - IDWALK_CB_EMBEDDED : + IDWALK_CB_EMBEDDED_NOT_OWNING : IDWALK_CB_NOP; BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, lc->collection, cb_flag | IDWALK_CB_DIRECT_WEAK_LINK); scene_foreach_layer_collection(data, &lc->layer_collections); @@ -947,6 +947,8 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres { Scene *sce = (Scene *)id; + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + if (BLO_write_is_undo(writer)) { /* Clean up, important in undo case to reduce false detection of changed data-blocks. */ /* XXX This UI data should not be stored in Scene at all... */ @@ -1074,8 +1076,15 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres } if (sce->nodetree) { - BLO_write_struct(writer, bNodeTree, sce->nodetree); - ntreeBlendWrite(writer, sce->nodetree); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &sce->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address(writer, + bNodeTree, + sce->nodetree, + BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite( + writer, + reinterpret_cast(BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer))); } BKE_color_managed_view_settings_blend_write(writer, &sce->view_settings); @@ -1102,8 +1111,15 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres } if (sce->master_collection) { - BLO_write_struct(writer, Collection, sce->master_collection); - BKE_collection_blend_write_nolib(writer, sce->master_collection); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &sce->master_collection->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address(writer, + Collection, + sce->master_collection, + BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + BKE_collection_blend_write_nolib( + writer, + reinterpret_cast(BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer))); } /* Eevee Light-cache */ @@ -1116,6 +1132,8 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres /* Freed on `do_versions()`. */ BLI_assert(sce->layer_properties == nullptr); + + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene, Paint **paint) diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index c62443303f1..7c60d2351fc 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -85,6 +85,9 @@ static void screen_foreach_id_dopesheet(LibraryForeachIDData *data, bDopeSheet * void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area) { + const bool is_readonly = (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_READONLY) != + 0; + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, area->full, IDWALK_CB_NOP); /* TODO: this should be moved to a callback in `SpaceType`, defined in each editor's own code. @@ -105,26 +108,55 @@ void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area SpaceGraph *sipo = (SpaceGraph *)sl; BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, screen_foreach_id_dopesheet(data, sipo->ads)); + + if (!is_readonly) { + /* Force recalc of list of channels (i.e. including calculating F-Curve colors) to + * prevent the "black curves" problem post-undo. */ + sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR; + } break; } case SPACE_PROPERTIES: { SpaceProperties *sbuts = (SpaceProperties *)sl; BKE_LIB_FOREACHID_PROCESS_ID(data, sbuts->pinid, IDWALK_CB_NOP); + if (!is_readonly) { + if (sbuts->pinid == NULL) { + sbuts->flag &= ~SB_PIN_CONTEXT; + } + /* Note: Restoring path pointers is complicated, if not impossible, because this contains + * data pointers too, not just ID ones. See #40046. */ + MEM_SAFE_FREE(sbuts->path); + } break; } - case SPACE_FILE: + case SPACE_FILE: { + if (!is_readonly) { + SpaceFile *sfile = (SpaceFile *)sl; + sfile->op = NULL; + sfile->tags = FILE_TAG_REBUILD_MAIN_FILES; + } break; + } case SPACE_ACTION: { SpaceAction *saction = (SpaceAction *)sl; screen_foreach_id_dopesheet(data, &saction->ads); BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, saction->action, IDWALK_CB_NOP); + if (!is_readonly) { + /* Force recalc of list of channels, potentially updating the active action while we're + * at it (as it can only be updated that way) #28962. */ + saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC; + } break; } case SPACE_IMAGE: { SpaceImage *sima = (SpaceImage *)sl; BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, sima->image, IDWALK_CB_USER_ONE); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, sima->iuser.scene, IDWALK_CB_NOP); BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, sima->mask_info.mask, IDWALK_CB_USER_ONE); BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, sima->gpd, IDWALK_CB_USER); + if (!is_readonly) { + sima->scopes.ok = 0; + } break; } case SPACE_SEQ: { @@ -156,45 +188,106 @@ void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area BLI_mempool_iternew(space_outliner->treestore, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { - BKE_LIB_FOREACHID_PROCESS_ID(data, tselem->id, IDWALK_CB_NOP); + /* Do not try to restore non-ID pointers (drivers/sequence/etc.). */ + if (TSE_IS_REAL_ID(tselem)) { + const int cb_flag = (tselem->id != NULL && + (tselem->id->flag & LIB_EMBEDDED_DATA) != 0) ? + IDWALK_CB_EMBEDDED_NOT_OWNING : + IDWALK_CB_NOP; + BKE_LIB_FOREACHID_PROCESS_ID(data, tselem->id, cb_flag); + } + else if (!is_readonly) { + tselem->id = NULL; + } + } + if (!is_readonly) { + /* rebuild hash table, because it depends on ids too */ + space_outliner->storeflag |= SO_TREESTORE_REBUILD; } } break; } case SPACE_NODE: { SpaceNode *snode = (SpaceNode *)sl; - const bool is_private_nodetree = snode->id != NULL && - ntreeFromID(snode->id) == snode->nodetree; + const bool is_embedded_nodetree = snode->id != NULL && + ntreeFromID(snode->id) == snode->nodetree; BKE_LIB_FOREACHID_PROCESS_ID(data, snode->id, IDWALK_CB_NOP); BKE_LIB_FOREACHID_PROCESS_ID(data, snode->from, IDWALK_CB_NOP); - BKE_LIB_FOREACHID_PROCESS_IDSUPER( - data, snode->nodetree, is_private_nodetree ? IDWALK_CB_EMBEDDED : IDWALK_CB_USER_ONE); - LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) { - if (path == snode->treepath.first) { - /* first nodetree in path is same as snode->nodetree */ - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, - path->nodetree, - is_private_nodetree ? IDWALK_CB_EMBEDDED : - IDWALK_CB_USER_ONE); + bNodeTreePath *path = snode->treepath.first; + BLI_assert(path == NULL || path->nodetree == snode->nodetree); + + if (is_embedded_nodetree) { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->nodetree, IDWALK_CB_EMBEDDED_NOT_OWNING); + if (path != NULL) { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, path->nodetree, IDWALK_CB_EMBEDDED_NOT_OWNING); } - else { + + /* Embedded ID pointers are not remapped (besides exceptions), ensure it still matches + * actual data. Note that `snode->id` was already processed (and therefore potentially + * remapped) above.*/ + if (!is_readonly && path != NULL) { + path->nodetree = snode->nodetree = (snode->id == NULL) ? NULL : ntreeFromID(snode->id); + } + } + else { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->nodetree, IDWALK_CB_USER_ONE); + if (path != NULL) { BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, path->nodetree, IDWALK_CB_USER_ONE); } - - if (path->nodetree == NULL) { - break; - } } - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->edittree, IDWALK_CB_NOP); + if (path != NULL) { + for (path = path->next; path != NULL; path = path->next) { + BLI_assert(path->nodetree != NULL); + BLI_assert((path->nodetree->id.flag & LIB_EMBEDDED_DATA) == 0); + + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, path->nodetree, IDWALK_CB_USER_ONE); + + if (path->nodetree == NULL) { + BLI_assert(!is_readonly); + /* Remaining path entries are invalid, remove them. */ + for (bNodeTreePath *path_next; path; path = path_next) { + path_next = path->next; + BLI_remlink(&snode->treepath, path); + MEM_freeN(path); + } + break; + } + } + } + BLI_assert(path == NULL); + + if (!is_readonly) { + /* `edittree` is just the last in the path, set this directly since the path may have + * been shortened above. */ + if (snode->treepath.last != NULL) { + path = snode->treepath.last; + snode->edittree = path->nodetree; + } + else { + snode->edittree = NULL; + } + } + /* NOTE: It is disputable whether this should be called here, especially when editing it is + * allowed? But for now, for sake of consistency, do it in any case. */ + if (is_embedded_nodetree && snode->edittree == snode->nodetree) { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->edittree, IDWALK_CB_EMBEDDED_NOT_OWNING); + } + else { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->edittree, IDWALK_CB_NOP); + } break; } case SPACE_CLIP: { SpaceClip *sclip = (SpaceClip *)sl; BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, sclip->clip, IDWALK_CB_USER_ONE); BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, sclip->mask_info.mask, IDWALK_CB_USER_ONE); + + if (!is_readonly) { + sclip->scopes.ok = 0; + } break; } case SPACE_SPREADSHEET: { diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc index c0e67b910f0..dabdad4b79f 100644 --- a/source/blender/blenkernel/intern/simulation.cc +++ b/source/blender/blenkernel/intern/simulation.cc @@ -107,8 +107,17 @@ static void simulation_blend_write(BlendWriter *writer, ID *id, const void *id_a /* nodetree is integral part of simulation, no libdata */ if (simulation->nodetree) { - BLO_write_struct(writer, bNodeTree, simulation->nodetree); - ntreeBlendWrite(writer, simulation->nodetree); + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &simulation->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address(writer, + bNodeTree, + simulation->nodetree, + BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite( + writer, + reinterpret_cast(BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer))); + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } } diff --git a/source/blender/blenkernel/intern/texture.cc b/source/blender/blenkernel/intern/texture.cc index ed385fae454..d2cb4c4b201 100644 --- a/source/blender/blenkernel/intern/texture.cc +++ b/source/blender/blenkernel/intern/texture.cc @@ -155,8 +155,17 @@ static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_addr /* nodetree is integral part of texture, no libdata */ if (tex->nodetree) { - BLO_write_struct(writer, bNodeTree, tex->nodetree); - ntreeBlendWrite(writer, tex->nodetree); + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &tex->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address(writer, + bNodeTree, + tex->nodetree, + BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite( + writer, + reinterpret_cast(BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer))); + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } BKE_previewimg_blend_write(writer, tex->preview); diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc index f1dea155225..094fb628698 100644 --- a/source/blender/blenkernel/intern/type_conversions.cc +++ b/source/blender/blenkernel/intern/type_conversions.cc @@ -51,6 +51,10 @@ static int32_t float_to_int(const float &a) { return int32_t(a); } +static int2 float_to_int2(const float &a) +{ + return int2(a); +} static bool float_to_bool(const float &a) { return a > 0.0f; @@ -81,6 +85,10 @@ static int float2_to_int(const float2 &a) { return int32_t((a.x + a.y) / 2.0f); } +static int2 float2_to_int2(const float2 &a) +{ + return int2(a.x, a.y); +} static bool float2_to_bool(const float2 &a) { return !math::is_zero(a); @@ -114,6 +122,10 @@ static int float3_to_int(const float3 &a) { return int((a.x + a.y + a.z) / 3.0f); } +static int2 float3_to_int2(const float3 &a) +{ + return int2(a.x, a.y); +} static float2 float3_to_float2(const float3 &a) { return float2(a); @@ -136,6 +148,10 @@ static int8_t int_to_int8(const int32_t &a) return std::clamp( a, int(std::numeric_limits::min()), int(std::numeric_limits::max())); } +static int2 int_to_int2(const int32_t &a) +{ + return int2(a); +} static float int_to_float(const int32_t &a) { return float(a); @@ -157,6 +173,39 @@ static ColorGeometry4b int_to_byte_color(const int32_t &a) return int_to_color(a).encode(); } +static bool int2_to_bool(const int2 &a) +{ + return !math::is_zero(a); +} +static float2 int2_to_float2(const int2 &a) +{ + return float2(a); +} +static int int2_to_int(const int2 &a) +{ + return math::midpoint(a.x, a.y); +} +static int8_t int2_to_int8(const int2 &a) +{ + return int_to_int8(int2_to_int(a)); +} +static float int2_to_float(const int2 &a) +{ + return float2_to_float(float2(a)); +} +static float3 int2_to_float3(const int2 &a) +{ + return float3(float(a.x), float(a.y), 0.0f); +} +static ColorGeometry4f int2_to_color(const int2 &a) +{ + return ColorGeometry4f(float(a.x), float(a.y), 0.0f, 1.0f); +} +static ColorGeometry4b int2_to_byte_color(const int2 &a) +{ + return int2_to_color(a).encode(); +} + static bool int8_to_bool(const int8_t &a) { return a > 0; @@ -165,6 +214,10 @@ static int int8_to_int(const int8_t &a) { return int(a); } +static int2 int8_to_int2(const int8_t &a) +{ + return int2(a); +} static float int8_to_float(const int8_t &a) { return float(a); @@ -198,6 +251,10 @@ static int32_t bool_to_int(const bool &a) { return int32_t(a); } +static int2 bool_to_int2(const bool &a) +{ + return int2(a); +} static float2 bool_to_float2(const bool &a) { return (a) ? float2(1.0f) : float2(0.0f); @@ -227,6 +284,10 @@ static int32_t color_to_int(const ColorGeometry4f &a) { return int(rgb_to_grayscale(a)); } +static int2 color_to_int2(const ColorGeometry4f &a) +{ + return int2(a.r, a.g); +} static int8_t color_to_int8(const ColorGeometry4f &a) { return int_to_int8(color_to_int(a)); @@ -256,6 +317,10 @@ static int32_t byte_color_to_int(const ColorGeometry4b &a) { return color_to_int(a.decode()); } +static int2 byte_color_to_int2(const ColorGeometry4b &a) +{ + return int2(a.r, a.g); +} static int8_t byte_color_to_int8(const ColorGeometry4b &a) { return color_to_int8(a.decode()); @@ -280,6 +345,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -288,6 +354,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -297,20 +364,32 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -320,6 +399,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -329,6 +409,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); @@ -337,6 +418,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); + add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); add_implicit_conversion(conversions); diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index c6c50ee068c..988e3e7a02e 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -144,8 +144,15 @@ static void world_blend_write(BlendWriter *writer, ID *id, const void *id_addres /* nodetree is integral part of world, no libdata */ if (wrld->nodetree) { - BLO_write_struct(writer, bNodeTree, wrld->nodetree); - ntreeBlendWrite(writer, wrld->nodetree); + BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer(); + BLO_write_init_id_buffer_from_id( + temp_embedded_id_buffer, &wrld->nodetree->id, BLO_write_is_undo(writer)); + BLO_write_struct_at_address(writer, + bNodeTree, + wrld->nodetree, + BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + ntreeBlendWrite(writer, (bNodeTree *)BLO_write_get_id_buffer_temp_id(temp_embedded_id_buffer)); + BLO_write_destroy_id_buffer(&temp_embedded_id_buffer); } BKE_previewimg_blend_write(writer, wrld->preview); diff --git a/source/blender/blenlib/BLI_implicit_sharing.hh b/source/blender/blenlib/BLI_implicit_sharing.hh index cb74367203c..36feadd4f1e 100644 --- a/source/blender/blenlib/BLI_implicit_sharing.hh +++ b/source/blender/blenlib/BLI_implicit_sharing.hh @@ -102,4 +102,83 @@ class ImplicitSharingMixin : public ImplicitSharingInfo { virtual void delete_self() = 0; }; +namespace implicit_sharing { + +namespace detail { + +void *resize_trivial_array_impl(void *old_data, + int64_t old_size, + int64_t new_size, + int64_t alignment, + ImplicitSharingInfo **sharing_info); +void *make_trivial_data_mutable_impl(void *old_data, + int64_t size, + int64_t alignment, + ImplicitSharingInfo **sharing_info); + +} // namespace detail + +/** + * Copy shared data from the source to the destination, adding a user count. + * \note Does not free any existing data in the destination. + */ +template +void copy_shared_pointer(T *src_ptr, + ImplicitSharingInfo *src_sharing_info, + T **r_dst_ptr, + ImplicitSharingInfo **r_dst_sharing_info) +{ + *r_dst_ptr = src_ptr; + *r_dst_sharing_info = src_sharing_info; + if (*r_dst_ptr) { + BLI_assert(*r_dst_sharing_info != nullptr); + (*r_dst_sharing_info)->add_user(); + } +} + +/** + * Remove this reference to the shared data and remove dangling pointers. + */ +template void free_shared_data(T **data, ImplicitSharingInfo **sharing_info) +{ + if (*sharing_info) { + BLI_assert(*data != nullptr); + (*sharing_info)->remove_user_and_delete_if_last(); + } + *data = nullptr; + *sharing_info = nullptr; +} + +/** + * Create an implicit sharing object that takes ownership of the data, allowing it to be shared. + * When it is no longer used, the data is freed with #MEM_freeN, so it must be a trivial type. + */ +ImplicitSharingInfo *info_for_mem_free(void *data); + +/** + * Make data mutable (single-user) if it is shared. For trivially-copyable data only. + */ +template +void make_trivial_data_mutable(T **data, ImplicitSharingInfo **sharing_info, const int64_t size) +{ + *data = static_cast( + detail::make_trivial_data_mutable_impl(*data, sizeof(T) * size, alignof(T), sharing_info)); +} + +/** + * Resize an array of shared data. For trivially-copyable data only. Any new values are not + * initialized. + */ +template +void resize_trivial_array(T **data, + ImplicitSharingInfo **sharing_info, + int64_t old_size, + int64_t new_size) +{ + *data = static_cast(detail::resize_trivial_array_impl( + *data, sizeof(T) * old_size, sizeof(T) * new_size, alignof(T), sharing_info)); +} + +} // namespace implicit_sharing + } // namespace blender diff --git a/source/blender/blenlib/BLI_math_base.hh b/source/blender/blenlib/BLI_math_base.hh index 87280eead3a..9ea04d604e4 100644 --- a/source/blender/blenlib/BLI_math_base.hh +++ b/source/blender/blenlib/BLI_math_base.hh @@ -194,11 +194,22 @@ inline T interpolate(const T &a, const T &b, const FactorT &t) template inline T midpoint(const T &a, const T &b) { - auto result = (a + b) * T(0.5); if constexpr (std::is_integral_v) { - result = std::round(result); + /** See std::midpoint from C++20. */ + using Unsigned = std::make_unsigned_t; + int sign = 1; + Unsigned smaller = a; + Unsigned larger = b; + if (a > b) { + sign = -1; + smaller = b; + larger = a; + } + return a + sign * T(Unsigned(larger - smaller) / 2); + } + else { + return (a + b) * T(0.5); } - return result; } } // namespace blender::math diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 9d80bce832e..8fd83c849a1 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -83,6 +83,7 @@ set(SRC intern/hash_md5.c intern/hash_mm2a.c intern/hash_mm3.c + intern/implicit_sharing.cc intern/index_mask.cc intern/jitter_2d.c intern/kdtree_1d.c diff --git a/source/blender/blenlib/PIL_time_utildefines.h b/source/blender/blenlib/PIL_time_utildefines.h index 03d69647b28..a9cf3351e32 100644 --- a/source/blender/blenlib/PIL_time_utildefines.h +++ b/source/blender/blenlib/PIL_time_utildefines.h @@ -104,6 +104,8 @@ } \ (void)0 +#define TIMEIT_BLOCK_VALUE(id) (float)(_timeit_var_##id) + #define TIMEIT_BLOCK_STATS(id) \ { \ printf("%s time (in seconds): %f\n", #id, _timeit_var_##id); \ diff --git a/source/blender/blenlib/intern/cpp_types.cc b/source/blender/blenlib/intern/cpp_types.cc index 083869c409d..573feff49b0 100644 --- a/source/blender/blenlib/intern/cpp_types.cc +++ b/source/blender/blenlib/intern/cpp_types.cc @@ -52,6 +52,7 @@ BLI_CPP_TYPE_MAKE(blender::float4x4, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int8_t, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int16_t, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int32_t, CPPTypeFlags::BasicType) +BLI_CPP_TYPE_MAKE(blender::int2, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(int64_t, CPPTypeFlags::BasicType) BLI_CPP_TYPE_MAKE(uint8_t, CPPTypeFlags::BasicType) @@ -80,6 +81,7 @@ void register_cpp_types() BLI_CPP_TYPE_REGISTER(int8_t); BLI_CPP_TYPE_REGISTER(int16_t); BLI_CPP_TYPE_REGISTER(int32_t); + BLI_CPP_TYPE_REGISTER(blender::int2); BLI_CPP_TYPE_REGISTER(int64_t); BLI_CPP_TYPE_REGISTER(uint8_t); diff --git a/source/blender/blenlib/intern/implicit_sharing.cc b/source/blender/blenlib/intern/implicit_sharing.cc new file mode 100644 index 00000000000..3ab1b61c1a5 --- /dev/null +++ b/source/blender/blenlib/intern/implicit_sharing.cc @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_implicit_sharing.hh" + +namespace blender::implicit_sharing { + +class MEMFreeImplicitSharing : public ImplicitSharingInfo { + public: + void *data; + + MEMFreeImplicitSharing(void *data) : ImplicitSharingInfo(1), data(data) + { + BLI_assert(data != nullptr); + } + + private: + void delete_self_with_data() override + { + MEM_freeN(data); + MEM_delete(this); + } +}; + +ImplicitSharingInfo *info_for_mem_free(void *data) +{ + return MEM_new(__func__, data); +} + +namespace detail { + +void *make_trivial_data_mutable_impl(void *old_data, + const int64_t size, + const int64_t alignment, + ImplicitSharingInfo **sharing_info) +{ + if (!old_data) { + BLI_assert(size == 0); + return nullptr; + } + + BLI_assert(*sharing_info != nullptr); + if ((*sharing_info)->is_shared()) { + void *new_data = MEM_mallocN_aligned(size, alignment, __func__); + memcpy(new_data, old_data, size); + (*sharing_info)->remove_user_and_delete_if_last(); + *sharing_info = info_for_mem_free(new_data); + return new_data; + } + + return old_data; +} + +void *resize_trivial_array_impl(void *old_data, + const int64_t old_size, + const int64_t new_size, + const int64_t alignment, + ImplicitSharingInfo **sharing_info) +{ + if (new_size == 0) { + if (*sharing_info) { + (*sharing_info)->remove_user_and_delete_if_last(); + *sharing_info = nullptr; + } + return nullptr; + } + + if (!old_data) { + BLI_assert(old_size == 0); + BLI_assert(*sharing_info == nullptr); + void *new_data = MEM_mallocN_aligned(new_size, alignment, __func__); + *sharing_info = info_for_mem_free(new_data); + return new_data; + } + + BLI_assert(old_size != 0); + if ((*sharing_info)->is_mutable()) { + if (auto *info = dynamic_cast(*sharing_info)) { + /* If the array was allocated with the MEM allocator, we can use realloc directly, which + * could theoretically give better performance if the data can be reused in place. */ + void *new_data = static_cast(MEM_reallocN(old_data, new_size)); + info->data = new_data; + return new_data; + } + } + + void *new_data = MEM_mallocN_aligned(new_size, alignment, __func__); + memcpy(new_data, old_data, std::min(old_size, new_size)); + (*sharing_info)->remove_user_and_delete_if_last(); + *sharing_info = info_for_mem_free(new_data); + return new_data; +} + +} // namespace detail + +} // namespace blender::implicit_sharing diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h index f1685d079e4..adf53d673e4 100644 --- a/source/blender/blenloader/BLO_read_write.h +++ b/source/blender/blenloader/BLO_read_write.h @@ -157,6 +157,23 @@ void blo_write_id_struct(BlendWriter *writer, #define BLO_write_id_struct(writer, struct_name, id_address, id) \ blo_write_id_struct(writer, BLO_get_struct_id(writer, struct_name), id_address, id) +/** + * Specific code to prepare IDs to be written. + * + * Required for writing properly embedded IDs currently. + * + * \note: Once there is a better generic handling of embedded IDs, this may go back to private code + * in writefile.c + */ +typedef struct BLO_Write_IDBuffer BLO_Write_IDBuffer; + +BLO_Write_IDBuffer *BLO_write_allocate_id_buffer(void); +void BLO_write_init_id_buffer_from_id(BLO_Write_IDBuffer *id_buffer, + struct ID *id, + const bool is_undo); +struct ID *BLO_write_get_id_buffer_temp_id(BLO_Write_IDBuffer *id_buffer); +void BLO_write_destroy_id_buffer(BLO_Write_IDBuffer **id_buffer); + /** * Write raw data. */ diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 948ade96855..77a01c6268a 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -2241,7 +2241,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data) { const int cb_flag = cb_data->cb_flag; ID **id_pointer = cb_data->id_pointer; - if (cb_flag & IDWALK_CB_EMBEDDED || *id_pointer == nullptr) { + if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING) || *id_pointer == nullptr) { return IDWALK_RET_NOP; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 77073ce2b3f..a8141e09ac9 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1269,7 +1269,7 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain) * it here :/ (expand element if it's the only one) */ TreeStoreElem *tselem = BLI_mempool_calloc(space_outliner->treestore); tselem->type = TSE_LAYER_COLLECTION; - tselem->id = layer->layer_collections.first; + tselem->id = &((LayerCollection *)(layer->layer_collections.first))->collection->id; tselem->nr = tselem->used = 0; tselem->flag &= ~TSE_CLOSED; } diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 0b5eb9aac51..9d04bb1759c 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -1088,6 +1088,78 @@ static void write_thumb(WriteData *wd, const BlendThumbnail *thumb) /** \name File Writing (Private) * \{ */ +#define ID_BUFFER_STATIC_SIZE 8192 + +typedef struct BLO_Write_IDBuffer { + const struct IDTypeInfo *id_type; + ID *temp_id; + char id_buffer_static[ID_BUFFER_STATIC_SIZE]; +} BLO_Write_IDBuffer; + +static void id_buffer_init_for_id_type(BLO_Write_IDBuffer *id_buffer, const IDTypeInfo *id_type) +{ + if (id_type != id_buffer->id_type) { + const size_t idtype_struct_size = id_type->struct_size; + if (idtype_struct_size > ID_BUFFER_STATIC_SIZE) { + CLOG_ERROR(&LOG, + "ID maximum buffer size (%d bytes) is not big enough to fit IDs of type %s, " + "which needs %lu bytes", + ID_BUFFER_STATIC_SIZE, + id_type->name, + idtype_struct_size); + id_buffer->temp_id = static_cast(MEM_mallocN(idtype_struct_size, __func__)); + } + else { + if (static_cast(id_buffer->temp_id) != id_buffer->id_buffer_static) { + MEM_SAFE_FREE(id_buffer->temp_id); + } + id_buffer->temp_id = reinterpret_cast(id_buffer->id_buffer_static); + } + id_buffer->id_type = id_type; + } +} + +static void id_buffer_init_from_id(BLO_Write_IDBuffer *id_buffer, ID *id, const bool is_undo) +{ + BLI_assert(id_buffer->id_type == BKE_idtype_get_info_from_id(id)); + + if (is_undo) { + /* Record the changes that happened up to this undo push in + * recalc_up_to_undo_push, and clear `recalc_after_undo_push` again + * to start accumulating for the next undo push. */ + id->recalc_up_to_undo_push = id->recalc_after_undo_push; + id->recalc_after_undo_push = 0; + } + + /* Copy ID data itself into buffer, to be able to freely modify it. */ + const size_t idtype_struct_size = id_buffer->id_type->struct_size; + ID *temp_id = id_buffer->temp_id; + memcpy(temp_id, id, idtype_struct_size); + + /* Clear runtime data to reduce false detection of changed data in undo/redo context. */ + if (is_undo) { + temp_id->tag &= LIB_TAG_KEEP_ON_UNDO; + } + else { + temp_id->tag = 0; + } + temp_id->us = 0; + temp_id->icon_id = 0; + /* Those listbase data change every time we add/remove an ID, and also often when + * renaming one (due to re-sorting). This avoids generating a lot of false 'is changed' + * detections between undo steps. */ + temp_id->prev = nullptr; + temp_id->next = nullptr; + /* Those runtime pointers should never be set during writing stage, but just in case clear + * them too. */ + temp_id->orig_id = nullptr; + temp_id->newid = nullptr; + /* Even though in theory we could be able to preserve this python instance across undo even + * when we need to re-read the ID into its original address, this is currently cleared in + * #direct_link_id_common in `readfile.c` anyway. */ + temp_id->py_instance = nullptr; +} + /* Helper callback for checking linked IDs used by given ID (assumed local), to ensure directly * linked data is tagged accordingly. */ static int write_id_direct_linked_data_process_cb(LibraryIDLinkCallbackData *cb_data) @@ -1187,11 +1259,11 @@ static bool write_file_handle(Main *mainvar, nullptr : BKE_lib_override_library_operations_store_init(); -#define ID_BUFFER_STATIC_SIZE 8192 /* This outer loop allows to save first data-blocks from real mainvar, * then the temp ones from override process, * if needed, without duplicating whole code. */ Main *bmain = mainvar; + BLO_Write_IDBuffer *id_buffer = BLO_write_allocate_id_buffer(); do { ListBase *lbarray[INDEX_ID_MAX]; int a = set_listbasepointers(bmain, lbarray); @@ -1202,19 +1274,8 @@ static bool write_file_handle(Main *mainvar, continue; /* Libraries are handled separately below. */ } - char id_buffer_static[ID_BUFFER_STATIC_SIZE]; - void *id_buffer = id_buffer_static; const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id); - const size_t idtype_struct_size = id_type->struct_size; - if (idtype_struct_size > ID_BUFFER_STATIC_SIZE) { - CLOG_ERROR(&LOG, - "ID maximum buffer size (%d bytes) is not big enough to fit IDs of type %s, " - "which needs %lu bytes", - ID_BUFFER_STATIC_SIZE, - id_type->name, - id_type->struct_size); - id_buffer = MEM_mallocN(idtype_struct_size, __func__); - } + id_buffer_init_for_id_type(id_buffer, id_type); for (; id; id = static_cast(id->next)) { /* We should never attempt to write non-regular IDs @@ -1249,57 +1310,12 @@ static bool write_file_handle(Main *mainvar, BKE_lib_override_library_operations_store_start(bmain, override_storage, id); } - if (wd->use_memfile) { - /* Record the changes that happened up to this undo push in - * recalc_up_to_undo_push, and clear `recalc_after_undo_push` again - * to start accumulating for the next undo push. */ - id->recalc_up_to_undo_push = id->recalc_after_undo_push; - id->recalc_after_undo_push = 0; - - bNodeTree *nodetree = ntreeFromID(id); - if (nodetree != nullptr) { - nodetree->id.recalc_up_to_undo_push = nodetree->id.recalc_after_undo_push; - nodetree->id.recalc_after_undo_push = 0; - } - if (GS(id->name) == ID_SCE) { - Scene *scene = (Scene *)id; - if (scene->master_collection != nullptr) { - scene->master_collection->id.recalc_up_to_undo_push = - scene->master_collection->id.recalc_after_undo_push; - scene->master_collection->id.recalc_after_undo_push = 0; - } - } - } - mywrite_id_begin(wd, id); - memcpy(id_buffer, id, idtype_struct_size); - - /* Clear runtime data to reduce false detection of changed data in undo/redo context. */ - if (wd->use_memfile) { - ((ID *)id_buffer)->tag &= LIB_TAG_KEEP_ON_UNDO; - } - else { - ((ID *)id_buffer)->tag = 0; - } - ((ID *)id_buffer)->us = 0; - ((ID *)id_buffer)->icon_id = 0; - /* Those listbase data change every time we add/remove an ID, and also often when - * renaming one (due to re-sorting). This avoids generating a lot of false 'is changed' - * detections between undo steps. */ - ((ID *)id_buffer)->prev = nullptr; - ((ID *)id_buffer)->next = nullptr; - /* Those runtime pointers should never be set during writing stage, but just in case clear - * them too. */ - ((ID *)id_buffer)->orig_id = nullptr; - ((ID *)id_buffer)->newid = nullptr; - /* Even though in theory we could be able to preserve this python instance across undo even - * when we need to re-read the ID into its original address, this is currently cleared in - * #direct_link_id_common in `readfile.c` anyway, */ - ((ID *)id_buffer)->py_instance = nullptr; + id_buffer_init_from_id(id_buffer, id, wd->use_memfile); if (id_type->blend_write != nullptr) { - id_type->blend_write(&writer, (ID *)id_buffer, id); + id_type->blend_write(&writer, static_cast(id_buffer->temp_id), id); } if (do_override) { @@ -1309,14 +1325,12 @@ static bool write_file_handle(Main *mainvar, mywrite_id_end(wd, id); } - if (id_buffer != id_buffer_static) { - MEM_SAFE_FREE(id_buffer); - } - mywrite_flush(wd); } } while ((bmain != override_storage) && (bmain = override_storage)); + BLO_write_destroy_id_buffer(&id_buffer); + if (override_storage) { BKE_lib_override_library_operations_store_finalize(override_storage); override_storage = nullptr; @@ -1571,6 +1585,39 @@ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int w return (err == 0); } +/* + * API to handle writing IDs while clearing some of their runtime data. + */ + +BLO_Write_IDBuffer *BLO_write_allocate_id_buffer() +{ + return MEM_cnew(__func__); +} + +void BLO_write_init_id_buffer_from_id(BLO_Write_IDBuffer *id_buffer, ID *id, const bool is_undo) +{ + const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id); + id_buffer_init_for_id_type(id_buffer, id_type); + id_buffer_init_from_id(id_buffer, id, is_undo); +} + +ID *BLO_write_get_id_buffer_temp_id(BLO_Write_IDBuffer *id_buffer) +{ + return id_buffer->temp_id; +} + +void BLO_write_destroy_id_buffer(BLO_Write_IDBuffer **id_buffer) +{ + if (static_cast((*id_buffer)->temp_id) != (*id_buffer)->id_buffer_static) { + MEM_SAFE_FREE((*id_buffer)->temp_id); + } + MEM_SAFE_FREE(*id_buffer); +} + +/* + * API to write chunks of data. + */ + void BLO_write_raw(BlendWriter *writer, size_t size_in_bytes, const void *data_ptr) { writedata(writer->wd, BLO_CODE_DATA, size_in_bytes, data_ptr); diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 49ddb335af8..ec67c8cfbe4 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -8,7 +8,7 @@ #include "DRW_engine.h" #include "DRW_render.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_view3d.h" #include "DNA_gpencil_legacy_types.h" diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc index 7d2e7a7fa2d..a6755c6adea 100644 --- a/source/blender/draw/intern/draw_attributes.cc +++ b/source/blender/draw/intern/draw_attributes.cc @@ -80,9 +80,10 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data, int *r_layer_index, eCustomDataType *r_type) { - const eCustomDataType possible_attribute_types[8] = { + const eCustomDataType possible_attribute_types[9] = { CD_PROP_BOOL, CD_PROP_INT8, + CD_PROP_INT32_2D, CD_PROP_INT32, CD_PROP_FLOAT, CD_PROP_FLOAT2, diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.cc b/source/blender/draw/intern/draw_cache_impl_gpencil.cc index b74b2b11e76..d91809e4d23 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_gpencil.cc @@ -17,7 +17,7 @@ #include "DRW_engine.h" #include "DRW_render.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "GPU_batch.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index 484810bb8a8..5cc568fe2ab 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -395,6 +395,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object, case CD_PROP_BOOL: case CD_PROP_INT8: case CD_PROP_INT32: + case CD_PROP_INT32_2D: case CD_PROP_FLOAT: case CD_PROP_FLOAT2: { if (layer != -1 && domain.has_value()) { diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index fcc79c37fe2..9ea93637b01 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -48,7 +48,7 @@ #include "DNA_view3d_types.h" #include "DNA_world_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_view3d.h" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index 62c4273afc5..dc1c5335763 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -100,6 +100,7 @@ static uint gpu_component_size_for_attribute_type(eCustomDataType type) * comment #extract_attr_init. */ return 3; case CD_PROP_FLOAT2: + case CD_PROP_INT32_2D: return 2; case CD_PROP_FLOAT3: return 3; @@ -116,6 +117,7 @@ static GPUVertFetchMode get_fetch_mode_for_type(eCustomDataType type) switch (type) { case CD_PROP_INT8: case CD_PROP_INT32: + case CD_PROP_INT32_2D: return GPU_FETCH_INT_TO_FLOAT; case CD_PROP_BYTE_COLOR: return GPU_FETCH_INT_TO_FLOAT_UNIT; @@ -128,6 +130,7 @@ static GPUVertCompType get_comp_type_for_type(eCustomDataType type) { switch (type) { case CD_PROP_INT8: + case CD_PROP_INT32_2D: case CD_PROP_INT32: return GPU_COMP_I32; case CD_PROP_BYTE_COLOR: @@ -299,6 +302,9 @@ static void extract_attr(const MeshRenderData *mr, case CD_PROP_INT32: extract_attr_generic(mr, vbo, request); break; + case CD_PROP_INT32_2D: + extract_attr_generic(mr, vbo, request); + break; case CD_PROP_FLOAT: extract_attr_generic(mr, vbo, request); break; diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 9fff8bf861c..e13ba1768f2 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -12,7 +12,7 @@ if(WITH_BLENDER) add_subdirectory(curves) add_subdirectory(geometry) add_subdirectory(gizmo_library) - add_subdirectory(gpencil) + add_subdirectory(gpencil_legacy) add_subdirectory(interface) add_subdirectory(io) add_subdirectory(lattice) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index e1dd1395373..4d0a2c2de42 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -746,7 +746,11 @@ void ANIM_frame_channel_y_extents(bContext *C, bAnimContext *ac) rctf bounds = {.xmin = FLT_MAX, .xmax = -FLT_MAX, .ymin = FLT_MAX, .ymax = -FLT_MAX}; const bool include_handles = false; - const float frame_range[2] = {window_region->v2d.cur.xmin, window_region->v2d.cur.xmax}; + float frame_range[2] = {window_region->v2d.cur.xmin, window_region->v2d.cur.xmax}; + if (ac->scene->r.flag & SCER_PRV_RANGE) { + frame_range[0] = ac->scene->r.psfra; + frame_range[1] = ac->scene->r.pefra; + } LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { rctf channel_bounds; diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 3dfcd076f17..cbc8e1d5105 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -741,7 +741,7 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) /* sanity checks */ if (BLI_listbase_is_empty(&driver_vars_copybuf)) { - BKE_report(reports, RPT_ERROR, "No driver variables in clipboard to paste"); + BKE_report(reports, RPT_ERROR, "No driver variables in the internal clipboard to paste"); return false; } @@ -1257,7 +1257,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) /* identifiers */ ot->name = "Paste Driver"; ot->idname = "ANIM_OT_paste_driver_button"; - ot->description = "Paste the driver in the clipboard to the highlighted button"; + ot->description = "Paste the driver in the internal clipboard to the highlighted button"; /* callbacks */ ot->exec = paste_driver_button_exec; diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.c index 5b7ad6fb900..db490c8b32e 100644 --- a/source/blender/editors/armature/pose_lib_2.c +++ b/source/blender/editors/armature/pose_lib_2.c @@ -123,7 +123,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd) } bPose *pose = pbd->ob->pose; - bAction *act = pbd->act; + bAction *act = poselib_action_to_blend(pbd); KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); ListBase dsources = {NULL, NULL}; diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 7f384c36af0..6466ecc6dac 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -798,7 +798,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op) BLI_listbase_clear(&temp_bmain->armatures); BKE_main_free(temp_bmain); /* We are all done! */ - BKE_report(op->reports, RPT_INFO, "Copied pose to buffer"); + BKE_report(op->reports, RPT_INFO, "Copied pose to internal clipboard"); return OPERATOR_FINISHED; } @@ -807,7 +807,7 @@ void POSE_OT_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Pose"; ot->idname = "POSE_OT_copy"; - ot->description = "Copies the current pose of the selected bones to copy/paste buffer"; + ot->description = "Copy the current pose of the selected bones to the internal clipboard"; /* api callbacks */ ot->exec = pose_copy_exec; @@ -846,13 +846,13 @@ static int pose_paste_exec(bContext *C, wmOperator *op) BLI_path_join(str, sizeof(str), BKE_tempdir_base(), "copybuffer_pose.blend"); if (!BKE_copybuffer_read(tmp_bmain, str, op->reports, FILTER_ID_OB)) { - BKE_report(op->reports, RPT_ERROR, "Copy buffer is empty"); + BKE_report(op->reports, RPT_ERROR, "Internal clipboard is empty"); BKE_main_free(tmp_bmain); return OPERATOR_CANCELLED; } /* Make sure data from this file is usable for pose paste. */ if (BLI_listbase_count_at_most(&tmp_bmain->objects, 2) != 1) { - BKE_report(op->reports, RPT_ERROR, "Copy buffer is not from pose mode"); + BKE_report(op->reports, RPT_ERROR, "Internal clipboard is not from pose mode"); BKE_main_free(tmp_bmain); return OPERATOR_CANCELLED; } @@ -860,7 +860,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) Object *object_from = tmp_bmain->objects.first; bPose *pose_from = object_from->pose; if (pose_from == NULL) { - BKE_report(op->reports, RPT_ERROR, "Copy buffer has no pose"); + BKE_report(op->reports, RPT_ERROR, "Internal clipboard has no pose"); BKE_main_free(tmp_bmain); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil_legacy/CMakeLists.txt similarity index 91% rename from source/blender/editors/gpencil/CMakeLists.txt rename to source/blender/editors/gpencil_legacy/CMakeLists.txt index af2ad0b7536..c1577b2ea60 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil_legacy/CMakeLists.txt @@ -77,7 +77,7 @@ if(WITH_POTRACE) endif() -blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") +blender_add_lib(bf_editor_gpencil_legacy "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") # RNA_prototypes.h -add_dependencies(bf_editor_gpencil bf_rna) +add_dependencies(bf_editor_gpencil_legacy bf_rna) diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil_legacy/annotate_draw.c similarity index 99% rename from source/blender/editors/gpencil/annotate_draw.c rename to source/blender/editors/gpencil_legacy/annotate_draw.c index 86ced9bd5cf..49616670e15 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil_legacy/annotate_draw.c @@ -41,7 +41,7 @@ #include "GPU_matrix.h" #include "GPU_state.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil_legacy/annotate_paint.c similarity index 99% rename from source/blender/editors/gpencil/annotate_paint.c rename to source/blender/editors/gpencil_legacy/annotate_paint.c index 458715ede1d..be3d4cb5883 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil_legacy/annotate_paint.c @@ -39,7 +39,7 @@ #include "UI_view2d.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil_legacy/drawgpencil.c similarity index 99% rename from source/blender/editors/gpencil/drawgpencil.c rename to source/blender/editors/gpencil_legacy/drawgpencil.c index f3428d01985..113bfa75ca2 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil_legacy/drawgpencil.c @@ -52,7 +52,7 @@ #include "GPU_state.h" #include "GPU_uniform_buffer.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil_legacy/editaction_gpencil.c similarity index 99% rename from source/blender/editors/gpencil/editaction_gpencil.c rename to source/blender/editors/gpencil_legacy/editaction_gpencil.c index ff3455f0b7d..3795b439030 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil_legacy/editaction_gpencil.c @@ -24,7 +24,7 @@ #include "BKE_report.h" #include "ED_anim_api.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframes_edit.h" #include "ED_markers.h" diff --git a/source/blender/editors/gpencil/gpencil_add_blank.c b/source/blender/editors/gpencil_legacy/gpencil_add_blank.c similarity index 98% rename from source/blender/editors/gpencil/gpencil_add_blank.c rename to source/blender/editors/gpencil_legacy/gpencil_add_blank.c index d6863ccfc01..728f4fd737c 100644 --- a/source/blender/editors/gpencil/gpencil_add_blank.c +++ b/source/blender/editors/gpencil_legacy/gpencil_add_blank.c @@ -23,7 +23,7 @@ #include "DEG_depsgraph.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" /* Definition of the most important info from a color */ typedef struct ColorTemplate { diff --git a/source/blender/editors/gpencil/gpencil_add_lineart.c b/source/blender/editors/gpencil_legacy/gpencil_add_lineart.c similarity index 98% rename from source/blender/editors/gpencil/gpencil_add_lineart.c rename to source/blender/editors/gpencil_legacy/gpencil_add_lineart.c index c3a4a8a928e..7fe07b69d21 100644 --- a/source/blender/editors/gpencil/gpencil_add_lineart.c +++ b/source/blender/editors/gpencil_legacy/gpencil_add_lineart.c @@ -26,7 +26,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" /* Definition of the most important info from a color */ typedef struct ColorTemplate { diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil_legacy/gpencil_add_monkey.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_add_monkey.c rename to source/blender/editors/gpencil_legacy/gpencil_add_monkey.c index 6d5688230dc..998b18f86ca 100644 --- a/source/blender/editors/gpencil/gpencil_add_monkey.c +++ b/source/blender/editors/gpencil_legacy/gpencil_add_monkey.c @@ -23,7 +23,7 @@ #include "DEG_depsgraph.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" void ED_gpencil_stroke_init_data(bGPDstroke *gps, const float *array, diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil_legacy/gpencil_add_stroke.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_add_stroke.c rename to source/blender/editors/gpencil_legacy/gpencil_add_stroke.c index 652c9ff6c8b..41af24773e0 100644 --- a/source/blender/editors/gpencil/gpencil_add_stroke.c +++ b/source/blender/editors/gpencil_legacy/gpencil_add_stroke.c @@ -23,7 +23,7 @@ #include "DEG_depsgraph.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" /* Definition of the most important info from a color */ typedef struct ColorTemplate { diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil_legacy/gpencil_armature.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_armature.c rename to source/blender/editors/gpencil_legacy/gpencil_armature.c index c38a0ef7bef..43cf338f129 100644 --- a/source/blender/editors/gpencil/gpencil_armature.c +++ b/source/blender/editors/gpencil_legacy/gpencil_armature.c @@ -41,7 +41,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_mesh.h" #include "ED_object.h" diff --git a/source/blender/editors/gpencil/gpencil_bake_animation.cc b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc similarity index 99% rename from source/blender/editors/gpencil/gpencil_bake_animation.cc rename to source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc index b2b639a9cc9..ce9afb362c4 100644 --- a/source/blender/editors/gpencil/gpencil_bake_animation.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc @@ -39,7 +39,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_transform_snap_object_context.h" #include "gpencil_intern.h" diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil_legacy/gpencil_convert.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_convert.c rename to source/blender/editors/gpencil_legacy/gpencil_convert.c index 2641d1903c5..97763060269 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil_legacy/gpencil_convert.c @@ -65,7 +65,7 @@ #include "UI_view2d.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil_legacy/gpencil_data.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_data.c rename to source/blender/editors/gpencil_legacy/gpencil_data.c index be89e63c9c5..32368022afe 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil_legacy/gpencil_data.c @@ -62,7 +62,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil_legacy/gpencil_edit.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_edit.c rename to source/blender/editors/gpencil_legacy/gpencil_edit.c index f832ca337b2..566777a4a12 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil_legacy/gpencil_edit.c @@ -66,7 +66,7 @@ #include "UI_view2d.h" #include "ED_armature.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_outliner.h" diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil_legacy/gpencil_edit_curve.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_edit_curve.c rename to source/blender/editors/gpencil_legacy/gpencil_edit_curve.c index 338072d15c8..26890004238 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil_legacy/gpencil_edit_curve.c @@ -29,7 +29,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil_legacy/gpencil_fill.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_fill.c rename to source/blender/editors/gpencil_legacy/gpencil_fill.c index 397f4d7c924..d618cc9fece 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil_legacy/gpencil_fill.c @@ -38,7 +38,7 @@ #include "BKE_report.h" #include "BKE_screen.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_screen.h" #include "ED_space_api.h" diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil_legacy/gpencil_intern.h similarity index 100% rename from source/blender/editors/gpencil/gpencil_intern.h rename to source/blender/editors/gpencil_legacy/gpencil_intern.h diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil_legacy/gpencil_interpolate.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_interpolate.c rename to source/blender/editors/gpencil_legacy/gpencil_interpolate.c index c8714ce8e8e..6b08b8b6e3c 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil_legacy/gpencil_interpolate.c @@ -47,7 +47,7 @@ #include "RNA_define.h" #include "RNA_prototypes.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil_legacy/gpencil_merge.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_merge.c rename to source/blender/editors/gpencil_legacy/gpencil_merge.c index 24966ea5d7f..0c63697f2a1 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil_legacy/gpencil_merge.c @@ -31,7 +31,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/gpencil/gpencil_mesh.cc b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc similarity index 99% rename from source/blender/editors/gpencil/gpencil_mesh.cc rename to source/blender/editors/gpencil_legacy/gpencil_mesh.cc index 9ad00ef174e..9cef4f42e97 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc @@ -37,7 +37,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_transform_snap_object_context.h" #include "gpencil_intern.h" diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil_legacy/gpencil_ops.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_ops.c rename to source/blender/editors/gpencil_legacy/gpencil_ops.c index 43d82de79dc..b534928999d 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil_legacy/gpencil_ops.c @@ -26,7 +26,7 @@ #include "RNA_access.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "gpencil_intern.h" diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil_legacy/gpencil_ops_versioning.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_ops_versioning.c rename to source/blender/editors/gpencil_legacy/gpencil_ops_versioning.c index 9c85754f3bd..7fa8a9d73ed 100644 --- a/source/blender/editors/gpencil/gpencil_ops_versioning.c +++ b/source/blender/editors/gpencil_legacy/gpencil_ops_versioning.c @@ -32,7 +32,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil_legacy/gpencil_paint.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_paint.c rename to source/blender/editors/gpencil_legacy/gpencil_paint.c index d4ec1ba76ae..aeb74980935 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_paint.c @@ -52,7 +52,7 @@ #include "UI_view2d.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil_legacy/gpencil_primitive.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_primitive.c rename to source/blender/editors/gpencil_legacy/gpencil_primitive.c index c33f2675a91..004d6d4d9ef 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil_legacy/gpencil_primitive.c @@ -54,7 +54,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_sculpt_paint.c rename to source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c index 7ced965fa04..f6659c4e2cd 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c @@ -58,7 +58,7 @@ #include "UI_view2d.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_screen.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil_legacy/gpencil_select.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_select.c rename to source/blender/editors/gpencil_legacy/gpencil_select.c index fd3effc144a..ed7093a8f35 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil_legacy/gpencil_select.c @@ -45,7 +45,7 @@ #include "UI_view2d.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_select_utils.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/gpencil_trace.h b/source/blender/editors/gpencil_legacy/gpencil_trace.h similarity index 100% rename from source/blender/editors/gpencil/gpencil_trace.h rename to source/blender/editors/gpencil_legacy/gpencil_trace.h diff --git a/source/blender/editors/gpencil/gpencil_trace_ops.c b/source/blender/editors/gpencil_legacy/gpencil_trace_ops.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_trace_ops.c rename to source/blender/editors/gpencil_legacy/gpencil_trace_ops.c index 6b3a71b557d..fd7e13f70a8 100644 --- a/source/blender/editors/gpencil/gpencil_trace_ops.c +++ b/source/blender/editors/gpencil_legacy/gpencil_trace_ops.c @@ -36,7 +36,7 @@ #include "IMB_imbuf_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "gpencil_intern.h" diff --git a/source/blender/editors/gpencil/gpencil_trace_utils.c b/source/blender/editors/gpencil_legacy/gpencil_trace_utils.c similarity index 100% rename from source/blender/editors/gpencil/gpencil_trace_utils.c rename to source/blender/editors/gpencil_legacy/gpencil_trace_utils.c diff --git a/source/blender/editors/gpencil/gpencil_undo.cc b/source/blender/editors/gpencil_legacy/gpencil_undo.cc similarity index 99% rename from source/blender/editors/gpencil/gpencil_undo.cc rename to source/blender/editors/gpencil_legacy/gpencil_undo.cc index 566e9c3033f..380cf959ed4 100644 --- a/source/blender/editors/gpencil/gpencil_undo.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_undo.cc @@ -22,7 +22,7 @@ #include "BKE_gpencil_legacy.h" #include "BKE_undo_system.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil_legacy/gpencil_utils.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_utils.c rename to source/blender/editors/gpencil_legacy/gpencil_utils.c index fef369427ad..34da7c160c4 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil_legacy/gpencil_utils.c @@ -63,7 +63,7 @@ #include "UI_view2d.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "ED_screen.h" #include "ED_select_utils.h" diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil_legacy/gpencil_uv.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_uv.c rename to source/blender/editors/gpencil_legacy/gpencil_uv.c index 2b9390a1beb..bed0b5ba295 100644 --- a/source/blender/editors/gpencil/gpencil_uv.c +++ b/source/blender/editors/gpencil_legacy/gpencil_uv.c @@ -26,7 +26,7 @@ #include "UI_interface.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_numinput.h" #include "ED_screen.h" #include "ED_space_api.h" diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c b/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_vertex_ops.c rename to source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c index 4fe87a51b93..d040d4fa8b9 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_ops.c +++ b/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c @@ -28,7 +28,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "DEG_depsgraph.h" diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_vertex_paint.c rename to source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c index 3e96f406fd5..ce21976c7c2 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c @@ -33,7 +33,7 @@ #include "UI_view2d.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_view3d.h" diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil_legacy/gpencil_weight_paint.c similarity index 99% rename from source/blender/editors/gpencil/gpencil_weight_paint.c rename to source/blender/editors/gpencil_legacy/gpencil_weight_paint.c index 85aa9e3a3d7..2bd827969bb 100644 --- a/source/blender/editors/gpencil/gpencil_weight_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_weight_paint.c @@ -38,7 +38,7 @@ #include "UI_view2d.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_view3d.h" diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil_legacy.h similarity index 100% rename from source/blender/editors/include/ED_gpencil.h rename to source/blender/editors/include/ED_gpencil_legacy.h diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc index 20592636fe7..187902c46ff 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc @@ -39,7 +39,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_undo.h" diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 0d52993a47a..e133e54fea7 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -245,8 +245,8 @@ static void UI_OT_copy_as_driver_button(wmOperatorType *ot) ot->idname = "UI_OT_copy_as_driver_button"; ot->description = "Create a new driver with this property as input, and copy it to the " - "clipboard. Use Paste Driver to add it to the target property, or Paste " - "Driver Variables to extend an existing driver"; + "internal clipboard. Use Paste Driver to add it to the target property, " + "or Paste Driver Variables to extend an existing driver"; /* callbacks */ ot->exec = copy_as_driver_button_exec; diff --git a/source/blender/editors/interface/interface_query.cc b/source/blender/editors/interface/interface_query.cc index 8597dd1b279..562c05df77f 100644 --- a/source/blender/editors/interface/interface_query.cc +++ b/source/blender/editors/interface/interface_query.cc @@ -155,10 +155,16 @@ bool UI_but_is_tool(const uiBut *but) bool UI_but_has_tooltip_label(const uiBut *but) { - if ((but->drawstr[0] == '\0') && !ui_block_is_popover(but->block)) { - return UI_but_is_tool(but); + /* No tooltip label if the button itself shows a label already. */ + if (but->drawstr[0] != '\0') { + return false; } - return false; + + if (UI_but_is_tool(but)) { + return !ui_block_is_popover(but->block); + } + + return ELEM(but->type, UI_BTYPE_TAB); } int ui_but_icon(const uiBut *but) diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index fd5fcbefd60..e5e216c8cfc 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -742,7 +742,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is static uiTooltipData *ui_tooltip_data_from_button_or_extra_icon(bContext *C, uiBut *but, - uiButExtraOpIcon *extra_icon) + uiButExtraOpIcon *extra_icon, + const bool is_label) { uiStringInfo but_label = {BUT_GET_LABEL, nullptr}; uiStringInfo but_tip = {BUT_GET_TIP, nullptr}; @@ -763,20 +764,30 @@ static uiTooltipData *ui_tooltip_data_from_button_or_extra_icon(bContext *C, uiTooltipData *data = MEM_cnew(__func__); if (extra_icon) { - UI_but_extra_icon_string_info_get(C, extra_icon, &but_label, &but_tip, &op_keymap, nullptr); + if (is_label) { + UI_but_extra_icon_string_info_get(C, extra_icon, &but_label, &enum_label, nullptr); + } + else { + UI_but_extra_icon_string_info_get(C, extra_icon, &but_label, &but_tip, &op_keymap, nullptr); + } } else { - UI_but_string_info_get(C, - but, - &but_label, - &but_tip, - &enum_label, - &enum_tip, - &op_keymap, - &prop_keymap, - &rna_struct, - &rna_prop, - nullptr); + if (is_label) { + UI_but_string_info_get(C, but, &but_label, &enum_label, nullptr); + } + else { + UI_but_string_info_get(C, + but, + &but_label, + &but_tip, + &enum_label, + &enum_tip, + &op_keymap, + &prop_keymap, + &rna_struct, + &rna_prop, + nullptr); + } } /* Tip Label (only for buttons not already showing the label). @@ -811,6 +822,13 @@ static uiTooltipData *ui_tooltip_data_from_button_or_extra_icon(bContext *C, field->text = BLI_strdup(TIP_("(Shift-Click/Drag to select multiple)")); } } + /* When there is only an enum label (no button label or tip), draw that as header. */ + else if (enum_label.strinfo && !(but_label.strinfo && but_label.strinfo[0])) { + uiTooltipField *field = text_field_add( + data, uiTooltipFormat::Style::Header, uiTooltipFormat::ColorID::Normal); + field->text = BLI_strdup(enum_label.strinfo); + } + /* Enum field label & tip. */ if (enum_tip.strinfo) { uiTooltipField *field = text_field_add( @@ -1346,11 +1364,11 @@ ARegion *UI_tooltip_create_from_button_or_extra_icon( } if (data == nullptr) { - data = ui_tooltip_data_from_button_or_extra_icon(C, but, extra_icon); + data = ui_tooltip_data_from_button_or_extra_icon(C, but, extra_icon, is_label); } if (data == nullptr) { - data = ui_tooltip_data_from_button_or_extra_icon(C, but, nullptr); + data = ui_tooltip_data_from_button_or_extra_icon(C, but, nullptr, is_label); } if (data == nullptr) { diff --git a/source/blender/editors/io/io_gpencil_import.c b/source/blender/editors/io/io_gpencil_import.c index a9a28978052..91c719849cc 100644 --- a/source/blender/editors/io/io_gpencil_import.c +++ b/source/blender/editors/io/io_gpencil_import.c @@ -32,7 +32,7 @@ # include "DEG_depsgraph.h" # include "DEG_depsgraph_query.h" -# include "ED_gpencil.h" +# include "ED_gpencil_legacy.h" # include "io_gpencil.h" diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index f1ac579d6bc..7e352cef0a3 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -326,7 +326,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot) "overwrite_textures", false, "Overwrite Textures", - "Allow overwriting existing texture files when exporting textures"); + "Overwrite existing files when exporting textures"); RNA_def_boolean(ot->srna, "relative_paths", @@ -612,7 +612,7 @@ void WM_OT_usd_import(struct wmOperatorType *ot) RNA_def_boolean(ot->srna, "read_mesh_uvs", true, "UV Coordinates", "Read mesh UV coordinates"); RNA_def_boolean( - ot->srna, "read_mesh_colors", false, "Color Attributes", "Read mesh color attributes"); + ot->srna, "read_mesh_colors", true, "Color Attributes", "Read mesh color attributes"); RNA_def_string(ot->srna, "prim_path_mask", diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index fcabc1bc1ec..58b3b07e1be 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -2069,7 +2069,7 @@ void MASK_OT_copy_splines(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy Splines"; - ot->description = "Copy selected splines to clipboard"; + ot->description = "Copy the selected splines to the internal clipboard"; ot->idname = "MASK_OT_copy_splines"; /* api callbacks */ @@ -2113,7 +2113,7 @@ void MASK_OT_paste_splines(wmOperatorType *ot) { /* identifiers */ ot->name = "Paste Splines"; - ot->description = "Paste splines from clipboard"; + ot->description = "Paste splines from the internal clipboard"; ot->idname = "MASK_OT_paste_splines"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_attribute.cc b/source/blender/editors/mesh/editmesh_attribute.cc index f9a8d551abd..8385c6194d6 100644 --- a/source/blender/editors/mesh/editmesh_attribute.cc +++ b/source/blender/editors/mesh/editmesh_attribute.cc @@ -102,6 +102,8 @@ static StringRefNull rna_property_name_for_type(const eCustomDataType type) case CD_PROP_INT8: case CD_PROP_INT32: return "value_int"; + case CD_PROP_INT32_2D: + return "value_int_vector_2d"; default: BLI_assert_unreachable(); return ""; @@ -208,6 +210,9 @@ static int mesh_set_attribute_exec(bContext *C, wmOperator *op) case CD_PROP_INT32: *static_cast(buffer) = RNA_int_get(op->ptr, prop_name.c_str()); break; + case CD_PROP_INT32_2D: + RNA_int_get_array(op->ptr, prop_name.c_str(), static_cast(buffer)); + break; default: BLI_assert_unreachable(); } @@ -320,6 +325,9 @@ static int mesh_set_attribute_invoke(bContext *C, wmOperator *op, const wmEvent case CD_PROP_INT32: RNA_property_int_set(op->ptr, prop, *active_value.get()); break; + case CD_PROP_INT32_2D: + RNA_property_int_set_array(op->ptr, prop, *active_value.get()); + break; default: BLI_assert_unreachable(); } @@ -385,6 +393,16 @@ void MESH_OT_attribute_set(wmOperatorType *ot) -FLT_MAX, FLT_MAX); RNA_def_int(ot->srna, "value_int", 0, INT_MIN, INT_MAX, "Value", "", INT_MIN, INT_MAX); + RNA_def_int_array(ot->srna, + "value_int_vector_2d", + 2, + nullptr, + INT_MIN, + INT_MAX, + "Value", + "", + INT_MIN, + INT_MAX); RNA_def_float_color( ot->srna, "value_color", 4, color_default, -FLT_MAX, FLT_MAX, "Value", "", 0.0f, 1.0f); RNA_def_boolean(ot->srna, "value_bool", false, "Value", ""); diff --git a/source/blender/editors/mesh/editmesh_tools.cc b/source/blender/editors/mesh/editmesh_tools.cc index e17c5db1278..7411bd4a4f8 100644 --- a/source/blender/editors/mesh/editmesh_tools.cc +++ b/source/blender/editors/mesh/editmesh_tools.cc @@ -9370,8 +9370,12 @@ enum { }; static EnumPropertyItem normal_vector_tool_items[] = { - {EDBM_CLNOR_TOOLS_COPY, "COPY", 0, "Copy Normal", "Copy normal to buffer"}, - {EDBM_CLNOR_TOOLS_PASTE, "PASTE", 0, "Paste Normal", "Paste normal from buffer"}, + {EDBM_CLNOR_TOOLS_COPY, "COPY", 0, "Copy Normal", "Copy normal to the internal clipboard"}, + {EDBM_CLNOR_TOOLS_PASTE, + "PASTE", + 0, + "Paste Normal", + "Paste normal from the internal clipboard"}, {EDBM_CLNOR_TOOLS_ADD, "ADD", 0, "Add Normal", "Add normal vector with selection"}, {EDBM_CLNOR_TOOLS_MULTIPLY, "MULTIPLY", @@ -9382,7 +9386,7 @@ static EnumPropertyItem normal_vector_tool_items[] = { "RESET", 0, "Reset Normal", - "Reset buffer and/or normal of selected element"}, + "Reset the internal clipboard and/or normal of selected element"}, {0, nullptr, 0, nullptr, nullptr}, }; diff --git a/source/blender/editors/mesh/editmesh_undo.cc b/source/blender/editors/mesh/editmesh_undo.cc index 098a4ef48ee..f8e5a4367d6 100644 --- a/source/blender/editors/mesh/editmesh_undo.cc +++ b/source/blender/editors/mesh/editmesh_undo.cc @@ -408,8 +408,8 @@ static void um_arraystore_compact_ex(UndoMesh *um, const UndoMesh *um_ref, bool um->store.poly_offset_indices = BLI_array_store_state_add( bs, me->poly_offset_indices, size_t(me->totpoly + 1) * stride, state_reference); } - - MEM_SAFE_FREE(me->poly_offset_indices); + blender::implicit_sharing::free_shared_data(&me->poly_offset_indices, + &me->runtime->poly_offsets_sharing_info); } }, [&]() { @@ -577,6 +577,8 @@ static void um_arraystore_expand(UndoMesh *um) size_t state_len; me->poly_offset_indices = static_cast( BLI_array_store_state_data_get_alloc(state, &state_len)); + me->runtime->poly_offsets_sharing_info = blender::implicit_sharing::info_for_mem_free( + me->poly_offset_indices); BLI_assert((me->totpoly + 1) == (state_len / stride)); UNUSED_VARS_NDEBUG(stride); } diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index ce417294187..fc54a974d60 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -1251,8 +1251,13 @@ static void mesh_add_polys(Mesh *mesh, int len) CustomData_copy_layout(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_SET_DEFAULT, totpoly); CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly); - mesh->poly_offset_indices = static_cast( - MEM_reallocN(mesh->poly_offset_indices, sizeof(int) * (totpoly + 1))); + implicit_sharing::resize_trivial_array(&mesh->poly_offset_indices, + &mesh->runtime->poly_offsets_sharing_info, + mesh->totpoly == 0 ? 0 : (mesh->totpoly + 1), + totpoly + 1); + /* Set common values for convenience. */ + mesh->poly_offset_indices[0] = 0; + mesh->poly_offset_indices[totpoly] = mesh->totloop; CustomData_free(&mesh->pdata, mesh->totpoly); mesh->pdata = pdata; @@ -1260,9 +1265,6 @@ static void mesh_add_polys(Mesh *mesh, int len) BKE_mesh_runtime_clear_cache(mesh); mesh->totpoly = totpoly; - /* Update the last offset, which may not be set elsewhere and must be the same as the number of - * face corners. */ - mesh->poly_offsets_for_write().last() = mesh->totloop; bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); bke::SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_span( diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index 021d77fa152..de6d40b5fea 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -677,7 +677,11 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) BKE_mesh_clear_geometry(me); - me->poly_offset_indices = poly_offsets; + if (totpoly) { + me->poly_offset_indices = poly_offsets; + me->runtime->poly_offsets_sharing_info = blender::implicit_sharing::info_for_mem_free( + poly_offsets); + } me->totvert = totvert; me->totedge = totedge; diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 3b7318de032..9ed1f7046b7 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -9,7 +9,7 @@ set(INC ../../bmesh ../../depsgraph ../../functions - ../../gpencil_modifiers + ../../gpencil_modifiers_legacy ../../gpu ../../ikplugin ../../imbuf diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 5fe5a401fca..34d83e9118d 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -100,7 +100,7 @@ #include "ED_armature.h" #include "ED_curve.h" #include "ED_curves.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_mball.h" #include "ED_mesh.h" #include "ED_node.h" @@ -3384,6 +3384,9 @@ static int object_convert_exec(bContext *C, wmOperator *op) } Mesh *new_mesh = static_cast(BKE_id_new(bmain, ID_ME, newob->id.name + 2)); + newob->data = new_mesh; + newob->type = OB_MESH; + if (const Mesh *mesh_eval = geometry.get_mesh_for_read()) { BKE_mesh_nomain_to_mesh(BKE_mesh_copy_for_eval(mesh_eval, false), new_mesh, newob); BKE_object_material_from_eval_data(bmain, newob, &mesh_eval->id); @@ -3393,6 +3396,9 @@ static int object_convert_exec(bContext *C, wmOperator *op) bke::AnonymousAttributePropagationInfo propagation_info; propagation_info.propagate_all = false; Mesh *mesh = bke::curve_to_wire_mesh(curves_eval->geometry.wrap(), propagation_info); + if (!mesh) { + mesh = BKE_mesh_new_nomain(0, 0, 0, 0); + } BKE_mesh_nomain_to_mesh(mesh, new_mesh, newob); BKE_object_material_from_eval_data(bmain, newob, &curves_eval->id); } @@ -3403,9 +3409,6 @@ static int object_convert_exec(bContext *C, wmOperator *op) ob->id.name + 2); } - newob->data = new_mesh; - newob->type = OB_MESH; - BKE_object_free_derived_caches(newob); BKE_object_free_modifiers(newob, 0); } diff --git a/source/blender/editors/object/object_edit.cc b/source/blender/editors/object/object_edit.cc index 00fd6139503..9bc7b3a3320 100644 --- a/source/blender/editors/object/object_edit.cc +++ b/source/blender/editors/object/object_edit.cc @@ -73,7 +73,7 @@ #include "ED_anim_api.h" #include "ED_armature.h" #include "ED_curve.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_image.h" #include "ED_keyframes_keylist.h" #include "ED_lattice.h" diff --git a/source/blender/editors/object/object_modes.cc b/source/blender/editors/object/object_modes.cc index 23d17e08455..36ff752e60d 100644 --- a/source/blender/editors/object/object_modes.cc +++ b/source/blender/editors/object/object_modes.cc @@ -41,7 +41,7 @@ #include "DEG_depsgraph_query.h" #include "ED_armature.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_transform_snap_object_context.h" #include "ED_undo.h" diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 51136680e21..2e454c12d96 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -21,7 +21,7 @@ #include "object_intern.h" -#include "MOD_gpencil_lineart.h" +#include "MOD_gpencil_legacy_lineart.h" /* ************************** registration **********************************/ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 252eddb824d..12f119f68ef 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -92,7 +92,7 @@ #include "ED_armature.h" #include "ED_curve.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_mesh.h" #include "ED_object.h" diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index f693e4918e5..e006afc430a 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -61,7 +61,7 @@ #include "WM_types.h" #include "ED_armature.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "ED_mesh.h" #include "ED_object.h" diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index 1dcbfd26535..076d2cc48b1 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -51,7 +51,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_view3d.h" #include "ED_view3d_offscreen.h" diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index 452b6228e50..d26fceb9814 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -1829,7 +1829,7 @@ void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Line Set"; ot->idname = "SCENE_OT_freestyle_lineset_copy"; - ot->description = "Copy the active line set to a buffer"; + ot->description = "Copy the active line set to the internal clipboard"; /* api callbacks */ ot->exec = freestyle_lineset_copy_exec; @@ -1863,7 +1863,7 @@ void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot) /* identifiers */ ot->name = "Paste Line Set"; ot->idname = "SCENE_OT_freestyle_lineset_paste"; - ot->description = "Paste the buffer content to the active line set"; + ot->description = "Paste the internal clipboard content to the active line set"; /* api callbacks */ ot->exec = freestyle_lineset_paste_exec; diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index e2e45a2a662..ba07697c6e3 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -41,7 +41,7 @@ #include "ED_anim_api.h" #include "ED_armature.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "SEQ_channels.h" #include "SEQ_select.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc b/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc index 80377fd2542..3abee75218f 100644 --- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc @@ -161,7 +161,10 @@ static void SCULPT_dynamic_topology_disable_ex( CustomData_copy(&geometry->edata, &me->edata, CD_MASK_MESH.emask, geometry->totedge); CustomData_copy(&geometry->ldata, &me->ldata, CD_MASK_MESH.lmask, geometry->totloop); CustomData_copy(&geometry->pdata, &me->pdata, CD_MASK_MESH.pmask, geometry->totpoly); - me->poly_offset_indices = static_cast(MEM_dupallocN(geometry->poly_offset_indices)); + blender::implicit_sharing::copy_shared_pointer(geometry->poly_offset_indices, + geometry->poly_offsets_sharing_info, + &me->poly_offset_indices, + &me->runtime->poly_offsets_sharing_info); } else { BKE_sculptsession_bm_to_me(ob, true); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index a61fb5c1a59..b86ae773630 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -16,6 +16,8 @@ #include "BKE_paint.h" #include "BKE_pbvh.h" + +#include "BLI_implicit_sharing.hh" #include "BLI_bitmap.h" #include "BLI_compiler_attrs.h" #include "BLI_compiler_compat.h" @@ -147,6 +149,7 @@ struct SculptUndoNodeGeometry { CustomData ldata; CustomData pdata; int *poly_offset_indices; + blender::ImplicitSharingInfo *poly_offsets_sharing_info; int totvert; int totedge; int totloop; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index d4784c24f3a..f99f04db661 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -749,7 +749,10 @@ static void sculpt_undo_geometry_store_data(SculptUndoNodeGeometry *geometry, Ob CustomData_copy(&mesh->edata, &geometry->edata, CD_MASK_MESH.emask, mesh->totedge); CustomData_copy(&mesh->ldata, &geometry->ldata, CD_MASK_MESH.lmask, mesh->totloop); CustomData_copy(&mesh->pdata, &geometry->pdata, CD_MASK_MESH.pmask, mesh->totpoly); - geometry->poly_offset_indices = static_cast(MEM_dupallocN(mesh->poly_offset_indices)); + blender::implicit_sharing::copy_shared_pointer(mesh->poly_offset_indices, + mesh->runtime->poly_offsets_sharing_info, + &geometry->poly_offset_indices, + &geometry->poly_offsets_sharing_info); geometry->totvert = mesh->totvert; geometry->totedge = mesh->totedge; @@ -775,7 +778,10 @@ static void sculpt_undo_geometry_restore_data(SculptUndoNodeGeometry *geometry, CustomData_copy(&geometry->edata, &mesh->edata, CD_MASK_MESH.emask, geometry->totedge); CustomData_copy(&geometry->ldata, &mesh->ldata, CD_MASK_MESH.lmask, geometry->totloop); CustomData_copy(&geometry->pdata, &mesh->pdata, CD_MASK_MESH.pmask, geometry->totpoly); - mesh->poly_offset_indices = static_cast(MEM_dupallocN(geometry->poly_offset_indices)); + blender::implicit_sharing::copy_shared_pointer(geometry->poly_offset_indices, + geometry->poly_offsets_sharing_info, + &mesh->poly_offset_indices, + &mesh->runtime->poly_offsets_sharing_info); } static void sculpt_undo_geometry_free_data(SculptUndoNodeGeometry *geometry) @@ -792,7 +798,8 @@ static void sculpt_undo_geometry_free_data(SculptUndoNodeGeometry *geometry) if (geometry->totpoly) { CustomData_free(&geometry->pdata, geometry->totpoly); } - MEM_SAFE_FREE(geometry->poly_offset_indices); + blender::implicit_sharing::free_shared_data(&geometry->poly_offset_indices, + &geometry->poly_offsets_sharing_info); } static void sculpt_undo_geometry_restore(SculptUndoNode *unode, Object *object) diff --git a/source/blender/editors/space_action/action_data.cc b/source/blender/editors/space_action/action_data.cc index e7dcaa9559f..f59944bb62a 100644 --- a/source/blender/editors/space_action/action_data.cc +++ b/source/blender/editors/space_action/action_data.cc @@ -38,7 +38,7 @@ #include "UI_view2d.h" #include "ED_anim_api.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframes_edit.h" #include "ED_keyframing.h" #include "ED_markers.h" diff --git a/source/blender/editors/space_action/action_edit.cc b/source/blender/editors/space_action/action_edit.cc index d805f3cce5e..ddaaf217b1f 100644 --- a/source/blender/editors/space_action/action_edit.cc +++ b/source/blender/editors/space_action/action_edit.cc @@ -40,7 +40,7 @@ #include "UI_view2d.h" #include "ED_anim_api.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframes_edit.h" #include "ED_keyframing.h" #include "ED_markers.h" @@ -576,7 +576,7 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) if (ac.datatype == ANIMCONT_GPENCIL) { if (ED_gpencil_anim_copybuf_copy(&ac) == false) { /* check if anything ended up in the buffer */ - BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); + BKE_report(op->reports, RPT_ERROR, "No keyframes copied to the internal clipboard"); return OPERATOR_CANCELLED; } } @@ -591,7 +591,7 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) const bool gpf_ok = ED_gpencil_anim_copybuf_copy(&ac); if (kf_empty && !gpf_ok) { - BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); + BKE_report(op->reports, RPT_ERROR, "No keyframes copied to the internal clipboard"); return OPERATOR_CANCELLED; } } @@ -604,7 +604,7 @@ void ACTION_OT_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Keyframes"; ot->idname = "ACTION_OT_copy"; - ot->description = "Copy selected keyframes to the copy/paste buffer"; + ot->description = "Copy selected keyframes to the internal clipboard"; /* api callbacks */ ot->exec = actkeys_copy_exec; @@ -635,7 +635,7 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) /* paste keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { if (ED_gpencil_anim_copybuf_paste(&ac, offset_mode) == false) { - BKE_report(op->reports, RPT_ERROR, "No data in buffer to paste"); + BKE_report(op->reports, RPT_ERROR, "No data in the internal clipboard to paste"); return OPERATOR_CANCELLED; } } @@ -664,7 +664,7 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; case KEYFRAME_PASTE_NOTHING_TO_PASTE: - BKE_report(op->reports, RPT_ERROR, "No data in buffer to paste"); + BKE_report(op->reports, RPT_ERROR, "No data in the internal clipboard to paste"); return OPERATOR_CANCELLED; } } @@ -698,7 +698,8 @@ void ACTION_OT_paste(wmOperatorType *ot) ot->name = "Paste Keyframes"; ot->idname = "ACTION_OT_paste"; ot->description = - "Paste keyframes from copy/paste buffer for the selected channels, starting on the current " + "Paste keyframes from the internal clipboard for the selected channels, starting on the " + "current " "frame"; /* api callbacks */ diff --git a/source/blender/editors/space_action/action_select.cc b/source/blender/editors/space_action/action_select.cc index bc9fb3ca7f4..abed2e4aa43 100644 --- a/source/blender/editors/space_action/action_select.cc +++ b/source/blender/editors/space_action/action_select.cc @@ -35,7 +35,7 @@ #include "UI_view2d.h" #include "ED_anim_api.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframes_edit.h" #include "ED_keyframes_keylist.h" #include "ED_markers.h" diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 0ed48924bbe..56aa0104329 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -33,7 +33,7 @@ #include "ED_fileselect.h" #include "ED_geometry.h" #include "ED_gizmo_library.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_lattice.h" #include "ED_markers.h" #include "ED_mask.h" diff --git a/source/blender/editors/space_clip/clip_draw.cc b/source/blender/editors/space_clip/clip_draw.cc index e5beccd2b75..a321dc1bebd 100644 --- a/source/blender/editors/space_clip/clip_draw.cc +++ b/source/blender/editors/space_clip/clip_draw.cc @@ -27,7 +27,7 @@ #include "BKE_tracking.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_mask.h" #include "ED_screen.h" #include "ED_util.h" diff --git a/source/blender/editors/space_clip/tracking_ops.cc b/source/blender/editors/space_clip/tracking_ops.cc index ae59cf672a1..48782a51145 100644 --- a/source/blender/editors/space_clip/tracking_ops.cc +++ b/source/blender/editors/space_clip/tracking_ops.cc @@ -1874,7 +1874,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy Tracks"; - ot->description = "Copy selected tracks to clipboard"; + ot->description = "Copy the selected tracks to the internal clipboard"; ot->idname = "CLIP_OT_copy_tracks"; /* api callbacks */ @@ -1919,7 +1919,7 @@ void CLIP_OT_paste_tracks(wmOperatorType *ot) { /* identifiers */ ot->name = "Paste Tracks"; - ot->description = "Paste tracks from clipboard"; + ot->description = "Paste tracks from the internal clipboard"; ot->idname = "CLIP_OT_paste_tracks"; /* api callbacks */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 0efc653c81b..941e211c3ad 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -523,7 +523,7 @@ static int graphkeys_copy_exec(bContext *C, wmOperator *op) /* Copy keyframes. */ if (copy_graph_keys(&ac)) { - BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); + BKE_report(op->reports, RPT_ERROR, "No keyframes copied to the internal clipboard"); return OPERATOR_CANCELLED; } @@ -536,7 +536,7 @@ void GRAPH_OT_copy(wmOperatorType *ot) /* Identifiers */ ot->name = "Copy Keyframes"; ot->idname = "GRAPH_OT_copy"; - ot->description = "Copy selected keyframes to the copy/paste buffer"; + ot->description = "Copy selected keyframes to the internal clipboard"; /* API callbacks */ ot->exec = graphkeys_copy_exec; @@ -574,7 +574,7 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; case KEYFRAME_PASTE_NOTHING_TO_PASTE: - BKE_report(op->reports, RPT_ERROR, "No data in buffer to paste"); + BKE_report(op->reports, RPT_ERROR, "No data in the internal clipboard to paste"); return OPERATOR_CANCELLED; } @@ -605,7 +605,8 @@ void GRAPH_OT_paste(wmOperatorType *ot) ot->name = "Paste Keyframes"; ot->idname = "GRAPH_OT_paste"; ot->description = - "Paste keyframes from copy/paste buffer for the selected channels, starting on the current " + "Paste keyframes from the internal clipboard for the selected channels, starting on the " + "current " "frame"; /* API callbacks */ diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 786fcd4075a..db795b254e1 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -31,7 +31,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_image.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 6460e6ebd7b..1693ab74e5b 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -48,7 +48,7 @@ #include "BLF_api.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_image.h" #include "ED_mask.h" #include "ED_render.h" diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index df11489f757..a0bab859025 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -167,7 +167,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator * /*op*/) void NODE_OT_clipboard_copy(wmOperatorType *ot) { ot->name = "Copy to Clipboard"; - ot->description = "Copies selected nodes to the clipboard"; + ot->description = "Copy the selected nodes to the internal clipboard"; ot->idname = "NODE_OT_clipboard_copy"; ot->exec = node_clipboard_copy_exec; @@ -191,7 +191,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) const bool is_valid = clipboard.validate(); if (clipboard.nodes.is_empty()) { - BKE_report(op->reports, RPT_ERROR, "Clipboard is empty"); + BKE_report(op->reports, RPT_ERROR, "The internal clipboard is empty"); return OPERATOR_CANCELLED; } @@ -311,7 +311,7 @@ static int node_clipboard_paste_invoke(bContext *C, wmOperator *op, const wmEven void NODE_OT_clipboard_paste(wmOperatorType *ot) { ot->name = "Paste from Clipboard"; - ot->description = "Pastes nodes from the clipboard to the active node tree"; + ot->description = "Paste nodes from the internal clipboard to the active node tree"; ot->idname = "NODE_OT_clipboard_paste"; ot->invoke = node_clipboard_paste_invoke; diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 3192db22e07..560a07dee3b 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -58,7 +58,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_node.h" #include "ED_node.hh" #include "ED_screen.h" diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index 982ea27374f..01f08e1f969 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -144,6 +144,7 @@ static eCustomDataType data_type_in_attribute_input_node(const eCustomDataType t /* Unsupported currently. */ return CD_PROP_FLOAT; case CD_PROP_FLOAT2: + case CD_PROP_INT32_2D: /* No 2D vector sockets currently. */ return CD_PROP_FLOAT3; case CD_PROP_INT8: diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 62f851d4c6e..4ea83f4720c 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -822,7 +822,7 @@ void OUTLINER_OT_id_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Outliner ID Data Copy"; ot->idname = "OUTLINER_OT_id_copy"; - ot->description = "Selected data-blocks are copied to the clipboard"; + ot->description = "Copy the selected data-blocks to the internal clipboard"; /* callbacks */ ot->exec = outliner_id_copy_exec; @@ -863,7 +863,7 @@ void OUTLINER_OT_id_paste(wmOperatorType *ot) /* identifiers */ ot->name = "Outliner ID Data Paste"; ot->idname = "OUTLINER_OT_id_paste"; - ot->description = "Data-blocks from the clipboard are pasted"; + ot->description = "Paste data-blocks from the internal clipboard"; /* callbacks */ ot->exec = outliner_id_paste_exec; diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index b7a3d0d7e64..4406dd7afaf 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -488,7 +488,9 @@ static void outliner_blend_read_lib(BlendLibReader *reader, ID * /*parent_id*/, BLI_mempool_iternew(space_outliner->treestore, &iter); while ((tselem = static_cast(BLI_mempool_iterstep(&iter)))) { - BLO_read_id_address(reader, nullptr, &tselem->id); + if (TSE_IS_REAL_ID(tselem)) { + BLO_read_id_address(reader, nullptr, &tselem->id); + } } /* rebuild hash table, because it depends on ids too */ space_outliner->storeflag |= SO_TREESTORE_REBUILD; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index debdb677d63..b257eb401c1 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -43,7 +43,7 @@ #include "GPU_viewport.h" #include "ED_anim_api.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_markers.h" #include "ED_mask.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index f6a9ae8dc60..ba5e770f81c 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2483,7 +2483,7 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) /* Identifiers. */ ot->name = "Copy"; ot->idname = "SEQUENCER_OT_copy"; - ot->description = "Copy selected strips to clipboard"; + ot->description = "Copy the selected strips to the internal clipboard"; /* Api callbacks. */ ot->exec = sequencer_copy_exec; @@ -2630,7 +2630,7 @@ void SEQUENCER_OT_paste(wmOperatorType *ot) /* Identifiers. */ ot->name = "Paste"; ot->idname = "SEQUENCER_OT_paste"; - ot->description = "Paste strips from clipboard"; + ot->description = "Paste strips from the internal clipboard"; /* Api callbacks. */ ot->exec = sequencer_paste_exec; diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index 52c1fa7a3ec..3c4bb00730f 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -335,6 +335,7 @@ static float get_default_column_width(const ColumnValues &values) return float_width; case SPREADSHEET_VALUE_TYPE_FLOAT: return float_width; + case SPREADSHEET_VALUE_TYPE_INT32_2D: case SPREADSHEET_VALUE_TYPE_FLOAT2: return 2.0f * float_width; case SPREADSHEET_VALUE_TYPE_FLOAT3: diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc index 078fa3c1c02..d0327cfc990 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc @@ -30,6 +30,9 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const CPPType &type) if (type.is()) { return SPREADSHEET_VALUE_TYPE_INT32; } + if (type.is()) { + return SPREADSHEET_VALUE_TYPE_INT32_2D; + } if (type.is()) { return SPREADSHEET_VALUE_TYPE_FLOAT; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc index 2f5ff624540..cd9fb6f5167 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc @@ -138,6 +138,10 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT); } + else if (data.type().is()) { + const int2 value = data.get(real_index); + this->draw_int_vector(params, Span(&value.x, 2)); + } else if (data.type().is()) { const float value = data.get(real_index); std::stringstream ss; @@ -311,6 +315,36 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { } } + void draw_int_vector(const CellDrawParams ¶ms, const Span values) const + { + BLI_assert(!values.is_empty()); + const float segment_width = float(params.width) / values.size(); + for (const int i : values.index_range()) { + std::stringstream ss; + const int value = values[i]; + ss << " " << value; + const std::string value_str = ss.str(); + uiBut *but = uiDefIconTextBut(params.block, + UI_BTYPE_LABEL, + 0, + ICON_NONE, + value_str.c_str(), + params.xmin + i * segment_width, + params.ymin, + segment_width, + params.height, + nullptr, + 0, + 0, + 0, + 0, + nullptr); + /* Right-align Floats. */ + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); + UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT); + } + } + void draw_byte_color(const CellDrawParams ¶ms, const ColorGeometry4b color) const { const ColorGeometry4f float_color = color.decode(); diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc index 303d3f1a688..79b58c07fe8 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc @@ -140,6 +140,36 @@ static void apply_row_filter(const SpreadsheetRowFilter &row_filter, } } } + else if (column_data.type().is()) { + const int2 value = row_filter.value_int2; + switch (row_filter.operation) { + case SPREADSHEET_ROW_FILTER_EQUAL: { + const float threshold_sq = pow2f(row_filter.threshold); + apply_filter_operation( + column_data.typed(), + [&](const int2 cell) { return math::distance_squared(cell, value) <= threshold_sq; }, + prev_mask, + new_indices); + break; + } + case SPREADSHEET_ROW_FILTER_GREATER: { + apply_filter_operation( + column_data.typed(), + [&](const int2 cell) { return cell.x > value.x && cell.y > value.y; }, + prev_mask, + new_indices); + break; + } + case SPREADSHEET_ROW_FILTER_LESS: { + apply_filter_operation( + column_data.typed(), + [&](const int2 cell) { return cell.x < value.x && cell.y < value.y; }, + prev_mask, + new_indices); + break; + } + } + } else if (column_data.type().is()) { const float2 value = row_filter.value_float2; switch (row_filter.operation) { diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc index fa22da4f26a..5007e859a0f 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc @@ -68,6 +68,11 @@ static std::string value_string(const SpreadsheetRowFilter &row_filter, result << std::fixed << row_filter.value_float; return result.str(); } + case SPREADSHEET_VALUE_TYPE_INT32_2D: { + std::ostringstream result; + result << "(" << row_filter.value_int2[0] << ", " << row_filter.value_int2[1] << ")"; + return result.str(); + } case SPREADSHEET_VALUE_TYPE_FLOAT2: { std::ostringstream result; result.precision(3); @@ -198,6 +203,10 @@ static void spreadsheet_filter_panel_draw(const bContext *C, Panel *panel) uiItemR(layout, filter_ptr, "operation", 0, nullptr, ICON_NONE); uiItemR(layout, filter_ptr, "value_int", 0, IFACE_("Value"), ICON_NONE); break; + case SPREADSHEET_VALUE_TYPE_INT32_2D: + uiItemR(layout, filter_ptr, "operation", 0, nullptr, ICON_NONE); + uiItemR(layout, filter_ptr, "value_int2", 0, IFACE_("Value"), ICON_NONE); + break; case SPREADSHEET_VALUE_TYPE_FLOAT: uiItemR(layout, filter_ptr, "operation", 0, nullptr, ICON_NONE); uiItemR(layout, filter_ptr, "value_float", 0, IFACE_("Value"), ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 9755599e989..86a7033d0df 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -48,7 +48,7 @@ #include "DRW_engine.h" #include "DRW_select_buffer.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_info.h" #include "ED_keyframing.h" #include "ED_screen.h" diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index fd940470cc1..16195a896bd 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -30,7 +30,7 @@ #include "ED_gizmo_library.h" #include "ED_gizmo_utils.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_screen.h" #include "ED_transform.h" #include "ED_transform_snap_object_context.h" diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 0274ff603c6..c808d810680 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -72,7 +72,7 @@ static void VIEW3D_OT_copybuffer(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Objects"; ot->idname = "VIEW3D_OT_copybuffer"; - ot->description = "Selected objects are copied to the clipboard"; + ot->description = "Copy the selected objects to the internal clipboard"; /* api callbacks */ ot->exec = view3d_copybuffer_exec; @@ -113,7 +113,7 @@ static void VIEW3D_OT_pastebuffer(wmOperatorType *ot) /* identifiers */ ot->name = "Paste Objects"; ot->idname = "VIEW3D_OT_pastebuffer"; - ot->description = "Objects from the clipboard are pasted"; + ot->description = "Paste objects from the internal clipboard"; /* api callbacks */ ot->exec = view3d_pastebuffer_exec; diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index 50adf47b799..3a9b366f03a 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -71,7 +71,7 @@ #include "ED_armature.h" #include "ED_curve.h" #include "ED_curves.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_lattice.h" #include "ED_mball.h" #include "ED_mesh.h" @@ -3664,8 +3664,7 @@ static bool do_mesh_box_select(ViewContext *vc, } if (ts->selectmode & SCE_SELECT_EDGE) { /* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */ - struct BoxSelectUserData_ForMeshEdge cb_data { - }; + struct BoxSelectUserData_ForMeshEdge cb_data {}; cb_data.data = &data; cb_data.esel = use_zbuf ? esel : nullptr; cb_data.backbuf_offset = use_zbuf ? DRW_select_buffer_context_offset_for_object_elem( diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index d75f0c0c8cd..338e91589c6 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -31,7 +31,7 @@ set(SRC transform_convert_cursor.c transform_convert_curve.c transform_convert_curves.cc - transform_convert_gpencil.c + transform_convert_gpencil_legacy.c transform_convert_graph.c transform_convert_lattice.c transform_convert_mask.c diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 78a42f1a3d8..b584eacce0a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -26,7 +26,7 @@ #include "GPU_state.h" #include "ED_clip.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_image.h" #include "ED_keyframing.h" #include "ED_node.h" diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h index bc7c4058d66..c409b2a4f31 100644 --- a/source/blender/editors/transform/transform_convert.h +++ b/source/blender/editors/transform/transform_convert.h @@ -142,7 +142,7 @@ extern TransConvertTypeInfo TransConvertType_Curves; extern TransConvertTypeInfo TransConvertType_Graph; -/* transform_convert_gpencil.c */ +/* transform_convert_gpencil_legacy.c */ extern TransConvertTypeInfo TransConvertType_GPencil; diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil_legacy.c similarity index 99% rename from source/blender/editors/transform/transform_convert_gpencil.c rename to source/blender/editors/transform/transform_convert_gpencil_legacy.c index 20e494ecdab..0446b14119b 100644 --- a/source/blender/editors/transform/transform_convert_gpencil.c +++ b/source/blender/editors/transform/transform_convert_gpencil_legacy.c @@ -21,7 +21,7 @@ #include "BKE_gpencil_legacy.h" #include "BKE_layer.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframing.h" #include "transform.h" diff --git a/source/blender/editors/transform/transform_gizmo_3d.cc b/source/blender/editors/transform/transform_gizmo_3d.cc index af6db57e275..e61990732ee 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.cc +++ b/source/blender/editors/transform/transform_gizmo_3d.cc @@ -34,7 +34,7 @@ #include "ED_curves.h" #include "ED_gizmo_library.h" #include "ED_gizmo_utils.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "ED_particle.h" #include "ED_screen.h" diff --git a/source/blender/editors/undo/ed_undo.cc b/source/blender/editors/undo/ed_undo.cc index d22c97cb9d4..dfd1f4c6860 100644 --- a/source/blender/editors/undo/ed_undo.cc +++ b/source/blender/editors/undo/ed_undo.cc @@ -35,7 +35,7 @@ #include "BLO_blend_validate.h" #include "ED_asset.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "ED_outliner.h" #include "ED_render.h" diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 66c3b9da74c..90f81030669 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -52,7 +52,7 @@ set(SRC ../include/ED_geometry.h ../include/ED_gizmo_library.h ../include/ED_gizmo_utils.h - ../include/ED_gpencil.h + ../include/ED_gpencil_legacy.h ../include/ED_image.h ../include/ED_info.h ../include/ED_keyframes_draw.h diff --git a/source/blender/editors/util/ed_util.cc b/source/blender/editors/util/ed_util.cc index 3e19a3f701d..b04ba65edd0 100644 --- a/source/blender/editors/util/ed_util.cc +++ b/source/blender/editors/util/ed_util.cc @@ -37,7 +37,7 @@ #include "ED_armature.h" #include "ED_asset.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_image.h" #include "ED_mesh.h" #include "ED_object.h" diff --git a/source/blender/functions/intern/cpp_types.cc b/source/blender/functions/intern/cpp_types.cc index e7abe7899a2..e11ed0b56e1 100644 --- a/source/blender/functions/intern/cpp_types.cc +++ b/source/blender/functions/intern/cpp_types.cc @@ -17,6 +17,7 @@ FN_FIELD_CPP_TYPE_MAKE(blender::ColorGeometry4b); FN_FIELD_CPP_TYPE_MAKE(bool); FN_FIELD_CPP_TYPE_MAKE(int8_t); FN_FIELD_CPP_TYPE_MAKE(int32_t); +FN_FIELD_CPP_TYPE_MAKE(blender::int2); FN_FIELD_CPP_TYPE_MAKE(std::string); BLI_VECTOR_CPP_TYPE_MAKE(blender::fn::ValueOrField); @@ -31,6 +32,7 @@ void FN_register_cpp_types() FN_FIELD_CPP_TYPE_REGISTER(bool); FN_FIELD_CPP_TYPE_REGISTER(int8_t); FN_FIELD_CPP_TYPE_REGISTER(int32_t); + FN_FIELD_CPP_TYPE_REGISTER(blender::int2); FN_FIELD_CPP_TYPE_REGISTER(std::string); BLI_VECTOR_CPP_TYPE_REGISTER(blender::fn::ValueOrField); diff --git a/source/blender/geometry/intern/mesh_split_edges.cc b/source/blender/geometry/intern/mesh_split_edges.cc index 784f468ef06..4908c67e288 100644 --- a/source/blender/geometry/intern/mesh_split_edges.cc +++ b/source/blender/geometry/intern/mesh_split_edges.cc @@ -28,6 +28,11 @@ static void copy_to_new_verts(MutableSpan data, const Span new_to_old_ve static void add_new_vertices(Mesh &mesh, const Span new_to_old_verts_map) { + /* These types aren't supported for interpolation below. */ + CustomData_free_layers(&mesh.vdata, CD_BWEIGHT, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_SHAPEKEY, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_CLOTH_ORCO, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_MVERT_SKIN, mesh.totvert); CustomData_realloc(&mesh.vdata, mesh.totvert, mesh.totvert + new_to_old_verts_map.size()); mesh.totvert += new_to_old_verts_map.size(); diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt deleted file mode 100644 index 91a17a5f00f..00000000000 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2018 Blender Foundation - -set(INC - . - intern - ../blenfont - ../blenkernel - ../blenlib - ../blentranslation - ../bmesh - ../depsgraph - ../editors/include - ../makesdna - ../makesrna - ../render - ../windowmanager - ../../../intern/eigen - ../../../intern/guardedalloc - - # dna_type_offsets.h in BLO_read_write.h - ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern - # RNA_prototypes.h - ${CMAKE_BINARY_DIR}/source/blender/makesrna -) - -set(INC_SYS - ${ZLIB_INCLUDE_DIRS} -) - -set(SRC - intern/MOD_gpencil_ui_common.c - - intern/MOD_gpencil_util.c - intern/MOD_gpencilarmature.c - intern/MOD_gpencilarray.c - intern/MOD_gpencilbuild.c - intern/MOD_gpencilcolor.c - intern/MOD_gpencildash.c - intern/MOD_gpencilenvelope.c - intern/MOD_gpencilhook.c - intern/MOD_gpencillattice.c - intern/MOD_gpencillength.c - intern/MOD_gpencillineart.c - intern/MOD_gpencilmirror.c - intern/MOD_gpencilmultiply.c - intern/MOD_gpencilnoise.c - intern/MOD_gpenciloffset.c - intern/MOD_gpencilopacity.c - intern/MOD_gpenciloutline.c - intern/MOD_gpencilshrinkwrap.c - intern/MOD_gpencilsimplify.c - intern/MOD_gpencilsmooth.c - intern/MOD_gpencilsubdiv.c - intern/MOD_gpenciltexture.c - intern/MOD_gpencilthick.c - intern/MOD_gpenciltime.c - intern/MOD_gpenciltint.c - intern/MOD_gpencilweight_angle.c - intern/MOD_gpencilweight_proximity.c - - MOD_gpencil_lineart.h - MOD_gpencil_modifiertypes.h - intern/MOD_gpencil_ui_common.h - intern/MOD_gpencil_util.h - - # Lineart code - intern/lineart/lineart_chain.c - intern/lineart/lineart_cpu.cc - intern/lineart/lineart_ops.c - intern/lineart/lineart_shadow.c - intern/lineart/lineart_util.c - - intern/lineart/MOD_lineart.h - intern/lineart/lineart_intern.h -) - -if(WITH_TBB) -add_definitions(-DWITH_TBB) -if(WIN32) - # TBB includes Windows.h which will define min/max macros - # that will collide with the stl versions. - add_definitions(-DNOMINMAX) -endif() -list(APPEND INC_SYS - ${TBB_INCLUDE_DIRS} -) - -list(APPEND LIB - ${TBB_LIBRARIES} -) -endif() - -set(LIB -) - -blender_add_lib(bf_gpencil_modifiers "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") - -add_dependencies(bf_gpencil_modifiers bf_dna) -# RNA_prototypes.h -add_dependencies(bf_gpencil_modifiers bf_rna) diff --git a/source/blender/gpencil_modifiers_legacy/CMakeLists.txt b/source/blender/gpencil_modifiers_legacy/CMakeLists.txt new file mode 100644 index 00000000000..5a5dbd4bb1f --- /dev/null +++ b/source/blender/gpencil_modifiers_legacy/CMakeLists.txt @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2018 Blender Foundation + +set(INC + . + intern + ../blenfont + ../blenkernel + ../blenlib + ../blentranslation + ../bmesh + ../depsgraph + ../editors/include + ../makesdna + ../makesrna + ../render + ../windowmanager + ../../../intern/eigen + ../../../intern/guardedalloc + + # dna_type_offsets.h in BLO_read_write.h + ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern + # RNA_prototypes.h + ${CMAKE_BINARY_DIR}/source/blender/makesrna +) + +set(INC_SYS + ${ZLIB_INCLUDE_DIRS} +) + +set(SRC + intern/MOD_gpencil_legacy_ui_common.c + + intern/MOD_gpencil_legacy_util.c + intern/MOD_gpencil_legacy_armature.c + intern/MOD_gpencil_legacy_array.c + intern/MOD_gpencil_legacy_build.c + intern/MOD_gpencil_legacy_color.c + intern/MOD_gpencil_legacy_dash.c + intern/MOD_gpencil_legacy_envelope.c + intern/MOD_gpencil_legacy_hook.c + intern/MOD_gpencil_legacy_lattice.c + intern/MOD_gpencil_legacy_length.c + intern/MOD_gpencil_legacy_lineart.c + intern/MOD_gpencil_legacy_mirror.c + intern/MOD_gpencil_legacy_multiply.c + intern/MOD_gpencil_legacy_noise.c + intern/MOD_gpencil_legacy_offset.c + intern/MOD_gpencil_legacy_opacity.c + intern/MOD_gpencil_legacy_outline.c + intern/MOD_gpencil_legacy_shrinkwrap.c + intern/MOD_gpencil_legacy_simplify.c + intern/MOD_gpencil_legacy_smooth.c + intern/MOD_gpencil_legacy_subdiv.c + intern/MOD_gpencil_legacy_texture.c + intern/MOD_gpencil_legacy_thick.c + intern/MOD_gpencil_legacy_time.c + intern/MOD_gpencil_legacy_tint.c + intern/MOD_gpencil_legacy_weight_angle.c + intern/MOD_gpencil_legacy_weight_proximity.c + + MOD_gpencil_legacy_lineart.h + MOD_gpencil_legacy_modifiertypes.h + intern/MOD_gpencil_legacy_ui_common.h + intern/MOD_gpencil_legacy_util.h + + # Lineart code + intern/lineart/lineart_chain.c + intern/lineart/lineart_cpu.cc + intern/lineart/lineart_ops.c + intern/lineart/lineart_shadow.c + intern/lineart/lineart_util.c + + intern/lineart/MOD_lineart.h + intern/lineart/lineart_intern.h +) + +if(WITH_TBB) +add_definitions(-DWITH_TBB) +if(WIN32) + # TBB includes Windows.h which will define min/max macros + # that will collide with the stl versions. + add_definitions(-DNOMINMAX) +endif() +list(APPEND INC_SYS + ${TBB_INCLUDE_DIRS} +) + +list(APPEND LIB + ${TBB_LIBRARIES} +) +endif() + +set(LIB +) + +blender_add_lib(bf_gpencil_modifiers_legacy "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") + +add_dependencies(bf_gpencil_modifiers_legacy bf_dna) +# RNA_prototypes.h +add_dependencies(bf_gpencil_modifiers_legacy bf_rna) diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_lineart.h b/source/blender/gpencil_modifiers_legacy/MOD_gpencil_legacy_lineart.h similarity index 100% rename from source/blender/gpencil_modifiers/MOD_gpencil_lineart.h rename to source/blender/gpencil_modifiers_legacy/MOD_gpencil_legacy_lineart.h diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers_legacy/MOD_gpencil_legacy_modifiertypes.h similarity index 98% rename from source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h rename to source/blender/gpencil_modifiers_legacy/MOD_gpencil_legacy_modifiertypes.h index 58ccc2299bd..652195ce541 100644 --- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h +++ b/source/blender/gpencil_modifiers_legacy/MOD_gpencil_legacy_modifiertypes.h @@ -38,6 +38,6 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Dash; extern GpencilModifierTypeInfo modifierType_Gpencil_Shrinkwrap; extern GpencilModifierTypeInfo modifierType_Gpencil_Envelope; -/* MOD_gpencil_util.c */ +/* MOD_gpencil_legacy_util.c */ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.c index 2b8c0d99b05..15aa95ed01e 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.c @@ -39,9 +39,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c index 8e949292b11..adedb0458ca 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c @@ -43,9 +43,9 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" typedef struct tmpStrokes { struct tmpStrokes *next, *prev; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c index 05eb80c0bef..57d743809ee 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c @@ -44,8 +44,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" /* Two hard-coded values for GP_BUILD_MODE_ADDITIVE with GP_BUILD_TIMEMODE_DRAWSPEED. */ diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c index da33312d0b5..2ccd6518265 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c @@ -36,9 +36,9 @@ #include "DEG_depsgraph.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencildash.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c index ffbb8d9c1f0..cf8380d30e6 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c @@ -38,9 +38,9 @@ #include "BLT_translation.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c index 5c7400292ed..3ce6ed33648 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c @@ -40,9 +40,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c index dc41cc9401f..7aa836c6740 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c @@ -42,9 +42,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c index 88a3e8164d0..ccd3ab59e92 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c @@ -37,9 +37,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencillength.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c index b0a54cb7837..0dca04f568b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c @@ -38,9 +38,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c index 5546524cccb..9d5074238c9 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c @@ -39,9 +39,9 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_gpencil_lineart.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" +#include "MOD_gpencil_legacy_lineart.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" #include "lineart/MOD_lineart.h" static void initData(GpencilModifierData *md) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c index 747dcc239ce..6e3461d6833 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c @@ -34,9 +34,9 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c index 6ae2c323c81..bce0f02d6d7 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c @@ -40,9 +40,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c index 40394dc09cc..3be6aff0979 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c @@ -41,9 +41,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c index e787073cda5..e21316f006e 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c @@ -41,9 +41,9 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c index a06c7817f17..9901b4412c8 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c @@ -35,9 +35,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloutline.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpenciloutline.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c index c71de59bd49..7332d2e0891 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloutline.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c @@ -40,9 +40,9 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c index c4ac6f680e6..2900f51a29e 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c @@ -40,9 +40,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c similarity index 97% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c index 231da156c84..713c4531043 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c @@ -33,9 +33,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c index 1a60359e7f3..497622ab141 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c @@ -36,9 +36,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c similarity index 97% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c index f68ebebd7d2..bc5ea5a4cf4 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c @@ -31,9 +31,9 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c index 1b7efc79457..b19f4f739cc 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c @@ -35,9 +35,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c index ea754ef8b20..1ebca18bcde 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c @@ -35,9 +35,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c index 4ef6dd2c30a..83d5da1ef2b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c @@ -38,9 +38,9 @@ #include "RNA_access.h" #include "RNA_prototypes.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "UI_interface.h" #include "UI_resources.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c index da9a833e390..499d490d135 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c @@ -43,9 +43,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c index 1605da90c6c..424d2a37010 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c @@ -31,7 +31,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "MOD_gpencil_ui_common.h" /* Self include */ +#include "MOD_gpencil_legacy_ui_common.h" /* Self include */ /** * Poll function so these modifier panels only show for grease pencil objects. diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.h similarity index 97% rename from source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.h index 57eac4d77bf..bb3a58a5254 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.h @@ -10,7 +10,7 @@ extern "C" { #endif -#include "MOD_gpencil_modifiertypes.h" +#include "MOD_gpencil_legacy_modifiertypes.h" struct ARegionType; struct PanelType; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.c index 8707eae7fa6..ddd043ea87a 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.c @@ -23,8 +23,8 @@ #include "BKE_material.h" #include "BKE_scene.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_util.h" #include "DEG_depsgraph_query.h" diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.h similarity index 100% rename from source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.h diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilweight_angle.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilweight_angle.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c index 237fc6e5afb..916298e2f17 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilweight_angle.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c @@ -36,9 +36,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilweight_proximity.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c similarity index 98% rename from source/blender/gpencil_modifiers/intern/MOD_gpencilweight_proximity.c rename to source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c index 76d2d1692bc..d1bfb65e6b7 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilweight_proximity.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c @@ -37,9 +37,9 @@ #include "RNA_access.h" -#include "MOD_gpencil_modifiertypes.h" -#include "MOD_gpencil_ui_common.h" -#include "MOD_gpencil_util.h" +#include "MOD_gpencil_legacy_modifiertypes.h" +#include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" static void initData(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h similarity index 100% rename from source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h rename to source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.c similarity index 100% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c rename to source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.c diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc similarity index 99% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc rename to source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc index c41139f1d9b..32e9eb4f714 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc @@ -5,7 +5,7 @@ * \ingroup editors */ -#include "MOD_gpencil_lineart.h" +#include "MOD_gpencil_legacy_lineart.h" #include "MOD_lineart.h" #include "BLI_edgehash.h" diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_intern.h similarity index 100% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h rename to source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_intern.h diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c rename to source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.c index 19dee478ecd..be7b4be61af 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.c @@ -29,7 +29,7 @@ #include "DNA_gpencil_modifier_types.h" #include "DNA_scene_types.h" -#include "MOD_gpencil_lineart.h" +#include "MOD_gpencil_legacy_lineart.h" #include "MOD_lineart.h" static bool lineart_mod_is_disabled(GpencilModifierData *md) diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c similarity index 99% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c rename to source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c index 1daea4a226b..54e5658f637 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c @@ -4,7 +4,7 @@ * \ingroup modifiers */ -#include "MOD_gpencil_lineart.h" +#include "MOD_gpencil_legacy_lineart.h" #include "MOD_lineart.h" #include "lineart_intern.h" diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_util.c b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_util.c similarity index 100% rename from source/blender/gpencil_modifiers/intern/lineart/lineart_util.c rename to source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_util.c diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index 1955bf2f948..e9378e6c225 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -23,7 +23,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_view3d.h" #ifdef WIN32 diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index d2d79e9cb33..1e6f688837d 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -23,7 +23,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_view3d.h" #ifdef WIN32 diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc index 4624ee23553..d63d546074b 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc @@ -13,7 +13,7 @@ #include "BKE_gpencil_legacy.h" #include "BKE_material.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "gpencil_io_import_base.hh" diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc index f90d6f33a5b..34661027fd4 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_import_svg.cc @@ -17,7 +17,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "gpencil_io.h" #include "gpencil_io_import_svg.hh" diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 4df4f7d566a..762686331f8 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -25,6 +25,9 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_windowmanager_types.h" + +#include "WM_api.h" #include "MEM_guardedalloc.h" @@ -408,102 +411,191 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo } } -void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime) +void USDMeshReader::read_color_data_all_primvars(Mesh *mesh, const double motionSampleTime) { if (!(mesh && mesh_prim_ && mesh->totloop > 0)) { return; } - /* Early out if we read the display color before and if this attribute isn't animated. */ - if (primvar_varying_map_.find(usdtokens::displayColor) != primvar_varying_map_.end() && - !primvar_varying_map_.at(usdtokens::displayColor)) { + pxr::UsdGeomPrimvarsAPI pv_api = pxr::UsdGeomPrimvarsAPI(mesh_prim_); + std::vector primvars = pv_api.GetPrimvarsWithValues(); + + pxr::TfToken active_color_name; + + /* Convert color primvars to custom layer data. */ + for (pxr::UsdGeomPrimvar &pv : primvars) { + if (!pv.HasValue()) { + continue; + } + + pxr::SdfValueTypeName type = pv.GetTypeName(); + + if (!ELEM(type, + pxr::SdfValueTypeNames->Color3hArray, + pxr::SdfValueTypeNames->Color3fArray, + pxr::SdfValueTypeNames->Color3dArray)) { + continue; + } + + pxr::TfToken name = pv.GetPrimvarName(); + + /* Set the active color name to 'displayColor', if a color primvar + * with this name exists. Otherwise, use the name of the first + * color primvar we find for the active color. */ + if (active_color_name.IsEmpty() || name == usdtokens::displayColor) { + active_color_name = name; + } + + /* Skip if we read this primvar before and it isn't animated. */ + const std::map::const_iterator is_animated_iter = + primvar_varying_map_.find(name); + if (is_animated_iter != primvar_varying_map_.end() && !is_animated_iter->second) { + continue; + } + + read_color_data_primvar(mesh, pv, motionSampleTime); + } + + if (!active_color_name.IsEmpty()) { + BKE_id_attributes_default_color_set(&mesh->id, active_color_name.GetText()); + BKE_id_attributes_active_color_set(&mesh->id, active_color_name.GetText()); + } +} + +void USDMeshReader::read_color_data_primvar(Mesh *mesh, + const pxr::UsdGeomPrimvar &color_primvar, + const double motionSampleTime) +{ + if (!(mesh && color_primvar && color_primvar.HasValue())) { return; } - pxr::UsdGeomPrimvar color_primvar = mesh_prim_.GetDisplayColorPrimvar(); - - if (!color_primvar.HasValue()) { - return; - } - - pxr::TfToken interp = color_primvar.GetInterpolation(); - - if (interp == pxr::UsdGeomTokens->varying) { - std::cerr << "WARNING: Unsupported varying interpolation for display colors\n" << std::endl; - return; - } - - if (primvar_varying_map_.find(usdtokens::displayColor) == primvar_varying_map_.end()) { + if (primvar_varying_map_.find(color_primvar.GetPrimvarName()) == primvar_varying_map_.end()) { bool might_be_time_varying = color_primvar.ValueMightBeTimeVarying(); - primvar_varying_map_.insert(std::make_pair(usdtokens::displayColor, might_be_time_varying)); + primvar_varying_map_.insert( + std::make_pair(color_primvar.GetPrimvarName(), might_be_time_varying)); if (might_be_time_varying) { is_time_varying_ = true; } } - pxr::VtArray display_colors; + pxr::VtArray usd_colors; - if (!color_primvar.ComputeFlattened(&display_colors, motionSampleTime)) { - std::cerr << "WARNING: Couldn't compute display colors\n" << std::endl; + if (!color_primvar.ComputeFlattened(&usd_colors, motionSampleTime)) { + WM_reportf(RPT_WARNING, + "USD Import: couldn't compute values for color attribute '%s'", + color_primvar.GetName().GetText()); return; } - if ((interp == pxr::UsdGeomTokens->faceVarying && display_colors.size() != mesh->totloop) || - (interp == pxr::UsdGeomTokens->vertex && display_colors.size() != mesh->totvert) || - (interp == pxr::UsdGeomTokens->constant && display_colors.size() != 1) || - (interp == pxr::UsdGeomTokens->uniform && display_colors.size() != mesh->totpoly)) { - std::cerr << "WARNING: display colors count mismatch\n" << std::endl; + pxr::TfToken interp = color_primvar.GetInterpolation(); + + if ((interp == pxr::UsdGeomTokens->faceVarying && usd_colors.size() != mesh->totloop) || + (interp == pxr::UsdGeomTokens->varying && usd_colors.size() != mesh->totloop) || + (interp == pxr::UsdGeomTokens->vertex && usd_colors.size() != mesh->totvert) || + (interp == pxr::UsdGeomTokens->constant && usd_colors.size() != 1) || + (interp == pxr::UsdGeomTokens->uniform && usd_colors.size() != mesh->totpoly)) { + WM_reportf(RPT_WARNING, + "USD Import: color attribute value '%s' count inconsistent with interpolation type", + color_primvar.GetName().GetText()); return; } - void *cd_ptr = add_customdata_cb(mesh, "displayColor", CD_PROP_BYTE_COLOR); + const StringRef color_primvar_name(color_primvar.GetBaseName().GetString()); + bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); - if (!cd_ptr) { - std::cerr << "WARNING: Couldn't add displayColor custom data.\n"; + eAttrDomain color_domain = ATTR_DOMAIN_POINT; + + if (ELEM(interp, + pxr::UsdGeomTokens->varying, + pxr::UsdGeomTokens->faceVarying, + pxr::UsdGeomTokens->uniform)) { + color_domain = ATTR_DOMAIN_CORNER; + } + + bke::SpanAttributeWriter color_data; + color_data = attributes.lookup_or_add_for_write_only_span(color_primvar_name, + color_domain); + if (!color_data) { + WM_reportf(RPT_WARNING, + "USD Import: couldn't add color attribute '%s'", + color_primvar.GetBaseName().GetText()); return; } - MLoopCol *colors = static_cast(cd_ptr); - - const OffsetIndices polys = mesh->polys(); - const Span corner_verts = mesh->corner_verts(); - for (const int i : polys.index_range()) { - const IndexRange poly = polys[i]; - for (int j = 0; j < poly.size(); ++j) { - int loop_index = poly[j]; - - /* Default for constant varying interpolation. */ - int usd_index = 0; - - if (interp == pxr::UsdGeomTokens->vertex) { - usd_index = corner_verts[loop_index]; + if (ELEM(interp, pxr::UsdGeomTokens->constant, pxr::UsdGeomTokens->uniform)) { + /* For situations where there's only a single item, flood fill the object. */ + color_data.span.fill( + ColorGeometry4f(usd_colors[0][0], usd_colors[0][1], usd_colors[0][2], 1.0f)); + } + else { + /* Check for situations that allow for a straight-forward copy by index. */ + if ((ELEM(interp, pxr::UsdGeomTokens->vertex)) || + (color_domain == ATTR_DOMAIN_CORNER && !is_left_handed_)) { + for (int i = 0; i < usd_colors.size(); i++) { + ColorGeometry4f color = ColorGeometry4f( + usd_colors[i][0], usd_colors[i][1], usd_colors[i][2], 1.0f); + color_data.span[i] = color; } - else if (interp == pxr::UsdGeomTokens->faceVarying) { - usd_index = poly.start(); - if (is_left_handed_) { - usd_index += poly.size() - 1 - j; - } - else { - usd_index += j; + } + + /* Special case: expand uniform color into corner color. + * Uniforms in USD come through as single colors, face-varying. Since Blender does not + * support this particular combination for paintable color attributes, we convert the type + * here to make sure that the user gets the same visual result. + * */ + else if (ELEM(interp, pxr::UsdGeomTokens->uniform)) { + for (int i = 0; i < usd_colors.size(); i++) { + const ColorGeometry4f color = ColorGeometry4f( + usd_colors[i][0], usd_colors[i][1], usd_colors[i][2], 1.0f); + color_data.span[i * 4] = color; + color_data.span[i * 4 + 1] = color; + color_data.span[i * 4 + 2] = color; + color_data.span[i * 4 + 3] = color; + } + } + + else { + const OffsetIndices polys = mesh->polys(); + const Span corner_verts = mesh->corner_verts(); + for (const int i : polys.index_range()) { + const IndexRange &poly = polys[i]; + for (int j = 0; j < poly.size(); ++j) { + int loop_index = poly[j]; + + /* Default for constant varying interpolation. */ + int usd_index = 0; + + if (interp == pxr::UsdGeomTokens->vertex) { + usd_index = corner_verts[loop_index]; + } + else if (interp == pxr::UsdGeomTokens->faceVarying) { + usd_index = poly.start(); + if (is_left_handed_) { + usd_index += poly.size() - 1 - j; + } + else { + usd_index += j; + } + } + else if (interp == pxr::UsdGeomTokens->uniform) { + /* Uniform varying uses the poly index. */ + usd_index = i; + } + + if (usd_index >= usd_colors.size()) { + continue; + } + + ColorGeometry4f color = ColorGeometry4f( + usd_colors[usd_index][0], usd_colors[usd_index][1], usd_colors[usd_index][2], 1.0f); + color_data.span[usd_index] = color; } } - else if (interp == pxr::UsdGeomTokens->uniform) { - /* Uniform varying uses the poly index. */ - usd_index = i; - } - - if (usd_index >= display_colors.size()) { - continue; - } - - colors[loop_index].r = unit_float_to_uchar_clamp(display_colors[usd_index][0]); - colors[loop_index].g = unit_float_to_uchar_clamp(display_colors[usd_index][1]); - colors[loop_index].b = unit_float_to_uchar_clamp(display_colors[usd_index][2]); - colors[loop_index].a = unit_float_to_uchar_clamp(1.0); } } - BKE_id_attributes_active_color_set(&mesh->id, "displayColor"); + color_data.finish(); } void USDMeshReader::read_vertex_creases(Mesh *mesh, const double motionSampleTime) @@ -672,9 +764,19 @@ void USDMeshReader::read_mesh_sample(ImportSettings *settings, read_uvs(mesh, motionSampleTime, new_mesh); } + /* Custom Data layers. */ + read_custom_data(settings, mesh, motionSampleTime); +} + +void USDMeshReader::read_custom_data(const ImportSettings *settings, + Mesh *mesh, + const double motionSampleTime) +{ if ((settings->read_flag & MOD_MESHSEQ_READ_COLOR) != 0) { - read_colors(mesh, motionSampleTime); + read_color_data_all_primvars(mesh, motionSampleTime); } + + /* TODO: Generic readers for custom data layers not listed above. */ } void USDMeshReader::assign_facesets_to_material_indices(double motionSampleTime, diff --git a/source/blender/io/usd/intern/usd_reader_mesh.h b/source/blender/io/usd/intern/usd_reader_mesh.h index 0cabae2a653..7d5c512de1e 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.h +++ b/source/blender/io/usd/intern/usd_reader_mesh.h @@ -66,13 +66,20 @@ class USDMeshReader : public USDGeomReader { void read_mpolys(Mesh *mesh); void read_uvs(Mesh *mesh, double motionSampleTime, bool load_uvs = false); - void read_colors(Mesh *mesh, double motionSampleTime); void read_vertex_creases(Mesh *mesh, double motionSampleTime); void read_mesh_sample(ImportSettings *settings, Mesh *mesh, double motionSampleTime, bool new_mesh); + + void read_custom_data(const ImportSettings *settings, + Mesh *mesh, + double motionSampleTime); + + void read_color_data_all_primvars(Mesh *mesh, const double motionSampleTime); + void read_color_data_primvar(Mesh *mesh, const pxr::UsdGeomPrimvar &color_primvar, + const double motionSampleTime); }; } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 885b34eb5ba..305b10c8a8a 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -14,7 +14,6 @@ #include "BLI_math_vector_types.hh" #include "BKE_attribute.h" -#include "BKE_attribute.hh" #include "BKE_customdata.h" #include "BKE_lib_id.h" #include "BKE_material.h" @@ -32,6 +31,8 @@ #include "DNA_object_fluidsim_types.h" #include "DNA_particle_types.h" +#include "WM_api.h" + #include namespace blender::io::usd { @@ -73,6 +74,72 @@ void USDGenericMeshWriter::do_write(HierarchyContext &context) } } +void USDGenericMeshWriter::write_custom_data(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh) +{ + const bke::AttributeAccessor attributes = mesh->attributes(); + + attributes.for_all( + [&](const bke::AttributeIDRef &attribute_id, const bke::AttributeMetaData &meta_data) { + /* Color data. */ + if (ELEM(meta_data.domain, ATTR_DOMAIN_CORNER, ATTR_DOMAIN_POINT) && + ELEM(meta_data.data_type, CD_PROP_BYTE_COLOR, CD_PROP_COLOR)) { + write_color_data(mesh, usd_mesh, attribute_id, meta_data); + } + + return true; + }); +} + +void USDGenericMeshWriter::write_color_data(const Mesh *mesh, + pxr::UsdGeomMesh usd_mesh, + const bke::AttributeIDRef &attribute_id, + const bke::AttributeMetaData &meta_data) +{ + pxr::UsdTimeCode timecode = get_export_time_code(); + const std::string name = attribute_id.name(); + pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(name)); + const pxr::UsdGeomPrimvarsAPI pvApi = pxr::UsdGeomPrimvarsAPI(usd_mesh); + + /* Varying type depends on original domain. */ + const pxr::TfToken prim_varying = meta_data.domain == ATTR_DOMAIN_CORNER ? + pxr::UsdGeomTokens->faceVarying : + pxr::UsdGeomTokens->vertex; + + pxr::UsdGeomPrimvar colors_pv = pvApi.CreatePrimvar( + primvar_name, pxr::SdfValueTypeNames->Color3fArray, prim_varying); + + const VArray attribute = mesh->attributes().lookup_or_default( + attribute_id, meta_data.domain, {0.0f, 0.0f, 0.0f, 1.0f}); + + pxr::VtArray colors_data; + + /* TODO: Thread the copy, like the obj exporter. */ + switch (meta_data.domain) { + case ATTR_DOMAIN_CORNER: + for (size_t loop_idx = 0; loop_idx < mesh->totloop; loop_idx++) { + const ColorGeometry4f color = attribute.get(loop_idx); + colors_data.push_back(pxr::GfVec3f(color.r, color.g, color.b)); + } + break; + + case ATTR_DOMAIN_POINT: + for (const int point_index : attribute.index_range()) { + const ColorGeometry4f color = attribute.get(point_index); + colors_data.push_back(pxr::GfVec3f(color.r, color.g, color.b)); + } + break; + + default: + BLI_assert_msg(0, "Invalid domain for mesh color data."); + return; + } + + colors_pv.Set(colors_data, timecode); + + const pxr::UsdAttribute &prim_colors_attr = colors_pv.GetAttr(); + usd_value_writer_.SetAttribute(prim_colors_attr, pxr::VtValue(colors_data), timecode); +} + void USDGenericMeshWriter::free_export_mesh(Mesh *mesh) { BKE_id_free(nullptr, mesh); @@ -233,6 +300,9 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh) if (usd_export_context_.export_params.export_uvmaps) { write_uv_maps(mesh, usd_mesh); } + + write_custom_data(mesh, usd_mesh); + if (usd_export_context_.export_params.export_normals) { write_normals(mesh, usd_mesh); } diff --git a/source/blender/io/usd/intern/usd_writer_mesh.h b/source/blender/io/usd/intern/usd_writer_mesh.h index 4abfa69aaa9..723835f4cd2 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.h +++ b/source/blender/io/usd/intern/usd_writer_mesh.h @@ -4,6 +4,8 @@ #include "usd_writer_abstract.h" +#include "BKE_attribute.hh" + #include namespace blender::io::usd { @@ -34,6 +36,12 @@ class USDGenericMeshWriter : public USDAbstractWriter { void write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh); void write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh); void write_surface_velocity(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh); + + void write_custom_data(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh); + void write_color_data(const Mesh *mesh, + pxr::UsdGeomMesh usd_mesh, + const bke::AttributeIDRef &attribute_id, + const bke::AttributeMetaData &meta_data); }; class USDMeshWriter : public USDGenericMeshWriter { diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h index cef5f70b732..a92ba92d2cd 100644 --- a/source/blender/makesdna/DNA_curves_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -107,6 +107,9 @@ typedef struct CurvesGeometry { * Every curve offset must be at least one larger than the previous. In other words, every curve * must have at least one point. The first value is 0 and the last value is #point_num. * + * This array is shared based on the bke::MeshRuntime::poly_offsets_sharing_info. + * Avoid accessing directly when possible. + * * \note This is *not* stored as an attribute because its size is one larger than #curve_num. */ int *curve_offsets; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 816d39965ee..305c8ecfc1d 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -104,8 +104,8 @@ typedef enum eCustomDataType { CD_AUTO_FROM_NAME = -1, #ifdef DNA_DEPRECATED_ALLOW - CD_MVERT = 0, /* DEPRECATED */ - CD_MSTICKY = 1, /* DEPRECATED */ + CD_MVERT = 0, + CD_MSTICKY = 1, #endif CD_MDEFORMVERT = 2, /* Array of `MDeformVert`. */ CD_MEDGE = 3, @@ -125,9 +125,9 @@ typedef enum eCustomDataType { CD_ORIGSPACE = 13, /* for modifier stack face location mapping */ CD_ORCO = 14, /* undeformed vertex coordinates, normalized to 0..1 range */ #ifdef DNA_DEPRECATED_ALLOW - CD_MTEXPOLY = 15, /* deprecated */ -#endif + CD_MTEXPOLY = 15, CD_MLOOPUV = 16, +#endif CD_PROP_BYTE_COLOR = 17, CD_TANGENT = 18, CD_MDISPS = 19, @@ -138,7 +138,9 @@ typedef enum eCustomDataType { /* CD_RECAST = 24, */ /* UNUSED */ CD_MPOLY = 25, +#ifdef DNA_DEPRECATED_ALLOW CD_MLOOP = 26, +#endif CD_SHAPE_KEYINDEX = 27, CD_SHAPEKEY = 28, CD_BWEIGHT = 29, @@ -156,12 +158,15 @@ typedef enum eCustomDataType { CD_MLOOPTANGENT = 39, CD_TESSLOOPNORMAL = 40, CD_CUSTOMLOOPNORMAL = 41, +#ifdef DNA_DEPRECATED_ALLOW CD_SCULPT_FACE_SETS = 42, +#endif /* CD_LOCATION = 43, */ /* UNUSED */ /* CD_RADIUS = 44, */ /* UNUSED */ CD_PROP_INT8 = 45, - /* CD_HAIRMAPPING = 46, */ /* UNUSED, can be reused. */ + /* Two 32-bit signed integers. */ + CD_PROP_INT32_2D = 46, CD_PROP_COLOR = 47, CD_PROP_FLOAT3 = 48, @@ -174,8 +179,6 @@ typedef enum eCustomDataType { } eCustomDataType; /* Bits for eCustomDataMask */ -// #define CD_MASK_MVERT (1 << CD_MVERT) /* DEPRECATED */ -// #define CD_MASK_MSTICKY (1 << CD_MSTICKY) /* DEPRECATED */ #define CD_MASK_MDEFORMVERT (1 << CD_MDEFORMVERT) #define CD_MASK_MEDGE (1 << CD_MEDGE) #define CD_MASK_MFACE (1 << CD_MFACE) @@ -189,13 +192,11 @@ typedef enum eCustomDataType { #define CD_MASK_PROP_STRING (1 << CD_PROP_STRING) #define CD_MASK_ORIGSPACE (1 << CD_ORIGSPACE) #define CD_MASK_ORCO (1 << CD_ORCO) -// #define CD_MASK_MTEXPOLY (1 << CD_MTEXPOLY) /* DEPRECATED */ #define CD_MASK_PROP_BYTE_COLOR (1 << CD_PROP_BYTE_COLOR) #define CD_MASK_TANGENT (1 << CD_TANGENT) #define CD_MASK_MDISPS (1 << CD_MDISPS) #define CD_MASK_PREVIEW_MCOL (1 << CD_PREVIEW_MCOL) #define CD_MASK_CLOTH_ORCO (1 << CD_CLOTH_ORCO) -// #define CD_MASK_RECAST (1 << CD_RECAST) /* DEPRECATED */ #define CD_MASK_SHAPE_KEYINDEX (1 << CD_SHAPE_KEYINDEX) #define CD_MASK_SHAPEKEY (1 << CD_SHAPEKEY) @@ -218,6 +219,7 @@ typedef enum eCustomDataType { #define CD_MASK_PROP_FLOAT2 (1ULL << CD_PROP_FLOAT2) #define CD_MASK_PROP_BOOL (1ULL << CD_PROP_BOOL) #define CD_MASK_PROP_INT8 (1ULL << CD_PROP_INT8) +#define CD_MASK_PROP_INT32_2D (1ULL << CD_PROP_INT32_2D) #define CD_MASK_HAIRLENGTH (1ULL << CD_HAIRLENGTH) @@ -231,7 +233,7 @@ typedef enum eCustomDataType { #define CD_MASK_PROP_ALL \ (CD_MASK_PROP_FLOAT | CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_FLOAT3 | CD_MASK_PROP_INT32 | \ CD_MASK_PROP_COLOR | CD_MASK_PROP_STRING | CD_MASK_PROP_BYTE_COLOR | CD_MASK_PROP_BOOL | \ - CD_MASK_PROP_INT8) + CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D) /* All color attributes */ #define CD_MASK_COLOR_ALL (CD_MASK_PROP_COLOR | CD_MASK_PROP_BYTE_COLOR) diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 50323233917..f0dbf6f86d9 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -78,6 +78,9 @@ typedef struct Mesh { /** * Array owned by mesh. May be null of there are no polygons. Index of the first corner of each * polygon, with the total number of corners at the end. See #Mesh::polys() and #OffsetIndices. + * + * This array is shared based on the bke::MeshRuntime::poly_offsets_sharing_info. + * Avoid accessing directly when possible. */ int *poly_offset_indices; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2bdb3f09583..d52e265b65e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1980,6 +1980,7 @@ typedef struct SpreadsheetRowFilter { char _pad0[2]; int value_int; + int value_int2[2]; char *value_string; float value_float; float threshold; @@ -2025,6 +2026,7 @@ typedef enum eSpreadsheetColumnValueType { SPREADSHEET_VALUE_TYPE_STRING = 7, SPREADSHEET_VALUE_TYPE_BYTE_COLOR = 8, SPREADSHEET_VALUE_TYPE_INT8 = 9, + SPREADSHEET_VALUE_TYPE_INT32_2D = 10, } eSpreadsheetColumnValueType; /** diff --git a/source/blender/makesdna/DNA_vec_types.h b/source/blender/makesdna/DNA_vec_types.h index f053efff2b4..f9294ffe314 100644 --- a/source/blender/makesdna/DNA_vec_types.h +++ b/source/blender/makesdna/DNA_vec_types.h @@ -23,12 +23,12 @@ typedef struct vec2f { float x, y; } vec2f; -/* not used at the moment */ -/* typedef struct vec2i { int x, y; } vec2i; +/* not used at the moment */ +/* typedef struct vec2d { double x, y; } vec2d; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 5d5e5cdcbb3..04b3b1389ed 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -36,8 +36,8 @@ set(DEFSRC rna_dynamicpaint.c rna_fcurve.c rna_fluid.c - rna_gpencil.c - rna_gpencil_modifier.c + rna_gpencil_legacy.c + rna_gpencil_legacy_modifier.c rna_image.c rna_key.c rna_lattice.c @@ -431,7 +431,7 @@ set(LIB bf_editor_curve bf_editor_curves bf_editor_gizmo_library - bf_editor_gpencil + bf_editor_gpencil_legacy bf_editor_io bf_editor_mesh bf_editor_object diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index a5ede32ec34..3cf32a878dc 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -4515,7 +4515,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_curve.c", "rna_curve_api.c", RNA_def_curve}, {"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint}, {"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve}, - {"rna_gpencil.c", NULL, RNA_def_gpencil}, + {"rna_gpencil_legacy.c", NULL, RNA_def_gpencil}, {"rna_curves.c", NULL, RNA_def_curves}, {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, @@ -4529,7 +4529,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, {"rna_meta.c", "rna_meta_api.c", RNA_def_meta}, {"rna_modifier.c", NULL, RNA_def_modifier}, - {"rna_gpencil_modifier.c", NULL, RNA_def_greasepencil_modifier}, + {"rna_gpencil_legacy_modifier.c", NULL, RNA_def_greasepencil_modifier}, {"rna_shader_fx.c", NULL, RNA_def_shader_fx}, {"rna_nla.c", NULL, RNA_def_nla}, {"rna_nodetree.c", NULL, RNA_def_nodetree}, diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index 3aedc92a248..b669ac0c888 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -39,6 +39,7 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = { {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"}, + {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"}, {0, NULL, 0, NULL, NULL}, }; @@ -65,7 +66,8 @@ const EnumPropertyItem rna_enum_attribute_type_with_auto_items[] = { {CD_PROP_STRING, "STRING", 0, "String", "Text string"}, {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, - {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"}, + {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, + {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"}, {0, NULL, 0, NULL, NULL}, }; @@ -162,6 +164,8 @@ static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type) return &RNA_Float2Attribute; case CD_PROP_INT8: return &RNA_ByteIntAttribute; + case CD_PROP_INT32_2D: + return &RNA_Int2Attribute; default: return NULL; } @@ -292,6 +296,9 @@ static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRN case CD_PROP_INT8: struct_size = sizeof(int8_t); break; + case CD_PROP_INT32_2D: + struct_size = sizeof(int[2]); + break; default: struct_size = 0; length = 0; @@ -1017,6 +1024,40 @@ static void rna_def_attribute_int8(BlenderRNA *brna) prop, "rna_ByteIntAttributeValue_get", "rna_ByteIntAttributeValue_set", NULL); } +static void rna_def_attribute_int2(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "Int2Attribute", "Attribute"); + RNA_def_struct_sdna(srna, "CustomDataLayer"); + RNA_def_struct_ui_text( + srna, "2D Integer Vector Attribute", "Geometry attribute that stores 2D integer vectors"); + + prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Int2AttributeValue"); + RNA_def_property_collection_funcs(prop, + "rna_Attribute_data_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_Attribute_data_length", + NULL, + NULL, + NULL); + + srna = RNA_def_struct(brna, "Int2AttributeValue", NULL); + RNA_def_struct_sdna(srna, "vec2i"); + RNA_def_struct_ui_text( + srna, "2D Integer Vector Attribute Value", "2D value in geometry attribute"); + + prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Vector", "2D vector"); + RNA_def_property_int_sdna(prop, NULL, "x"); + RNA_def_property_array(prop, 2); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); +} + static void rna_def_attribute_float2(BlenderRNA *brna) { StructRNA *srna; @@ -1095,6 +1136,7 @@ static void rna_def_attribute(BlenderRNA *brna) rna_def_attribute_float_color(brna); rna_def_attribute_byte_color(brna); rna_def_attribute_int(brna); + rna_def_attribute_int2(brna); rna_def_attribute_string(brna); rna_def_attribute_bool(brna); rna_def_attribute_float2(brna); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index d145e7c9f5b..aa96102f74d 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -248,7 +248,7 @@ const EnumPropertyItem rna_enum_brush_gpencil_sculpt_types_items[] = { "CLONE", ICON_GPBRUSH_CLONE, "Clone", - "Paste copies of the strokes stored on the clipboard"}, + "Paste copies of the strokes stored on the internal clipboard"}, {0, NULL, 0, NULL, NULL}}; const EnumPropertyItem rna_enum_brush_gpencil_weight_types_items[] = { @@ -262,16 +262,18 @@ const EnumPropertyItem rna_enum_brush_gpencil_weight_types_items[] = { /* clang-format off */ const EnumPropertyItem rna_enum_brush_curves_sculpt_tool_items[] = { - {CURVES_SCULPT_TOOL_COMB, "COMB", ICON_BRUSH_CURVES_COMB, "Comb Curves", ""}, - {CURVES_SCULPT_TOOL_DELETE, "DELETE", ICON_BRUSH_CURVES_DELETE, "Delete Curves", ""}, - {CURVES_SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_CURVES_SNAKE_HOOK, "Curves Snake Hook", ""}, - {CURVES_SCULPT_TOOL_ADD, "ADD", ICON_BRUSH_CURVES_ADD, "Add Curves", ""}, - {CURVES_SCULPT_TOOL_GROW_SHRINK, "GROW_SHRINK", ICON_BRUSH_CURVES_GROW_SHRINK, "Grow / Shrink Curves", ""}, {CURVES_SCULPT_TOOL_SELECTION_PAINT, "SELECTION_PAINT", ICON_BRUSH_PAINT_SELECT, "Paint Selection", ""}, - {CURVES_SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_CURVES_PINCH, "Pinch Curves", ""}, - {CURVES_SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_CURVES_SMOOTH, "Smooth Curves", ""}, - {CURVES_SCULPT_TOOL_PUFF, "PUFF", ICON_BRUSH_CURVES_PUFF, "Puff Curves", ""}, + RNA_ENUM_ITEM_SEPR, + {CURVES_SCULPT_TOOL_ADD, "ADD", ICON_BRUSH_CURVES_ADD, "Add Curves", ""}, + {CURVES_SCULPT_TOOL_DELETE, "DELETE", ICON_BRUSH_CURVES_DELETE, "Delete Curves", ""}, {CURVES_SCULPT_TOOL_DENSITY, "DENSITY", ICON_BRUSH_CURVES_DENSITY, "Density Curves", ""}, + RNA_ENUM_ITEM_SEPR, + {CURVES_SCULPT_TOOL_COMB, "COMB", ICON_BRUSH_CURVES_COMB, "Comb Curves", ""}, + {CURVES_SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_CURVES_SNAKE_HOOK, "Curves Snake Hook", ""}, + {CURVES_SCULPT_TOOL_GROW_SHRINK, "GROW_SHRINK", ICON_BRUSH_CURVES_GROW_SHRINK, "Grow / Shrink Curves", ""}, + {CURVES_SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_CURVES_PINCH, "Pinch Curves", ""}, + {CURVES_SCULPT_TOOL_PUFF, "PUFF", ICON_BRUSH_CURVES_PUFF, "Puff Curves", ""}, + {CURVES_SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_CURVES_SMOOTH, "Smooth Curves", ""}, {CURVES_SCULPT_TOOL_SLIDE, "SLIDE", ICON_BRUSH_CURVES_SLIDE, "Slide Curves", ""}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/makesrna/intern/rna_curves.c b/source/blender/makesrna/intern/rna_curves.c index b14fe826e62..bed608a5711 100644 --- a/source/blender/makesrna/intern/rna_curves.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -77,6 +77,18 @@ static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter, NULL); } +static int rna_Curves_curve_offset_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + Curves *curves = rna_curves(ptr); + if (index < 0 || index >= curves->geometry.curve_num + 1) { + return false; + } + r_ptr->owner_id = &curves->id; + r_ptr->type = &RNA_IntAttributeValue; + r_ptr->data = &ED_curves_offsets_for_write(curves)[index]; + return true; +} + static float (*get_curves_positions(Curves *curves))[3] { return (float(*)[3])CustomData_get_layer_named_for_write( @@ -97,6 +109,35 @@ static int rna_CurvePoint_index_get_const(const PointerRNA *ptr) return (int)(co - positions); } +static void rna_Curves_curves_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Curves *curves = rna_curves(ptr); + rna_iterator_array_begin(iter, + ED_curves_offsets_for_write(curves), + sizeof(int), + curves->geometry.curve_num, + false, + NULL); +} + +static int rna_Curves_curves_length(PointerRNA *ptr) +{ + const Curves *curves = rna_curves(ptr); + return curves->geometry.curve_num; +} + +static int rna_Curves_curves_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + Curves *curves = rna_curves(ptr); + if (index < 0 || index >= curves->geometry.curve_num) { + return false; + } + r_ptr->owner_id = &curves->id; + r_ptr->type = &RNA_CurveSlice; + r_ptr->data = &ED_curves_offsets_for_write(curves)[index]; + return true; +} + static int rna_Curves_position_data_length(PointerRNA *ptr) { const Curves *curves = rna_curves(ptr); @@ -343,7 +384,15 @@ 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.curve_offsets", "geometry.curve_num"); + RNA_def_property_collection_funcs(prop, + "rna_Curves_curves_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_Curves_curves_length", + "rna_Curves_curves_lookup_int", + NULL, + NULL); RNA_def_property_struct_type(prop, "CurveSlice"); RNA_def_property_ui_text(prop, "Curves", "All curves in the data-block"); @@ -376,7 +425,6 @@ static void rna_def_curves(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curves_update_data"); prop = RNA_def_property(srna, "curve_offset_data", PROP_COLLECTION, PROP_NONE); - 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", @@ -384,7 +432,7 @@ static void rna_def_curves(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Curves_curve_offset_data_length", - NULL, + "rna_Curves_curve_offset_data_lookup_int", NULL, NULL); RNA_def_property_update(prop, 0, "rna_Curves_update_data"); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil_legacy.c similarity index 100% rename from source/blender/makesrna/intern/rna_gpencil.c rename to source/blender/makesrna/intern/rna_gpencil_legacy.c diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c similarity index 100% rename from source/blender/makesrna/intern/rna_gpencil_modifier.c rename to source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index e0128595b7f..dbb2b7e7071 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -332,8 +332,8 @@ void RNA_def_main(BlenderRNA *brna) {"grease_pencils", "GreasePencil", "rna_Main_gpencils_begin", - "Grease Pencil", - "Grease Pencil data-blocks", + "Grease Pencil (legacy)", + "Grease Pencil (legacy) data-blocks", RNA_def_main_gpencil}, {"movieclips", "MovieClip", diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 2b0c2a269dd..4221893e4c3 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -77,7 +77,7 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = { # include "DEG_depsgraph.h" # include "DEG_depsgraph_build.h" -# include "ED_gpencil.h" +# include "ED_gpencil_legacy.h" # include "ED_image.h" # include "ED_node.h" # include "ED_screen.h" diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 4f9cecc307e..ac264687cb4 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1013,21 +1013,33 @@ static int rna_enum_check_separator(CollectionPropertyIterator *UNUSED(iter), vo return (item->identifier[0] == 0); } -static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_EnumProperty_items_begin_impl(CollectionPropertyIterator *iter, + PointerRNA *ptr, + IteratorSkipFunc skip_fn) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - /* EnumPropertyRNA *eprop; */ /* UNUSED */ + // EnumPropertyRNA *eprop; /* UNUSED */ const EnumPropertyItem *item = NULL; int totitem; bool free; prop = rna_ensure_property(prop); - /* eprop = (EnumPropertyRNA *)prop; */ + // eprop = (EnumPropertyRNA *)prop; RNA_property_enum_items_ex( NULL, ptr, prop, STREQ(iter->prop->identifier, "enum_items_static"), &item, &totitem, &free); - rna_iterator_array_begin( - iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator); + rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, skip_fn); +} + +static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + rna_EnumProperty_items_begin_impl(iter, ptr, rna_enum_check_separator); +} + +static void rna_EnumProperty_items_ui_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + /* No skip-funciton, include all "UI" items. */ + rna_EnumProperty_items_begin_impl(iter, ptr, NULL); } static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value) @@ -3360,6 +3372,26 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) "Static Items", "Possible values for the property (never calls optional dynamic generation of those)"); + /* Expose a UI version of `enum_items_static` to allow separator & title access, + * needed for the tool-system to access separators from brush enums. */ + prop = RNA_def_property(srna, "enum_items_static_ui", PROP_COLLECTION, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "EnumPropertyItem"); + RNA_def_property_collection_funcs(prop, + "rna_EnumProperty_items_ui_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + NULL, + NULL, + NULL, + NULL); + RNA_def_property_ui_text( + prop, + "Static Items with UI Elements", + "Possible values for the property (never calls optional dynamic generation of those). " + "Includes UI elements (separators and section headings)"); + srna = RNA_def_struct(brna, "EnumPropertyItem", NULL); RNA_def_struct_ui_text( srna, "Enum Item Definition", "Definition of a choice in an RNA enum property"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index fe8ec52f1ef..04d2d2e8c84 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -34,7 +34,7 @@ #include "BKE_paint.h" #include "BKE_volume.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_object.h" #include "ED_uvedit.h" diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index a468d2c5272..5b5b4dcfc25 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -116,7 +116,7 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = { # include "DEG_depsgraph.h" -# include "ED_gpencil.h" +# include "ED_gpencil_legacy.h" # include "ED_paint.h" # include "ED_particle.h" diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b4c1058969c..a475ccf55ba 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -8004,6 +8004,11 @@ static void rna_def_spreadsheet_row_filter(BlenderRNA *brna) RNA_def_property_ui_text(prop, "8-Bit Integer Value", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + prop = RNA_def_property(srna, "value_int2", PROP_INT, PROP_NONE); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "2D Vector Value", ""); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SPREADSHEET, NULL); + prop = RNA_def_property(srna, "value_boolean", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SPREADSHEET_ROW_FILTER_BOOL_VALUE); RNA_def_property_ui_text(prop, "Boolean Value", ""); diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 16384125f58..8a28908afa4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -94,25 +94,46 @@ static void expand_mesh(Mesh &mesh, const int poly_expand, const int loop_expand) { + /* Remove types that aren't supported for interpolation in this node. */ if (vert_expand != 0) { + CustomData_free_layers(&mesh.vdata, CD_ORCO, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_BWEIGHT, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_SHAPEKEY, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_CLOTH_ORCO, mesh.totvert); + CustomData_free_layers(&mesh.vdata, CD_MVERT_SKIN, mesh.totvert); const int old_verts_num = mesh.totvert; mesh.totvert += vert_expand; CustomData_realloc(&mesh.vdata, old_verts_num, mesh.totvert); } if (edge_expand != 0) { + CustomData_free_layers(&mesh.edata, CD_BWEIGHT, mesh.totedge); + CustomData_free_layers(&mesh.edata, CD_FREESTYLE_EDGE, mesh.totedge); const int old_edges_num = mesh.totedge; mesh.totedge += edge_expand; CustomData_realloc(&mesh.edata, old_edges_num, mesh.totedge); } if (poly_expand != 0) { + CustomData_free_layers(&mesh.pdata, CD_FACEMAP, mesh.totpoly); + CustomData_free_layers(&mesh.pdata, CD_FREESTYLE_FACE, mesh.totpoly); const int old_polys_num = mesh.totpoly; mesh.totpoly += poly_expand; CustomData_realloc(&mesh.pdata, old_polys_num, mesh.totpoly); - mesh.poly_offset_indices = static_cast( - MEM_reallocN(mesh.poly_offset_indices, sizeof(int) * (mesh.totpoly + 1))); - mesh.poly_offsets_for_write().last() = mesh.totloop + loop_expand; + implicit_sharing::resize_trivial_array(&mesh.poly_offset_indices, + &mesh.runtime->poly_offsets_sharing_info, + old_polys_num == 0 ? 0 : (old_polys_num + 1), + mesh.totpoly + 1); + /* Set common values for convenience. */ + mesh.poly_offset_indices[0] = 0; + mesh.poly_offset_indices[mesh.totpoly] = mesh.totloop + loop_expand; } if (loop_expand != 0) { + CustomData_free_layers(&mesh.ldata, CD_NORMAL, mesh.totloop); + CustomData_free_layers(&mesh.ldata, CD_MDISPS, mesh.totloop); + CustomData_free_layers(&mesh.ldata, CD_TANGENT, mesh.totloop); + CustomData_free_layers(&mesh.ldata, CD_PAINT_MASK, mesh.totloop); + CustomData_free_layers(&mesh.ldata, CD_MLOOPTANGENT, mesh.totloop); + CustomData_free_layers(&mesh.ldata, CD_GRID_PAINT_MASK, mesh.totloop); + CustomData_free_layers(&mesh.ldata, CD_CUSTOMLOOPNORMAL, mesh.totloop); const int old_loops_num = mesh.totloop; mesh.totloop += loop_expand; CustomData_realloc(&mesh.ldata, old_loops_num, mesh.totloop); diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c index 766c74c0bbc..df3c687307b 100644 --- a/source/blender/python/intern/bpy_rna_id_collection.c +++ b/source/blender/python/intern/bpy_rna_id_collection.c @@ -85,7 +85,7 @@ static int foreach_libblock_id_user_map_callback(LibraryIDLinkCallbackData *cb_d return IDWALK_RET_NOP; } - if (cb_flag & IDWALK_CB_EMBEDDED) { + if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING)) { /* We skip private pointers themselves, like root node trees, we'll 'link' their own ID * pointers to their 'ID owner' instead. */ return IDWALK_RET_NOP; diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index 57b07579291..852a9f1a7ce 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -95,7 +95,7 @@ #include "ED_anim_api.h" #include "ED_armature.h" #include "ED_asset.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_keyframes_edit.h" #include "ED_keyframing.h" #include "ED_node.h" diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 38cbd7d782d..548ee1440c9 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -73,7 +73,7 @@ #include "IMB_imbuf_types.h" #include "ED_fileselect.h" -#include "ED_gpencil.h" +#include "ED_gpencil_legacy.h" #include "ED_numinput.h" #include "ED_screen.h" #include "ED_undo.h" @@ -3462,7 +3462,7 @@ static int previews_id_ensure_callback(LibraryIDLinkCallbackData *cb_data) { const int cb_flag = cb_data->cb_flag; - if (cb_flag & IDWALK_CB_EMBEDDED) { + if (cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING)) { return IDWALK_RET_NOP; } diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py index 0199132b0b9..4ee77745a90 100644 --- a/tests/python/bl_blendfile_liblink.py +++ b/tests/python/bl_blendfile_liblink.py @@ -220,7 +220,7 @@ class TestBlendLibLinkIndirect(TestBlendLibLinkHelper): assert mesh.use_fake_user is False assert mesh.users == 0 # IDs explicitely linked by the user are forcefully considered directly linked. - assert mesh.is_library_indirect == False + assert mesh.is_library_indirect is False ob = bpy.data.objects.new("LocalMesh", mesh) coll = bpy.data.collections.new("LocalMesh") @@ -230,19 +230,19 @@ class TestBlendLibLinkIndirect(TestBlendLibLinkHelper): assert material.users == 2 assert material.is_library_indirect assert mesh.users == 1 - assert mesh.is_library_indirect == False + assert mesh.is_library_indirect is False ob.material_slots[0].link = 'OBJECT' ob.material_slots[0].material = material assert material.users == 3 - assert material.is_library_indirect == False + assert material.is_library_indirect is False ob.material_slots[0].material = None assert material.users == 2 # This is not properly updated whene removing a local user of linked data. - assert material.is_library_indirect == False + assert material.is_library_indirect is False output_work_path = os.path.join(output_dir, self.unique_blendfile_name("blendfile")) bpy.ops.wm.save_as_mainfile(filepath=output_work_path, check_existing=False, compress=False) @@ -270,7 +270,7 @@ class TestBlendLibLinkIndirect(TestBlendLibLinkHelper): assert mesh.library is not None assert mesh.use_fake_user is False assert mesh.users == 1 - assert mesh.is_library_indirect == False + assert mesh.is_library_indirect is False class TestBlendLibAppendBasic(TestBlendLibLinkHelper): @@ -598,7 +598,7 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): # Only explicitely linked data gets a liboverride, without any handling of hierarchy/dependencies. assert bpy.data.collections[0].library is None - assert bpy.data.collections[0].is_runtime_data == False + assert bpy.data.collections[0].is_runtime_data is False assert bpy.data.collections[0].override_library is not None assert bpy.data.collections[0].override_library.reference == bpy.data.collections[-1] @@ -616,7 +616,7 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): # Only explicitely linked data gets a liboverride, without any handling of hierarchy/dependencies. assert bpy.data.collections[1].library is None - assert bpy.data.collections[1].is_runtime_data == False + assert bpy.data.collections[1].is_runtime_data is False assert bpy.data.collections[1].override_library is not None assert bpy.data.collections[1].override_library.reference == bpy.data.collections[-1] @@ -634,7 +634,7 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): # Only explicitely linked data gets a liboverride, without any handling of hierarchy/dependencies. assert bpy.data.collections[1].library is None - assert bpy.data.collections[1].is_runtime_data == False + assert bpy.data.collections[1].is_runtime_data is False assert bpy.data.collections[1].override_library is not None assert bpy.data.collections[1].override_library.reference == bpy.data.collections[-1] @@ -699,7 +699,7 @@ class TestBlendLibDataLibrariesLoadLibOverride(TestBlendLibDataLibrariesLoad): # Only explicitely linked data gets a liboverride, without any handling of hierarchy/dependencies. assert bpy.data.collections[1].library is None - assert bpy.data.collections[1].is_runtime_data == False + assert bpy.data.collections[1].is_runtime_data is False assert bpy.data.collections[1].override_library is not None assert bpy.data.collections[1].override_library.reference == bpy.data.collections[-1] diff --git a/tools/utils/gitea_inactive_developers.py b/tools/utils/gitea_inactive_developers.py new file mode 100755 index 00000000000..a90cd7ececc --- /dev/null +++ b/tools/utils/gitea_inactive_developers.py @@ -0,0 +1,248 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Script to get all the inactive gitea developers +# Usage: GITEA_API_TOKEN= python3 gitea_inactive_developers.py +# +# The API Token have the "read:org" or "admin:org" scope. +# +# Potential errors: +# * 403 Client Error: That means the token doesn't have the right scope. +# * 500 Server Error: The token is invalid. + +import csv +import logging +import os +import requests +import sys +import yarl +from retry import retry as retry_decorator +import datetime +import dataclasses as dc +import iso8601 + +from typing import ( + cast, + Callable, + Dict, + Iterable, + List, + NewType, + Optional, + Tuple, + Type, + TypeVar, +) + +logger = logging.getLogger(__file__) + + +@dc.dataclass +class TeamMember(): + id: int + login: str + full_name: str + last_login: datetime.datetime + + def __str__(self): + return "{id};{login};{full_name};{last_login};{url}\n".format( + id=self.id, + login=self.login, + full_name=self.full_name, + last_login=self.last_login, + url=gitea_domain + self.login, + ) + + +Page = NewType('Page', int) + +F = TypeVar('F', bound=Callable[..., object]) +T = TypeVar('T', bound=object) + +retry: Callable[[F], F] = retry_decorator( + tries=10, delay=1, backoff=2, logger=logger) + + +def assert_cast(typ: Type[T], obj: object) -> T: + assert isinstance(obj, typ), f'object is not of type {typ}: {obj}' + return cast(T, obj) + + +def get_date_object(date_string: str) -> datetime.datetime: + return iso8601.parse_date(date_string) + + +results_per_page = 25 + + +def get_next_page(headers: Dict, page: int) -> int: + """ + Parse the header looking for reference to next. + """ + total_count = int(assert_cast(str, headers.get('X-Total-Count'))) + next_page = page + 1 if page else 1 + + if next_page * results_per_page > total_count: + return None + + return next_page + + +@retry +def fetch_single( + api_url: yarl.URL, + api_token: str, + method: str, + data: Dict[str, str], + page: Optional[Page] = None, +) -> Tuple[List[object], Optional[Page]]: + """Generic function to query a single item from the API. + + Returns: + A dictionary containing the item data. + """ + headers = { + 'accept': 'application/json', + 'Authorization': 'token ' + api_token, + } + + params = { + 'limit': results_per_page, + **data, + } + + if page is not None: + params['page'] = page + + logger.info(f"Calling {method} ({params=}).") + response = requests.get(str(api_url / method), params=params, headers=headers) + response.raise_for_status() + response_json = response.json() + + next_page = get_next_page(response.headers, page) + return response_json, None if next_page is None else Page(next_page) + + +def fetch_all( + api_url: yarl.URL, + api_token: str, + method: str, + data: Dict[str, str], +) -> Iterable[object]: + """Generic function to query lists from API. + + Yields: + response_data - the result of fetch_single() + """ + response_data, page = fetch_single(api_url, api_token, method, data) + yield from response_data if response_data is not None else () + while page is not None: + response_data, page = fetch_single( + api_url, api_token, method, data, page=page) + yield from response_data + + +def fetch_team_members( + api_url: yarl.URL, + api_token: str, + organization_name: str, + team_name: str, +) -> List[TeamMember]: + """Query API for all the members of a team. + + Yields: + TeamMember objects. + """ + + method = "orgs/{org}/teams".format(org=organization_name) + team_id = None + + for team in cast( + Iterable[Dict[object, object]], + fetch_all( + api_url, + api_token, + method, + data={}, + ), + ): + if team.get('name') != team_name: + continue + + team_id = team.get('id') + break + + if team_id is None: + logger.error('No team found with name: ' + team_name) + sys.exit(2) + + method = "teams/{id}/members".format(id=team_id) + users = list() + + for member in cast( + Iterable[Dict[object, object]], + fetch_all( + api_url, + api_token, + method, + data={}, + ), + ): + users.append( + TeamMember( + id=assert_cast(int, member.get('id')), + login=assert_cast(str, member.get('login')), + full_name=assert_cast(str, member.get('full_name')), + last_login=get_date_object( + assert_cast(str, member.get('last_login'))), + )) + + return users + + +def is_inactive(member: TeamMember) -> bool: + """ + Returns whether the member is no longer active. + + Users are active when they logged in the past 2 years. + """ + tzinfo = member.last_login.tzinfo + two_years_ago = datetime.datetime.now(tzinfo) - datetime.timedelta(days=2 * 365) + return member.last_login < two_years_ago + + +teams = ( + "Developers", + "Add-ons", + "Translation", + "Documentation", + "Technical-Artists", + "Contributors", +) + + +api_token = os.environ['GITEA_API_TOKEN'] +gitea_domain = "https://projects.blender.org/" +api_url = yarl.URL(gitea_domain + 'api/v1/') +organization_name = "blender" + + +def main(): + for team_name in teams: + logger.warning(team_name) + members = fetch_team_members( + api_url, api_token, organization_name, team_name) + + inactive_members = [str(m) for m in members if is_inactive(m)] + + logger.warning(" Total members:" + str(len(members))) + logger.warning(" Inactive members: " + str(len(inactive_members))) + + file_name = team_name.lower() + ".csv" + with open(file_name, 'w', newline='') as csv_file: + csv_file.write("id;login;full_name;last_login;url\n") + csv_file.writelines(inactive_members) + logger.warning(" Output file: " + file_name) + + +if __name__ == "__main__": + main()