From b3bb51dd83a3a17f6fada77f6bed26758070f7ad Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 7 Feb 2022 12:18:15 +0100 Subject: Fix asset-view template ignoring "Asset Indexing" debug option If the "Asset Indexing" option was disabled in Preferences > Experimental > Debugging, the asset-view template (used by pose libraries for example) would still use the indexing. --- source/blender/editors/asset/intern/asset_list.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc index c075ae390d9..fa0946ffe3d 100644 --- a/source/blender/editors/asset/intern/asset_list.cc +++ b/source/blender/editors/asset/intern/asset_list.cc @@ -41,6 +41,7 @@ #include "WM_api.h" /* XXX uses private header of file-space. */ +#include "../space_file/file_indexer.h" #include "../space_file/filelist.h" #include "ED_asset_handle.h" @@ -170,7 +171,8 @@ void AssetList::setup() "", ""); - filelist_setindexer(files, &file_indexer_asset); + const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing); + filelist_setindexer(files, use_asset_indexer ? &file_indexer_asset : &file_indexer_noop); char path[FILE_MAXDIR] = ""; if (user_library) { -- cgit v1.2.3 From a5dd1bc53d4bf7994745124f58de674068d1d598 Mon Sep 17 00:00:00 2001 From: Shrey Aggarwal Date: Mon, 7 Feb 2022 08:20:12 -0700 Subject: Fix T90868: Console window flash when exiting If the console was hidden on windows, it would be made visible during shutdown in an effort not hide a potentially active interactive console session. This however did not take in account if blender was actually launched from an interactive console causing the console window to briefly flash during shutdown even when launched from the new launcher, the brief flash concerned some users. This change adjusts the behaviour to restore the console only when blender was started from the console. Reviewed By: LazyDodo Differential Revision: https://developer.blender.org/D14016 --- intern/ghost/intern/GHOST_SystemWin32.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 64e1ac3b9b3..923453d6c6f 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -105,6 +105,8 @@ */ #define BROKEN_PEEK_TOUCHPAD +static bool isStartedFromCommandPrompt(); + static void initRawInput() { #ifdef WITH_INPUT_NDOF @@ -166,7 +168,10 @@ GHOST_SystemWin32::~GHOST_SystemWin32() { // Shutdown COM OleUninitialize(); - toggleConsole(1); + + if (isStartedFromCommandPrompt()) { + toggleConsole(1); + } } uint64_t GHOST_SystemWin32::performanceCounterToMillis(__int64 perf_ticks) const -- cgit v1.2.3 From a7b598203034c04f5fce3088d6b07799d74f832c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 7 Feb 2022 16:22:38 +0100 Subject: Fix missing removal of proxy references in py scripts. Reported by studio (Hjalti), thanks. --- release/scripts/modules/rna_manual_reference.py | 1 - release/scripts/startup/bl_ui/properties_data_armature.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/release/scripts/modules/rna_manual_reference.py b/release/scripts/modules/rna_manual_reference.py index 232046ebd60..f0da4bac974 100644 --- a/release/scripts/modules/rna_manual_reference.py +++ b/release/scripts/modules/rna_manual_reference.py @@ -2139,7 +2139,6 @@ url_manual_mapping = ( ("bpy.ops.object.origin_set*", "scene_layout/object/origin.html#bpy-ops-object-origin-set"), ("bpy.ops.object.parent_set*", "scene_layout/object/editing/parent.html#bpy-ops-object-parent-set"), ("bpy.ops.object.pointcloud*", "modeling/point_cloud.html#bpy-ops-object-pointcloud"), - ("bpy.ops.object.proxy_make*", "files/linked_libraries/library_proxies.html#bpy-ops-object-proxy-make"), ("bpy.ops.object.select_all*", "scene_layout/object/selecting.html#bpy-ops-object-select-all"), ("bpy.ops.object.shade_flat*", "scene_layout/object/editing/shading.html#bpy-ops-object-shade-flat"), ("bpy.ops.pose.group_assign*", "animation/armatures/properties/bone_groups.html#bpy-ops-pose-group-assign"), diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 22f3d1a9c50..2a6bd53bff5 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -149,7 +149,7 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN' split = layout.split() - split.active = (ob.proxy is None) + split.active = True col = split.column() col.prop(group, "color_set") -- cgit v1.2.3 From fe4e85a9240ff95909be33c7e72e0ab969d5a4ca Mon Sep 17 00:00:00 2001 From: Charlie Jolly Date: Mon, 7 Feb 2022 15:29:16 +0000 Subject: Nodes: Dynamic node class for Map Range node This patch makes it possible to set the UI color of a node's header bar and override the default from the node's typeinfo. Currently the color is taken from the `.nclass` member of the node's bNodeType->TypeInfo struct. This is created once when registering the node. The TypeInfo is used for both UI and non-UI functionality. Since the TypeInfo is shared, the header bar for the node can't be changed without changing all nodes of that type. The Map Range node is shown as a `Converter` or blue color by default. This patch allows this to be changed dynamically to `Vector` or purple. This is done by adding a `ui_class` callback to node typeinfo struct. Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D13936 --- source/blender/blenkernel/BKE_node.h | 3 +++ source/blender/editors/space_node/node_draw.cc | 4 +++- source/blender/nodes/shader/nodes/node_shader_map_range.cc | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index d583b5f0648..7ffa180b523 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -274,6 +274,9 @@ typedef struct bNodeType { char *label, int maxlen); + /** Optional override for node class, used for drawing node header. */ + int (*ui_class)(const struct bNode *node); + /** Called when the node is updated in the editor. */ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node); /** Check and update if internal ID data has changed. */ diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 834bb3e5802..81c63e9bddb 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -626,7 +626,9 @@ static void node_update_hidden(bNode &node, uiBlock &block) static int node_get_colorid(const bNode &node) { - switch (node.typeinfo->nclass) { + const int nclass = (node.typeinfo->ui_class == nullptr) ? node.typeinfo->nclass : + node.typeinfo->ui_class(&node); + switch (nclass) { case NODE_CLASS_INPUT: return TH_NODE_INPUT; case NODE_CLASS_OUTPUT: diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index bc7ca661a77..254ab9f866d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -66,6 +66,16 @@ static void node_shader_buts_map_range(uiLayout *layout, bContext *UNUSED(C), Po } } +static int node_shader_map_range_ui_class(const bNode *node) +{ + const NodeMapRange &storage = node_storage(*node); + const CustomDataType data_type = static_cast(storage.data_type); + if (data_type == CD_PROP_FLOAT3) { + return NODE_CLASS_OP_VECTOR; + } + return NODE_CLASS_CONVERTER; +} + static void node_shader_update_map_range(bNodeTree *ntree, bNode *node) { const NodeMapRange &storage = node_storage(*node); @@ -665,6 +675,7 @@ void register_node_type_sh_map_range() sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_map_range_declare; ntype.draw_buttons = file_ns::node_shader_buts_map_range; + ntype.ui_class = file_ns::node_shader_map_range_ui_class; node_type_init(&ntype, file_ns::node_shader_init_map_range); node_type_storage( &ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage); -- cgit v1.2.3 From 2f868e5647009434c4a1b9afddc48f6180a2bb60 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 7 Feb 2022 17:56:25 +0100 Subject: Fix T95578: missing update when linking selected nodes This removes a "narrow" update in `snode_autoconnect` in favor of the more general update in `node_make_link_exec`. --- source/blender/editors/space_node/node_relationships.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index fd9420b173d..bc79925b51d 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -365,10 +365,7 @@ void sort_multi_input_socket_links(SpaceNode &snode, } } -static void snode_autoconnect(Main &bmain, - SpaceNode &snode, - const bool allow_multiple, - const bool replace) +static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const bool replace) { bNodeTree *ntree = snode.edittree; Vector sorted_nodes; @@ -441,10 +438,6 @@ static void snode_autoconnect(Main &bmain, } } } - - if (numlinks > 0) { - BKE_ntree_update_main_tree(&bmain, ntree, nullptr); - } } /** \} */ @@ -1304,13 +1297,13 @@ static int node_make_link_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), &bmain); - snode_autoconnect(bmain, snode, true, replace); + snode_autoconnect(snode, true, replace); /* deselect sockets after linking */ node_deselect_all_input_sockets(snode, false); node_deselect_all_output_sockets(snode, false); - ED_node_tree_propagate_change(C, CTX_data_main(C), snode.edittree); + ED_node_tree_propagate_change(C, &bmain, snode.edittree); return OPERATOR_FINISHED; } -- cgit v1.2.3 From eb071e3d3cae0033582a269b5fbdd859d5532ce4 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 7 Feb 2022 18:16:35 +0100 Subject: Fix: missing null check This fixes https://github.com/JacquesLucke/animation_nodes/issues/1827. --- source/blender/editors/space_node/node_edit.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 6275e7e4656..a513f5df7a0 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -394,7 +394,7 @@ static void send_notifiers_after_tree_change(ID *id, bNodeTree *ntree) { WM_main_add_notifier(NC_NODE | NA_EDITED, nullptr); - if (ntree->type == NTREE_SHADER) { + if (ntree->type == NTREE_SHADER && id != nullptr) { if (GS(id->name) == ID_MA) { WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); } -- cgit v1.2.3 From 65d287a14a4081fc30535a2c17f0e64819401564 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 7 Feb 2022 18:44:30 +0100 Subject: Fix T95543: incorrect handling of implicit field inputs in ui --- source/blender/blenkernel/intern/node_tree_update.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 0555707b64c..904a0de9a90 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -273,6 +273,12 @@ static OutputFieldDependency find_group_output_dependencies( while (!sockets_to_check.is_empty()) { const InputSocketRef *input_socket = sockets_to_check.pop(); + if (!input_socket->is_directly_linked() && + !field_state_by_socket_id[input_socket->id()].is_single) { + /* This socket uses a field as input by default. */ + return OutputFieldDependency::ForFieldSource(); + } + for (const OutputSocketRef *origin_socket : input_socket->directly_linked_sockets()) { const NodeRef &origin_node = origin_socket->node(); const SocketFieldState &origin_state = field_state_by_socket_id[origin_socket->id()]; -- cgit v1.2.3 From fe1816f67fbc6aaf383ec77847d668367335d093 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 7 Feb 2022 11:55:54 -0600 Subject: Curves: Rename "Hair" types, variables, and functions to "Curves" Based on discussions from T95355 and T94193, the plan is to use the name "Curves" to describe the data-block container for multiple curves. Eventually this will replace the existing "Curve" data-block. However, it will be a while before the curve data-block can be replaced so in order to distinguish the two curve types in the UI, "Hair Curves" will be used, but eventually changed back to "Curves". This patch renames "hair-related" files, functions, types, and variable names to this convention. A deep rename is preferred to keep code consistent and to avoid any "hair" terminology from leaking, since the new data-block is meant for all curve types, not just hair use cases. The downside of this naming is that the difference between "Curve" and "Curves" has become important. That was considered during design discussons and deemed acceptable, especially given the non-permanent nature of the somewhat common conflict. Some points of interest: - All DNA compatibility is lost, just like rBf59767ff9729. - I renamed `ID_HA` to `ID_CV` so there is no complete mismatch. - `hair_curves` is used where necessary to distinguish from the existing "curves" plural. - I didn't rename any of the cycles/rendering code function names, since that is also used by the old hair particle system. Differential Revision: https://developer.blender.org/D14007 --- intern/cycles/blender/curves.cpp | 58 +-- intern/cycles/blender/geometry.cpp | 8 +- intern/cycles/blender/object.cpp | 4 +- release/scripts/startup/bl_ui/__init__.py | 2 +- .../startup/bl_ui/properties_data_curves.py | 142 ++++++ .../scripts/startup/bl_ui/properties_data_hair.py | 142 ------ release/scripts/startup/bl_ui/space_dopesheet.py | 4 +- release/scripts/startup/bl_ui/space_outliner.py | 2 +- release/scripts/startup/bl_ui/space_userpref.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 4 +- source/blender/CMakeLists.txt | 2 +- source/blender/blenkernel/BKE_attribute.h | 4 +- source/blender/blenkernel/BKE_curves.h | 68 +++ source/blender/blenkernel/BKE_hair.h | 63 --- source/blender/blenkernel/BKE_idtype.h | 2 +- source/blender/blenkernel/BKE_main.h | 6 +- source/blender/blenkernel/CMakeLists.txt | 4 +- source/blender/blenkernel/intern/anim_data.c | 8 +- source/blender/blenkernel/intern/anim_sys.c | 4 +- source/blender/blenkernel/intern/attribute.c | 24 +- source/blender/blenkernel/intern/curves.cc | 473 ++++++++++++++++++++ source/blender/blenkernel/intern/customdata.cc | 1 - source/blender/blenkernel/intern/hair.cc | 474 --------------------- source/blender/blenkernel/intern/idtype.c | 10 +- source/blender/blenkernel/intern/lib_query.c | 2 +- source/blender/blenkernel/intern/lib_remap.c | 2 +- source/blender/blenkernel/intern/main.c | 6 +- source/blender/blenkernel/intern/material.c | 26 +- source/blender/blenkernel/intern/object.cc | 30 +- source/blender/blenkernel/intern/object_update.c | 10 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/versioning_290.c | 12 +- source/blender/blentranslation/BLT_translation.h | 4 +- .../depsgraph/intern/builder/deg_builder_nodes.cc | 6 +- .../intern/builder/deg_builder_relations.cc | 8 +- source/blender/depsgraph/intern/depsgraph_tag.cc | 6 +- .../intern/eval/deg_eval_runtime_backup_object.cc | 2 +- source/blender/draw/CMakeLists.txt | 2 +- .../blender/draw/engines/eevee/eevee_cryptomatte.c | 28 +- source/blender/draw/engines/eevee/eevee_data.c | 2 +- source/blender/draw/engines/eevee/eevee_engine.c | 2 +- .../blender/draw/engines/eevee/eevee_materials.c | 4 +- source/blender/draw/engines/eevee/eevee_private.h | 6 +- source/blender/draw/engines/eevee/eevee_render.c | 4 +- .../blender/draw/engines/overlay/overlay_engine.c | 4 +- .../blender/draw/engines/overlay/overlay_extra.c | 2 +- .../draw/engines/workbench/workbench_engine.c | 6 +- source/blender/draw/intern/draw_cache.c | 22 +- source/blender/draw/intern/draw_cache.h | 16 +- source/blender/draw/intern/draw_cache_impl.h | 10 +- .../blender/draw/intern/draw_cache_impl_curves.cc | 389 +++++++++++++++++ source/blender/draw/intern/draw_cache_impl_hair.cc | 388 ----------------- source/blender/draw/intern/draw_common.c | 2 +- source/blender/draw/intern/draw_manager.c | 6 +- .../editors/animation/anim_channels_defines.c | 38 +- source/blender/editors/animation/anim_filter.c | 14 +- source/blender/editors/include/ED_anim_api.h | 2 +- source/blender/editors/include/UI_icons.h | 8 +- source/blender/editors/interface/interface_icons.c | 4 +- .../editors/interface/interface_templates.c | 6 +- source/blender/editors/object/CMakeLists.txt | 2 +- source/blender/editors/object/object_add.c | 24 +- source/blender/editors/object/object_intern.h | 2 +- source/blender/editors/object/object_modifier.c | 6 +- source/blender/editors/object/object_ops.c | 2 +- source/blender/editors/object/object_relations.c | 4 +- source/blender/editors/render/render_opengl.cc | 2 +- .../blender/editors/space_buttons/CMakeLists.txt | 2 +- .../editors/space_buttons/buttons_context.c | 16 +- source/blender/editors/space_info/info_stats.cc | 2 +- .../editors/space_outliner/outliner_draw.cc | 8 +- .../editors/space_outliner/outliner_intern.hh | 2 +- .../editors/space_outliner/outliner_select.cc | 2 +- .../editors/space_outliner/outliner_tools.cc | 12 +- .../editors/space_outliner/outliner_tree.cc | 10 +- .../editors/space_outliner/tree/tree_element_id.cc | 2 +- .../blender/editors/space_view3d/view3d_buttons.c | 2 +- source/blender/makesdna/DNA_ID.h | 6 +- source/blender/makesdna/DNA_ID_enums.h | 2 +- source/blender/makesdna/DNA_curves_defaults.h | 37 ++ source/blender/makesdna/DNA_curves_types.h | 108 +++++ source/blender/makesdna/DNA_hair_defaults.h | 37 -- source/blender/makesdna/DNA_hair_types.h | 108 ----- source/blender/makesdna/DNA_object_types.h | 16 +- source/blender/makesdna/DNA_userdef_types.h | 4 +- source/blender/makesdna/intern/CMakeLists.txt | 2 +- source/blender/makesdna/intern/dna_defaults.c | 12 +- source/blender/makesdna/intern/makesdna.c | 4 +- source/blender/makesrna/RNA_access.h | 2 +- source/blender/makesrna/intern/CMakeLists.txt | 4 +- source/blender/makesrna/intern/makesrna.c | 4 +- source/blender/makesrna/intern/rna_ID.c | 16 +- source/blender/makesrna/intern/rna_action.c | 4 +- source/blender/makesrna/intern/rna_attribute.c | 4 +- source/blender/makesrna/intern/rna_curves.c | 296 +++++++++++++ source/blender/makesrna/intern/rna_hair.c | 296 ------------- source/blender/makesrna/intern/rna_internal.h | 6 +- source/blender/makesrna/intern/rna_main.c | 17 +- source/blender/makesrna/intern/rna_main_api.c | 48 +-- source/blender/makesrna/intern/rna_material.c | 2 +- source/blender/makesrna/intern/rna_object.c | 8 +- source/blender/makesrna/intern/rna_space.c | 4 +- source/blender/makesrna/intern/rna_userdef.c | 8 +- source/blender/modifiers/CMakeLists.txt | 2 +- 104 files changed, 1885 insertions(+), 1864 deletions(-) create mode 100644 release/scripts/startup/bl_ui/properties_data_curves.py delete mode 100644 release/scripts/startup/bl_ui/properties_data_hair.py create mode 100644 source/blender/blenkernel/BKE_curves.h delete mode 100644 source/blender/blenkernel/BKE_hair.h create mode 100644 source/blender/blenkernel/intern/curves.cc delete mode 100644 source/blender/blenkernel/intern/hair.cc create mode 100644 source/blender/draw/intern/draw_cache_impl_curves.cc delete mode 100644 source/blender/draw/intern/draw_cache_impl_hair.cc create mode 100644 source/blender/makesdna/DNA_curves_defaults.h create mode 100644 source/blender/makesdna/DNA_curves_types.h delete mode 100644 source/blender/makesdna/DNA_hair_defaults.h delete mode 100644 source/blender/makesdna/DNA_hair_types.h create mode 100644 source/blender/makesrna/intern/rna_curves.c delete mode 100644 source/blender/makesrna/intern/rna_hair.c diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index 4206a1d8a8b..102ddf5ee32 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -626,11 +626,11 @@ void BlenderSync::sync_particle_hair( } } -#ifdef WITH_HAIR_NODES +#ifdef WITH_NEW_CURVES_TYPE -static std::optional find_curves_radius_attribute(BL::Hair b_hair) +static std::optional find_curves_radius_attribute(BL::Curves b_curves) { - for (BL::Attribute &b_attribute : b_hair.attributes) { + for (BL::Attribute &b_attribute : b_curves.attributes) { if (b_attribute.name() != "radius") { continue; } @@ -645,16 +645,16 @@ static std::optional find_curves_radius_attribute(BL::Hair b return std::nullopt; } -static float4 hair_point_as_float4(BL::Hair b_hair, +static float4 hair_point_as_float4(BL::Curves b_curves, std::optional b_attr_radius, const int index) { - float4 mP = float3_to_float4(get_float3(b_hair.position_data[index].vector())); + float4 mP = float3_to_float4(get_float3(b_curves.position_data[index].vector())); mP.w = b_attr_radius ? b_attr_radius->data[index].value() : 0.0f; return mP; } -static float4 interpolate_hair_points(BL::Hair b_hair, +static float4 interpolate_hair_points(BL::Curves b_curves, std::optional b_attr_radius, const int first_point_index, const int num_points, @@ -664,12 +664,12 @@ static float4 interpolate_hair_points(BL::Hair b_hair, const int point_a = clamp((int)curve_t, 0, num_points - 1); const int point_b = min(point_a + 1, num_points - 1); const float t = curve_t - (float)point_a; - return lerp(hair_point_as_float4(b_hair, b_attr_radius, first_point_index + point_a), - hair_point_as_float4(b_hair, b_attr_radius, first_point_index + point_b), + return lerp(hair_point_as_float4(b_curves, b_attr_radius, first_point_index + point_a), + hair_point_as_float4(b_curves, b_attr_radius, first_point_index + point_b), t); } -static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair) +static void export_hair_curves(Scene *scene, Hair *hair, BL::Curves b_curves) { /* TODO: optimize so we can straight memcpy arrays from Blender? */ @@ -689,19 +689,19 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair) } /* Reserve memory. */ - const int num_keys = b_hair.points.length(); - const int num_curves = b_hair.curves.length(); + const int num_keys = b_curves.points.length(); + const int num_curves = b_curves.curves.length(); hair->reserve_curves(num_curves, num_keys); - std::optional b_attr_radius = find_curves_radius_attribute(b_hair); + std::optional b_attr_radius = find_curves_radius_attribute(b_curves); /* Export curves and points. */ vector points_length; for (int i = 0; i < num_curves; i++) { - const int first_point_index = b_hair.curve_offset_data[i].value(); - const int num_points = b_hair.curve_offset_data[i + 1].value() - first_point_index; + const int first_point_index = b_curves.curve_offset_data[i].value(); + const int num_points = b_curves.curve_offset_data[i + 1].value() - first_point_index; float3 prev_co = zero_float3(); float length = 0.0f; @@ -712,7 +712,7 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair) /* Position and radius. */ for (int i = 0; i < num_points; i++) { - const float3 co = get_float3(b_hair.position_data[first_point_index + i].vector()); + const float3 co = get_float3(b_curves.position_data[first_point_index + i].vector()); const float radius = b_attr_radius ? b_attr_radius->data[first_point_index + i].value() : 0.0f; hair->add_curve_key(co, radius); @@ -748,7 +748,7 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair) } } -static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_step) +static void export_hair_curves_motion(Hair *hair, BL::Curves b_curves, int motion_step) { /* Find or add attribute. */ Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); @@ -761,17 +761,17 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st /* Export motion keys. */ const int num_keys = hair->get_curve_keys().size(); - const int num_curves = b_hair.curves.length(); + const int num_curves = b_curves.curves.length(); float4 *mP = attr_mP->data_float4() + motion_step * num_keys; bool have_motion = false; int num_motion_keys = 0; int curve_index = 0; - std::optional b_attr_radius = find_curves_radius_attribute(b_hair); + std::optional b_attr_radius = find_curves_radius_attribute(b_curves); for (int i = 0; i < num_curves; i++) { - const int first_point_index = b_hair.curve_offset_data[i].value(); - const int num_points = b_hair.curve_offset_data[i + 1].value() - first_point_index; + const int first_point_index = b_curves.curve_offset_data[i].value(); + const int num_points = b_curves.curve_offset_data[i + 1].value() - first_point_index; Hair::Curve curve = hair->get_curve(curve_index); curve_index++; @@ -782,7 +782,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st int point_index = first_point_index + i; if (point_index < num_keys) { - mP[num_motion_keys] = hair_point_as_float4(b_hair, b_attr_radius, point_index); + mP[num_motion_keys] = hair_point_as_float4(b_curves, b_attr_radius, point_index); num_motion_keys++; if (!have_motion) { @@ -802,7 +802,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st for (int i = 0; i < curve.num_keys; i++) { const float step = i * step_size; mP[num_motion_keys] = interpolate_hair_points( - b_hair, b_attr_radius, first_point_index, num_points, step); + b_curves, b_attr_radius, first_point_index, num_points, step); num_motion_keys++; } have_motion = true; @@ -819,12 +819,12 @@ static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_st void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step) { /* Convert Blender hair to Cycles curves. */ - BL::Hair b_hair(b_ob_info.object_data); + BL::Curves b_curves(b_ob_info.object_data); if (motion) { - export_hair_curves_motion(hair, b_hair, motion_step); + export_hair_curves_motion(hair, b_curves, motion_step); } else { - export_hair_curves(scene, hair, b_hair); + export_hair_curves(scene, hair, b_curves); } } #else @@ -847,8 +847,8 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, H new_hair.set_used_shaders(used_shaders); if (view_layer.use_hair) { -#ifdef WITH_HAIR_NODES - if (b_ob_info.object_data.is_a(&RNA_Hair)) { +#ifdef WITH_NEW_CURVES_TYPE + if (b_ob_info.object_data.is_a(&RNA_Curves)) { /* Hair object. */ sync_hair(&new_hair, b_ob_info, false); } @@ -901,8 +901,8 @@ void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph, /* Export deformed coordinates. */ if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) { -#ifdef WITH_HAIR_NODES - if (b_ob_info.object_data.is_a(&RNA_Hair)) { +#ifdef WITH_NEW_CURVES_TYPE + if (b_ob_info.object_data.is_a(&RNA_Curves)) { /* Hair object. */ sync_hair(hair, b_ob_info, true, motion_step); return; diff --git a/intern/cycles/blender/geometry.cpp b/intern/cycles/blender/geometry.cpp index 78c803b7adb..a9b61f2578f 100644 --- a/intern/cycles/blender/geometry.cpp +++ b/intern/cycles/blender/geometry.cpp @@ -32,8 +32,8 @@ CCL_NAMESPACE_BEGIN static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_particle_hair) { -#ifdef WITH_HAIR_NODES - if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) { +#ifdef WITH_NEW_CURVES_TYPE + if (b_ob_info.object_data.is_a(&RNA_Curves) || use_particle_hair) { #else if (use_particle_hair) { #endif @@ -231,8 +231,8 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph, if (progress.get_cancel()) return; -#ifdef WITH_HAIR_NODES - if (b_ob_info.object_data.is_a(&RNA_Hair) || use_particle_hair) { +#ifdef WITH_NEW_CURVES_TYPE + if (b_ob_info.object_data.is_a(&RNA_Curves) || use_particle_hair) { #else if (use_particle_hair) { #endif diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp index 65a04a39660..22acc09c538 100644 --- a/intern/cycles/blender/object.cpp +++ b/intern/cycles/blender/object.cpp @@ -72,7 +72,7 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info) BL::Object::type_enum type = b_ob_info.iter_object.type(); - if (type == BL::Object::type_VOLUME || type == BL::Object::type_HAIR || + if (type == BL::Object::type_VOLUME || type == BL::Object::type_CURVES || type == BL::Object::type_POINTCLOUD) { /* Will be exported attached to mesh. */ return true; @@ -97,7 +97,7 @@ bool BlenderSync::object_can_have_geometry(BL::Object &b_ob) case BL::Object::type_SURFACE: case BL::Object::type_META: case BL::Object::type_FONT: - case BL::Object::type_HAIR: + case BL::Object::type_CURVES: case BL::Object::type_POINTCLOUD: case BL::Object::type_VOLUME: return true; diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index 1fb40ad8bc8..7c254596683 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -33,9 +33,9 @@ _modules = [ "properties_data_bone", "properties_data_camera", "properties_data_curve", + "properties_data_curves", "properties_data_empty", "properties_data_gpencil", - "properties_data_hair", "properties_data_light", "properties_data_lattice", "properties_data_mesh", diff --git a/release/scripts/startup/bl_ui/properties_data_curves.py b/release/scripts/startup/bl_ui/properties_data_curves.py new file mode 100644 index 00000000000..0b4bf0283ed --- /dev/null +++ b/release/scripts/startup/bl_ui/properties_data_curves.py @@ -0,0 +1,142 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# +import bpy +from bpy.types import Menu, Panel, UIList +from rna_prop_ui import PropertyPanel + + +class DataButtonsPanel: + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "data" + + @classmethod + def poll(cls, context): + engine = context.scene.render.engine + return hasattr(context, 'curves') and context.curves and (engine in cls.COMPAT_ENGINES) + + +class DATA_PT_context_curves(DataButtonsPanel, Panel): + bl_label = "" + bl_options = {'HIDE_HEADER'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + + def draw(self, context): + layout = self.layout + + ob = context.object + curves = context.curves + space = context.space_data + + if ob: + layout.template_ID(ob, "data") + elif curves: + layout.template_ID(space, "pin_id") + + +class CURVES_MT_add_attribute(Menu): + bl_label = "Add Attribute" + + @staticmethod + def add_standard_attribute(layout, curves, name, data_type, domain): + exists = curves.attributes.get(name) is not None + + col = layout.column() + col.enabled = not exists + col.operator_context = 'EXEC_DEFAULT' + + props = col.operator("geometry.attribute_add", text=name) + props.name = name + props.data_type = data_type + props.domain = domain + + def draw(self, context): + layout = self.layout + curves = context.curves + + self.add_standard_attribute(layout, curves, 'radius', 'FLOAT', 'POINT') + self.add_standard_attribute(layout, curves, 'color', 'FLOAT_COLOR', 'POINT') + + layout.separator() + + layout.operator_context = 'INVOKE_DEFAULT' + layout.operator("geometry.attribute_add", text="Custom...") + + +class CURVES_UL_attributes(UIList): + def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index): + data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type] + domain = attribute.bl_rna.properties['domain'].enum_items[attribute.domain] + + split = layout.split(factor=0.5) + split.emboss = 'NONE' + row = split.row() + row.prop(attribute, "name", text="") + sub = split.split() + sub.alignment = 'RIGHT' + sub.active = False + sub.label(text=domain.name) + sub.label(text=data_type.name) + + +class DATA_PT_CURVES_attributes(DataButtonsPanel, Panel): + bl_label = "Attributes" + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + + def draw(self, context): + curves = context.curves + + layout = self.layout + row = layout.row() + + col = row.column() + col.template_list( + "CURVES_UL_attributes", + "attributes", + curves, + "attributes", + curves.attributes, + "active_index", + rows=3, + ) + + col = row.column(align=True) + col.menu("CURVES_MT_add_attribute", icon='ADD', text="") + col.operator("geometry.attribute_remove", icon='REMOVE', text="") + + +class DATA_PT_custom_props_curves(DataButtonsPanel, PropertyPanel, Panel): + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + _context_path = "object.data" + _property_type = bpy.types.Curves if hasattr(bpy.types, "Curves") else None + + +classes = ( + DATA_PT_context_curves, + DATA_PT_CURVES_attributes, + DATA_PT_custom_props_curves, + CURVES_MT_add_attribute, + CURVES_UL_attributes, +) + +if __name__ == "__main__": # only for live edit. + from bpy.utils import register_class + for cls in classes: + register_class(cls) diff --git a/release/scripts/startup/bl_ui/properties_data_hair.py b/release/scripts/startup/bl_ui/properties_data_hair.py deleted file mode 100644 index 7f95fad9a9e..00000000000 --- a/release/scripts/startup/bl_ui/properties_data_hair.py +++ /dev/null @@ -1,142 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -# -import bpy -from bpy.types import Menu, Panel, UIList -from rna_prop_ui import PropertyPanel - - -class DataButtonsPanel: - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" - - @classmethod - def poll(cls, context): - engine = context.scene.render.engine - return hasattr(context, 'hair') and context.hair and (engine in cls.COMPAT_ENGINES) - - -class DATA_PT_context_hair(DataButtonsPanel, Panel): - bl_label = "" - bl_options = {'HIDE_HEADER'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} - - def draw(self, context): - layout = self.layout - - ob = context.object - hair = context.hair - space = context.space_data - - if ob: - layout.template_ID(ob, "data") - elif hair: - layout.template_ID(space, "pin_id") - - -class HAIR_MT_add_attribute(Menu): - bl_label = "Add Attribute" - - @staticmethod - def add_standard_attribute(layout, hair, name, data_type, domain): - exists = hair.attributes.get(name) is not None - - col = layout.column() - col.enabled = not exists - col.operator_context = 'EXEC_DEFAULT' - - props = col.operator("geometry.attribute_add", text=name) - props.name = name - props.data_type = data_type - props.domain = domain - - def draw(self, context): - layout = self.layout - hair = context.hair - - self.add_standard_attribute(layout, hair, 'Radius', 'FLOAT', 'POINT') - self.add_standard_attribute(layout, hair, 'Color', 'FLOAT_COLOR', 'POINT') - - layout.separator() - - layout.operator_context = 'INVOKE_DEFAULT' - layout.operator("geometry.attribute_add", text="Custom...") - - -class HAIR_UL_attributes(UIList): - def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index): - data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type] - domain = attribute.bl_rna.properties['domain'].enum_items[attribute.domain] - - split = layout.split(factor=0.5) - split.emboss = 'NONE' - row = split.row() - row.prop(attribute, "name", text="") - sub = split.split() - sub.alignment = 'RIGHT' - sub.active = False - sub.label(text=domain.name) - sub.label(text=data_type.name) - - -class DATA_PT_hair_attributes(DataButtonsPanel, Panel): - bl_label = "Attributes" - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} - - def draw(self, context): - hair = context.hair - - layout = self.layout - row = layout.row() - - col = row.column() - col.template_list( - "HAIR_UL_attributes", - "attributes", - hair, - "attributes", - hair.attributes, - "active_index", - rows=3, - ) - - col = row.column(align=True) - col.menu("HAIR_MT_add_attribute", icon='ADD', text="") - col.operator("geometry.attribute_remove", icon='REMOVE', text="") - - -class DATA_PT_custom_props_hair(DataButtonsPanel, PropertyPanel, Panel): - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} - _context_path = "object.data" - _property_type = bpy.types.Hair if hasattr(bpy.types, "Hair") else None - - -classes = ( - DATA_PT_context_hair, - DATA_PT_hair_attributes, - DATA_PT_custom_props_hair, - HAIR_MT_add_attribute, - HAIR_UL_attributes, -) - -if __name__ == "__main__": # only for live edit. - from bpy.utils import register_class - for cls in classes: - register_class(cls) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 18dfa4da6c6..99edbe647e2 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -127,8 +127,8 @@ class DopesheetFilterPopoverBase: flow.prop(dopesheet, "show_lattices", text="Lattices") if bpy.data.metaballs: flow.prop(dopesheet, "show_metaballs", text="Metaballs") - if hasattr(bpy.data, "hairs") and bpy.data.hairs: - flow.prop(dopesheet, "show_hairs", text="Hairs") + if hasattr(bpy.data, "hair_curves") and bpy.data.hair_curves: + flow.prop(dopesheet, "show_hair_curves", text="Hair Curves") if hasattr(bpy.data, "pointclouds") and bpy.data.pointclouds: flow.prop(dopesheet, "show_pointclouds", text="Point Clouds") if bpy.data.volumes: diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index d85538a37e0..6cc80c088e0 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -448,7 +448,7 @@ class OUTLINER_PT_filter(Panel): if ( bpy.data.curves or bpy.data.metaballs or - (hasattr(bpy.data, "hairs") and bpy.data.hairs) or + (hasattr(bpy.data, "hair_curves") and bpy.data.hair_curves) or (hasattr(bpy.data, "pointclouds") and bpy.data.pointclouds) or bpy.data.volumes or bpy.data.lightprobes or diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 78ef68e0bab..26b4229690f 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -2295,7 +2295,7 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel): def draw(self, context): self._draw_items( context, ( - ({"property": "use_new_hair_type"}, "T68981"), + ({"property": "use_new_curves_type"}, "T68981"), ({"property": "use_new_point_cloud_type"}, "T75717"), ({"property": "use_full_frame_compositor"}, "T88150"), ), diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 03f5d7abe02..ea7a1885369 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2148,8 +2148,8 @@ class VIEW3D_MT_add(Menu): layout.menu("VIEW3D_MT_surface_add", icon='OUTLINER_OB_SURFACE') layout.menu("VIEW3D_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META') layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT') - if context.preferences.experimental.use_new_hair_type: - layout.operator("object.hair_add", text="Hair", icon='OUTLINER_OB_HAIR') + if context.preferences.experimental.use_new_curves_type: + layout.operator("object.hair_curves_add", text="Hair Curves", icon='OUTLINER_OB_CURVES') if context.preferences.experimental.use_new_point_cloud_type: layout.operator("object.pointcloud_add", text="Point Cloud", icon='OUTLINER_OB_POINTCLOUD') layout.menu("VIEW3D_MT_volume_add", text="Volume", icon='OUTLINER_OB_VOLUME') diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index c6112344208..1fcde431d2d 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -48,7 +48,7 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpu_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_hair_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curves_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_ipo_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_key_types.h diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 6020da08f51..ff207997e79 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -40,11 +40,11 @@ struct ReportList; /* Attribute.domain */ typedef enum AttributeDomain { ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */ - ATTR_DOMAIN_POINT = 0, /* Mesh, Hair or PointCloud Point */ + ATTR_DOMAIN_POINT = 0, /* Mesh, Curve or Point Cloud Point */ ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */ ATTR_DOMAIN_FACE = 2, /* Mesh Face */ ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */ - ATTR_DOMAIN_CURVE = 4, /* Hair Curve */ + ATTR_DOMAIN_CURVE = 4, /* A single curve in a larger curve data-block */ ATTR_DOMAIN_INSTANCE = 5, /* Instance */ ATTR_DOMAIN_NUM diff --git a/source/blender/blenkernel/BKE_curves.h b/source/blender/blenkernel/BKE_curves.h new file mode 100644 index 00000000000..99839b20121 --- /dev/null +++ b/source/blender/blenkernel/BKE_curves.h @@ -0,0 +1,68 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#pragma once + +/** \file + * \ingroup bke + * \brief Low-level operations for curves. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct BoundBox; +struct CustomDataLayer; +struct Depsgraph; +struct Curves; +struct Main; +struct Object; +struct Scene; + +void *BKE_curves_add(struct Main *bmain, const char *name); + +struct BoundBox *BKE_curves_boundbox_get(struct Object *ob); + +void BKE_curves_update_customdata_pointers(struct Curves *curves); +bool BKE_curves_customdata_required(struct Curves *curves, struct CustomDataLayer *layer); + +/* Depsgraph */ + +struct Curves *BKE_curves_new_for_eval(const struct Curves *curves_src, + int totpoint, + int totcurve); +struct Curves *BKE_curves_copy_for_eval(struct Curves *curves_src, bool reference); + +void BKE_curves_data_update(struct Depsgraph *depsgraph, + struct Scene *scene, + struct Object *object); + +/* Draw Cache */ + +enum { + BKE_CURVES_BATCH_DIRTY_ALL = 0, +}; + +void BKE_curves_batch_cache_dirty_tag(struct Curves *curves, int mode); +void BKE_curves_batch_cache_free(struct Curves *curves); + +extern void (*BKE_curves_batch_cache_dirty_tag_cb)(struct Curves *curves, int mode); +extern void (*BKE_curves_batch_cache_free_cb)(struct Curves *curves); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h deleted file mode 100644 index 403e461a9dc..00000000000 --- a/source/blender/blenkernel/BKE_hair.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#pragma once - -/** \file - * \ingroup bke - * \brief General operations for hairs. - */ -#ifdef __cplusplus -extern "C" { -#endif - -struct BoundBox; -struct CustomDataLayer; -struct Depsgraph; -struct Hair; -struct Main; -struct Object; -struct Scene; - -void *BKE_hair_add(struct Main *bmain, const char *name); - -struct BoundBox *BKE_hair_boundbox_get(struct Object *ob); - -void BKE_hair_update_customdata_pointers(struct Hair *hair); -bool BKE_hair_customdata_required(struct Hair *hair, struct CustomDataLayer *layer); - -/* Depsgraph */ - -struct Hair *BKE_hair_new_for_eval(const struct Hair *hair_src, int totpoint, int totcurve); -struct Hair *BKE_hair_copy_for_eval(struct Hair *hair_src, bool reference); - -void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object); - -/* Draw Cache */ - -enum { - BKE_HAIR_BATCH_DIRTY_ALL = 0, -}; - -void BKE_hair_batch_cache_dirty_tag(struct Hair *hair, int mode); -void BKE_hair_batch_cache_free(struct Hair *hair); - -extern void (*BKE_hair_batch_cache_dirty_tag_cb)(struct Hair *hair, int mode); -extern void (*BKE_hair_batch_cache_free_cb)(struct Hair *hair); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h index df50f773a46..e9e5b183e4a 100644 --- a/source/blender/blenkernel/BKE_idtype.h +++ b/source/blender/blenkernel/BKE_idtype.h @@ -278,7 +278,7 @@ extern IDTypeInfo IDType_ID_PC; extern IDTypeInfo IDType_ID_CF; extern IDTypeInfo IDType_ID_WS; extern IDTypeInfo IDType_ID_LP; -extern IDTypeInfo IDType_ID_HA; +extern IDTypeInfo IDType_ID_CV; extern IDTypeInfo IDType_ID_PT; extern IDTypeInfo IDType_ID_VO; extern IDTypeInfo IDType_ID_SIM; diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 4c6eb31db4b..e4f94110eb1 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -182,7 +182,11 @@ typedef struct Main { ListBase linestyles; ListBase cachefiles; ListBase workspaces; - ListBase hairs; + /** + * \note The name `hair_curves` is chosen to be different than `curves`, + * but they are generic curve data-blocks, not just for hair. + */ + ListBase hair_curves; ListBase pointclouds; ListBase volumes; ListBase simulations; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 55a68c1c5a0..efc9cd6e99f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -119,6 +119,7 @@ set(SRC intern/crazyspace.c intern/cryptomatte.cc intern/curve.cc + intern/curves.cc intern/curve_bevel.c intern/curve_convert.c intern/curve_decimate.c @@ -156,7 +157,6 @@ set(SRC intern/gpencil_curve.c intern/gpencil_geom.cc intern/gpencil_modifier.c - intern/hair.cc intern/icons.cc intern/icons_rasterize.c intern/idprop.c @@ -356,6 +356,7 @@ set(SRC BKE_cryptomatte.h BKE_cryptomatte.hh BKE_curve.h + BKE_curves.h BKE_curve_to_mesh.hh BKE_curveprofile.h BKE_customdata.h @@ -384,7 +385,6 @@ set(SRC BKE_gpencil_curve.h BKE_gpencil_geom.h BKE_gpencil_modifier.h - BKE_hair.h BKE_icons.h BKE_idprop.h BKE_idprop.hh diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index 42b72a7cd66..1c0b465d202 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -1284,8 +1284,8 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use /* cache files */ ANIMDATA_IDS_CB(bmain->cachefiles.first); - /* hairs */ - ANIMDATA_IDS_CB(bmain->hairs.first); + /* Hair Curves. */ + ANIMDATA_IDS_CB(bmain->hair_curves.first); /* pointclouds */ ANIMDATA_IDS_CB(bmain->pointclouds.first); @@ -1413,8 +1413,8 @@ void BKE_animdata_fix_paths_rename_all_ex(Main *bmain, /* cache files */ RENAMEFIX_ANIM_IDS(bmain->cachefiles.first); - /* hairs */ - RENAMEFIX_ANIM_IDS(bmain->hairs.first); + /* Hair Curves. */ + RENAMEFIX_ANIM_IDS(bmain->hair_curves.first); /* pointclouds */ RENAMEFIX_ANIM_IDS(bmain->pointclouds.first); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index b5ea68aaadc..c45856adbda 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -3382,8 +3382,8 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, float /* cache files */ EVAL_ANIM_IDS(main->cachefiles.first, ADT_RECALC_ANIM); - /* hairs */ - EVAL_ANIM_IDS(main->hairs.first, ADT_RECALC_ANIM); + /* Hair Curves. */ + EVAL_ANIM_IDS(main->hair_curves.first, ADT_RECALC_ANIM); /* pointclouds */ EVAL_ANIM_IDS(main->pointclouds.first, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c index 73e00398084..74eb95add51 100644 --- a/source/blender/blenkernel/intern/attribute.c +++ b/source/blender/blenkernel/intern/attribute.c @@ -29,8 +29,8 @@ #include "MEM_guardedalloc.h" #include "DNA_ID.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" -#include "DNA_hair_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_pointcloud_types.h" @@ -38,9 +38,9 @@ #include "BLI_string_utf8.h" #include "BKE_attribute.h" +#include "BKE_curves.h" #include "BKE_customdata.h" #include "BKE_editmesh.h" -#include "BKE_hair.h" #include "BKE_pointcloud.h" #include "BKE_report.h" @@ -88,12 +88,12 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM]) } break; } - case ID_HA: { - Hair *hair = (Hair *)id; - info[ATTR_DOMAIN_POINT].customdata = &hair->geometry.point_data; - info[ATTR_DOMAIN_POINT].length = hair->geometry.point_size; - info[ATTR_DOMAIN_CURVE].customdata = &hair->geometry.curve_data; - info[ATTR_DOMAIN_CURVE].length = hair->geometry.curve_size; + case ID_CV: { + Curves *curves = (Curves *)id; + info[ATTR_DOMAIN_POINT].customdata = &curves->geometry.point_data; + info[ATTR_DOMAIN_POINT].length = curves->geometry.point_size; + info[ATTR_DOMAIN_CURVE].customdata = &curves->geometry.curve_data; + info[ATTR_DOMAIN_CURVE].length = curves->geometry.curve_size; break; } default: @@ -301,8 +301,8 @@ bool BKE_id_attribute_required(ID *id, CustomDataLayer *layer) case ID_PT: { return BKE_pointcloud_customdata_required((PointCloud *)id, layer); } - case ID_HA: { - return BKE_hair_customdata_required((Hair *)id, layer); + case ID_CV: { + return BKE_curves_customdata_required((Curves *)id, layer); } default: return false; @@ -372,8 +372,8 @@ int *BKE_id_attributes_active_index_p(ID *id) case ID_ME: { return &((Mesh *)id)->attributes_active_index; } - case ID_HA: { - return &((Hair *)id)->attributes_active_index; + case ID_CV: { + return &((Curves *)id)->attributes_active_index; } default: return NULL; diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc new file mode 100644 index 00000000000..f5672e9b288 --- /dev/null +++ b/source/blender/blenkernel/intern/curves.cc @@ -0,0 +1,473 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup bke + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "DNA_curves_types.h" +#include "DNA_defaults.h" +#include "DNA_material_types.h" +#include "DNA_object_types.h" + +#include "BLI_index_range.hh" +#include "BLI_listbase.h" +#include "BLI_math_base.h" +#include "BLI_math_vec_types.hh" +#include "BLI_rand.hh" +#include "BLI_string.h" +#include "BLI_utildefines.h" + +#include "BKE_anim_data.h" +#include "BKE_curves.h" +#include "BKE_customdata.h" +#include "BKE_global.h" +#include "BKE_idtype.h" +#include "BKE_lib_id.h" +#include "BKE_lib_query.h" +#include "BKE_lib_remap.h" +#include "BKE_main.h" +#include "BKE_modifier.h" +#include "BKE_object.h" + +#include "BLT_translation.h" + +#include "DEG_depsgraph_query.h" + +#include "BLO_read_write.h" + +using blender::float3; +using blender::IndexRange; +using blender::MutableSpan; +using blender::RandomNumberGenerator; + +static const char *ATTR_POSITION = "position"; +static const char *ATTR_RADIUS = "radius"; + +static void curves_random(Curves *curves); + +static void curves_init_data(ID *id) +{ + Curves *curves = (Curves *)id; + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(curves, id)); + + MEMCPY_STRUCT_AFTER(curves, DNA_struct_default_get(Curves), id); + + CustomData_reset(&curves->geometry.point_data); + CustomData_reset(&curves->geometry.curve_data); + + CustomData_add_layer_named(&curves->geometry.point_data, + CD_PROP_FLOAT3, + CD_CALLOC, + nullptr, + curves->geometry.point_size, + ATTR_POSITION); + CustomData_add_layer_named(&curves->geometry.point_data, + CD_PROP_FLOAT, + CD_CALLOC, + nullptr, + curves->geometry.point_size, + ATTR_RADIUS); + + BKE_curves_update_customdata_pointers(curves); + + curves_random(curves); +} + +static void curves_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag) +{ + Curves *curves_dst = (Curves *)id_dst; + const Curves *curves_src = (const Curves *)id_src; + curves_dst->mat = static_cast(MEM_dupallocN(curves_src->mat)); + + curves_dst->geometry.point_size = curves_src->geometry.point_size; + curves_dst->geometry.curve_size = curves_src->geometry.curve_size; + + const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE; + CustomData_copy(&curves_src->geometry.point_data, + &curves_dst->geometry.point_data, + CD_MASK_ALL, + alloc_type, + curves_dst->geometry.point_size); + CustomData_copy(&curves_src->geometry.curve_data, + &curves_dst->geometry.curve_data, + CD_MASK_ALL, + alloc_type, + curves_dst->geometry.curve_size); + BKE_curves_update_customdata_pointers(curves_dst); + + curves_dst->geometry.offsets = static_cast(MEM_dupallocN(curves_src->geometry.offsets)); + + curves_dst->batch_cache = nullptr; +} + +static void curves_free_data(ID *id) +{ + Curves *curves = (Curves *)id; + BKE_animdata_free(&curves->id, false); + + BKE_curves_batch_cache_free(curves); + + CustomData_free(&curves->geometry.point_data, curves->geometry.point_size); + CustomData_free(&curves->geometry.curve_data, curves->geometry.curve_size); + + MEM_SAFE_FREE(curves->geometry.offsets); + + MEM_SAFE_FREE(curves->mat); +} + +static void curves_foreach_id(ID *id, LibraryForeachIDData *data) +{ + Curves *curves = (Curves *)id; + for (int i = 0; i < curves->totcol; i++) { + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curves->mat[i], IDWALK_CB_USER); + } +} + +static void curves_blend_write(BlendWriter *writer, ID *id, const void *id_address) +{ + Curves *curves = (Curves *)id; + + CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE]; + CustomDataLayer *clayers = nullptr, clayers_buff[CD_TEMP_CHUNK_SIZE]; + CustomData_blend_write_prepare( + &curves->geometry.point_data, &players, players_buff, ARRAY_SIZE(players_buff)); + CustomData_blend_write_prepare( + &curves->geometry.curve_data, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff)); + + /* Write LibData */ + BLO_write_id_struct(writer, Curves, id_address, &curves->id); + BKE_id_blend_write(writer, &curves->id); + + /* Direct data */ + CustomData_blend_write(writer, + &curves->geometry.point_data, + players, + curves->geometry.point_size, + CD_MASK_ALL, + &curves->id); + CustomData_blend_write(writer, + &curves->geometry.curve_data, + clayers, + curves->geometry.curve_size, + CD_MASK_ALL, + &curves->id); + + BLO_write_int32_array(writer, curves->geometry.curve_size + 1, curves->geometry.offsets); + + BLO_write_pointer_array(writer, curves->totcol, curves->mat); + if (curves->adt) { + BKE_animdata_blend_write(writer, curves->adt); + } + + /* Remove temporary data. */ + if (players && players != players_buff) { + MEM_freeN(players); + } + if (clayers && clayers != clayers_buff) { + MEM_freeN(clayers); + } +} + +static void curves_blend_read_data(BlendDataReader *reader, ID *id) +{ + Curves *curves = (Curves *)id; + BLO_read_data_address(reader, &curves->adt); + BKE_animdata_blend_read_data(reader, curves->adt); + + /* Geometry */ + CustomData_blend_read(reader, &curves->geometry.point_data, curves->geometry.point_size); + CustomData_blend_read(reader, &curves->geometry.curve_data, curves->geometry.point_size); + BKE_curves_update_customdata_pointers(curves); + + BLO_read_int32_array(reader, curves->geometry.curve_size + 1, &curves->geometry.offsets); + + /* Materials */ + BLO_read_pointer_array(reader, (void **)&curves->mat); +} + +static void curves_blend_read_lib(BlendLibReader *reader, ID *id) +{ + Curves *curves = (Curves *)id; + for (int a = 0; a < curves->totcol; a++) { + BLO_read_id_address(reader, curves->id.lib, &curves->mat[a]); + } +} + +static void curves_blend_read_expand(BlendExpander *expander, ID *id) +{ + Curves *curves = (Curves *)id; + for (int a = 0; a < curves->totcol; a++) { + BLO_expand(expander, curves->mat[a]); + } +} + +IDTypeInfo IDType_ID_CV = { + /*id_code */ ID_CV, + /*id_filter */ FILTER_ID_CV, + /*main_listbase_index */ INDEX_ID_CV, + /*struct_size */ sizeof(Curves), + /*name */ "Hair Curves", + /*name_plural */ "Hair Curves", + /*translation_context */ BLT_I18NCONTEXT_ID_CURVES, + /*flags */ IDTYPE_FLAGS_APPEND_IS_REUSABLE, + /*asset_type_info */ nullptr, + + /*init_data */ curves_init_data, + /*copy_data */ curves_copy_data, + /*free_data */ curves_free_data, + /*make_local */ nullptr, + /*foreach_id */ curves_foreach_id, + /*foreach_cache */ nullptr, + /*foreach_path */ nullptr, + /*owner_get */ nullptr, + + /*blend_write */ curves_blend_write, + /*blend_read_data */ curves_blend_read_data, + /*blend_read_lib */ curves_blend_read_lib, + /*blend_read_expand */ curves_blend_read_expand, + + /*blend_read_undo_preserve */ nullptr, + + /*lib_override_apply_post */ nullptr, +}; + +static void curves_random(Curves *curves) +{ + CurvesGeometry &geometry = curves->geometry; + const int numpoints = 8; + + geometry.curve_size = 500; + + geometry.curve_size = 500; + geometry.point_size = geometry.curve_size * numpoints; + + curves->geometry.offsets = (int *)MEM_calloc_arrayN( + curves->geometry.curve_size + 1, sizeof(int), __func__); + CustomData_realloc(&geometry.point_data, geometry.point_size); + CustomData_realloc(&geometry.curve_data, geometry.curve_size); + BKE_curves_update_customdata_pointers(curves); + + MutableSpan offsets{geometry.offsets, geometry.curve_size + 1}; + MutableSpan positions{(float3 *)geometry.position, geometry.point_size}; + MutableSpan radii{geometry.radius, geometry.point_size}; + + for (const int i : offsets.index_range()) { + geometry.offsets[i] = numpoints * i; + } + + RandomNumberGenerator rng; + + for (int i = 0; i < geometry.curve_size; i++) { + const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); + MutableSpan curve_positions = positions.slice(curve_range); + MutableSpan curve_radii = radii.slice(curve_range); + + const float theta = 2.0f * M_PI * rng.get_float(); + const float phi = saacosf(2.0f * rng.get_float() - 1.0f); + + float3 no = {std::sin(theta) * std::sin(phi), std::cos(theta) * std::sin(phi), std::cos(phi)}; + no = blender::math::normalize(no); + + float3 co = no; + for (int key = 0; key < numpoints; key++) { + float t = key / (float)(numpoints - 1); + curve_positions[key] = co; + curve_radii[key] = 0.02f * (1.0f - t); + + float3 offset = float3(rng.get_float(), rng.get_float(), rng.get_float()) * 2.0f - 1.0f; + co += (offset + no) / numpoints; + } + } +} + +void *BKE_curves_add(Main *bmain, const char *name) +{ + Curves *curves = static_cast(BKE_id_new(bmain, ID_CV, name)); + + return curves; +} + +BoundBox *BKE_curves_boundbox_get(Object *ob) +{ + BLI_assert(ob->type == OB_CURVES); + Curves *curves = static_cast(ob->data); + + if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) { + return ob->runtime.bb; + } + + if (ob->runtime.bb == nullptr) { + ob->runtime.bb = MEM_cnew(__func__); + + float min[3], max[3]; + INIT_MINMAX(min, max); + + float(*curves_co)[3] = curves->geometry.position; + float *curves_radius = curves->geometry.radius; + for (int a = 0; a < curves->geometry.point_size; a++) { + float *co = curves_co[a]; + float radius = (curves_radius) ? curves_radius[a] : 0.0f; + const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; + const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; + DO_MIN(co_min, min); + DO_MAX(co_max, max); + } + + BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); + } + + return ob->runtime.bb; +} + +void BKE_curves_update_customdata_pointers(Curves *curves) +{ + curves->geometry.position = (float(*)[3])CustomData_get_layer_named( + &curves->geometry.point_data, CD_PROP_FLOAT3, ATTR_POSITION); + curves->geometry.radius = (float *)CustomData_get_layer_named( + &curves->geometry.point_data, CD_PROP_FLOAT, ATTR_RADIUS); +} + +bool BKE_curves_customdata_required(Curves *UNUSED(curves), CustomDataLayer *layer) +{ + return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, ATTR_POSITION); +} + +/* Dependency Graph */ + +Curves *BKE_curves_new_for_eval(const Curves *curves_src, int totpoint, int totcurve) +{ + Curves *curves_dst = static_cast(BKE_id_new_nomain(ID_CV, nullptr)); + + STRNCPY(curves_dst->id.name, curves_src->id.name); + curves_dst->mat = static_cast(MEM_dupallocN(curves_src->mat)); + curves_dst->totcol = curves_src->totcol; + + curves_dst->geometry.point_size = totpoint; + curves_dst->geometry.curve_size = totcurve; + CustomData_copy(&curves_src->geometry.point_data, + &curves_dst->geometry.point_data, + CD_MASK_ALL, + CD_CALLOC, + totpoint); + CustomData_copy(&curves_src->geometry.curve_data, + &curves_dst->geometry.curve_data, + CD_MASK_ALL, + CD_CALLOC, + totcurve); + BKE_curves_update_customdata_pointers(curves_dst); + + return curves_dst; +} + +Curves *BKE_curves_copy_for_eval(Curves *curves_src, bool reference) +{ + int flags = LIB_ID_COPY_LOCALIZE; + + if (reference) { + flags |= LIB_ID_COPY_CD_REFERENCE; + } + + Curves *result = (Curves *)BKE_id_copy_ex(nullptr, &curves_src->id, nullptr, flags); + return result; +} + +static Curves *curves_evaluate_modifiers(struct Depsgraph *depsgraph, + struct Scene *scene, + Object *object, + Curves *curves_input) +{ + Curves *curves = curves_input; + + /* Modifier evaluation modes. */ + const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); + const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; + ModifierApplyFlag apply_flag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE; + const ModifierEvalContext mectx = {depsgraph, object, apply_flag}; + + /* Get effective list of modifiers to execute. Some effects like shape keys + * are added as virtual modifiers before the user created modifiers. */ + VirtualModifierData virtualModifierData; + ModifierData *md = BKE_modifiers_get_virtual_modifierlist(object, &virtualModifierData); + + /* Evaluate modifiers. */ + for (; md; md = md->next) { + const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast(md->type)); + + if (!BKE_modifier_is_enabled(scene, md, required_mode)) { + continue; + } + + if ((mti->type == eModifierTypeType_OnlyDeform) && + (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly)) { + /* Ensure we are not modifying the input. */ + if (curves == curves_input) { + curves = BKE_curves_copy_for_eval(curves, true); + } + + /* Ensure we are not overwriting referenced data. */ + CustomData_duplicate_referenced_layer_named(&curves->geometry.point_data, + CD_PROP_FLOAT3, + ATTR_POSITION, + curves->geometry.point_size); + BKE_curves_update_customdata_pointers(curves); + + /* Created deformed coordinates array on demand. */ + mti->deformVerts( + md, &mectx, nullptr, curves->geometry.position, curves->geometry.point_size); + } + } + + return curves; +} + +void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) +{ + /* Free any evaluated data and restore original data. */ + BKE_object_free_derived_caches(object); + + /* Evaluate modifiers. */ + Curves *curves = static_cast(object->data); + Curves *curves_eval = curves_evaluate_modifiers(depsgraph, scene, object, curves); + + /* Assign evaluated object. */ + const bool is_owned = (curves != curves_eval); + BKE_object_eval_assign_data(object, &curves_eval->id, is_owned); +} + +/* Draw Cache */ + +void (*BKE_curves_batch_cache_dirty_tag_cb)(Curves *curves, int mode) = nullptr; +void (*BKE_curves_batch_cache_free_cb)(Curves *curves) = nullptr; + +void BKE_curves_batch_cache_dirty_tag(Curves *curves, int mode) +{ + if (curves->batch_cache) { + BKE_curves_batch_cache_dirty_tag_cb(curves, mode); + } +} + +void BKE_curves_batch_cache_free(Curves *curves) +{ + if (curves->batch_cache) { + BKE_curves_batch_cache_free_cb(curves); + } +} diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 36d511422aa..c5cc077c8ae 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -31,7 +31,6 @@ #include "DNA_ID.h" #include "DNA_customdata_types.h" -#include "DNA_hair_types.h" #include "DNA_meshdata_types.h" #include "BLI_bitmap.h" diff --git a/source/blender/blenkernel/intern/hair.cc b/source/blender/blenkernel/intern/hair.cc deleted file mode 100644 index bddadc3bcfd..00000000000 --- a/source/blender/blenkernel/intern/hair.cc +++ /dev/null @@ -1,474 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** \file - * \ingroup bke - */ - -#include -#include - -#include "MEM_guardedalloc.h" - -#include "DNA_defaults.h" -#include "DNA_hair_types.h" -#include "DNA_material_types.h" -#include "DNA_object_types.h" - -#include "BLI_index_range.hh" -#include "BLI_listbase.h" -#include "BLI_math_base.h" -#include "BLI_math_vec_types.hh" -#include "BLI_rand.hh" -#include "BLI_string.h" -#include "BLI_utildefines.h" - -#include "BKE_anim_data.h" -#include "BKE_customdata.h" -#include "BKE_global.h" -#include "BKE_hair.h" -#include "BKE_idtype.h" -#include "BKE_lib_id.h" -#include "BKE_lib_query.h" -#include "BKE_lib_remap.h" -#include "BKE_main.h" -#include "BKE_modifier.h" -#include "BKE_object.h" - -#include "BLT_translation.h" - -#include "DEG_depsgraph_query.h" - -#include "BLO_read_write.h" - -using blender::float3; -using blender::IndexRange; -using blender::MutableSpan; -using blender::RandomNumberGenerator; - -static const char *HAIR_ATTR_POSITION = "position"; -static const char *HAIR_ATTR_RADIUS = "radius"; - -/* Hair datablock */ - -static void hair_random(Hair *hair); - -static void hair_init_data(ID *id) -{ - Hair *hair = (Hair *)id; - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(hair, id)); - - MEMCPY_STRUCT_AFTER(hair, DNA_struct_default_get(Hair), id); - - CustomData_reset(&hair->geometry.point_data); - CustomData_reset(&hair->geometry.curve_data); - - CustomData_add_layer_named(&hair->geometry.point_data, - CD_PROP_FLOAT3, - CD_CALLOC, - nullptr, - hair->geometry.point_size, - HAIR_ATTR_POSITION); - CustomData_add_layer_named(&hair->geometry.point_data, - CD_PROP_FLOAT, - CD_CALLOC, - nullptr, - hair->geometry.point_size, - HAIR_ATTR_RADIUS); - - BKE_hair_update_customdata_pointers(hair); - - hair_random(hair); -} - -static void hair_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag) -{ - Hair *hair_dst = (Hair *)id_dst; - const Hair *hair_src = (const Hair *)id_src; - hair_dst->mat = static_cast(MEM_dupallocN(hair_src->mat)); - - hair_dst->geometry.point_size = hair_src->geometry.point_size; - hair_dst->geometry.curve_size = hair_src->geometry.curve_size; - - const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE; - CustomData_copy(&hair_src->geometry.point_data, - &hair_dst->geometry.point_data, - CD_MASK_ALL, - alloc_type, - hair_dst->geometry.point_size); - CustomData_copy(&hair_src->geometry.curve_data, - &hair_dst->geometry.curve_data, - CD_MASK_ALL, - alloc_type, - hair_dst->geometry.curve_size); - BKE_hair_update_customdata_pointers(hair_dst); - - hair_dst->geometry.offsets = static_cast(MEM_dupallocN(hair_src->geometry.offsets)); - - hair_dst->batch_cache = nullptr; -} - -static void hair_free_data(ID *id) -{ - Hair *hair = (Hair *)id; - BKE_animdata_free(&hair->id, false); - - BKE_hair_batch_cache_free(hair); - - CustomData_free(&hair->geometry.point_data, hair->geometry.point_size); - CustomData_free(&hair->geometry.curve_data, hair->geometry.curve_size); - - MEM_SAFE_FREE(hair->geometry.offsets); - - MEM_SAFE_FREE(hair->mat); -} - -static void hair_foreach_id(ID *id, LibraryForeachIDData *data) -{ - Hair *hair = (Hair *)id; - for (int i = 0; i < hair->totcol; i++) { - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, hair->mat[i], IDWALK_CB_USER); - } -} - -static void hair_blend_write(BlendWriter *writer, ID *id, const void *id_address) -{ - Hair *hair = (Hair *)id; - - CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE]; - CustomDataLayer *clayers = nullptr, clayers_buff[CD_TEMP_CHUNK_SIZE]; - CustomData_blend_write_prepare( - &hair->geometry.point_data, &players, players_buff, ARRAY_SIZE(players_buff)); - CustomData_blend_write_prepare( - &hair->geometry.curve_data, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff)); - - /* Write LibData */ - BLO_write_id_struct(writer, Hair, id_address, &hair->id); - BKE_id_blend_write(writer, &hair->id); - - /* Direct data */ - CustomData_blend_write(writer, - &hair->geometry.point_data, - players, - hair->geometry.point_size, - CD_MASK_ALL, - &hair->id); - CustomData_blend_write(writer, - &hair->geometry.curve_data, - clayers, - hair->geometry.curve_size, - CD_MASK_ALL, - &hair->id); - - BLO_write_int32_array(writer, hair->geometry.curve_size + 1, hair->geometry.offsets); - - BLO_write_pointer_array(writer, hair->totcol, hair->mat); - if (hair->adt) { - BKE_animdata_blend_write(writer, hair->adt); - } - - /* Remove temporary data. */ - if (players && players != players_buff) { - MEM_freeN(players); - } - if (clayers && clayers != clayers_buff) { - MEM_freeN(clayers); - } -} - -static void hair_blend_read_data(BlendDataReader *reader, ID *id) -{ - Hair *hair = (Hair *)id; - BLO_read_data_address(reader, &hair->adt); - BKE_animdata_blend_read_data(reader, hair->adt); - - /* Geometry */ - CustomData_blend_read(reader, &hair->geometry.point_data, hair->geometry.point_size); - CustomData_blend_read(reader, &hair->geometry.curve_data, hair->geometry.point_size); - BKE_hair_update_customdata_pointers(hair); - - BLO_read_int32_array(reader, hair->geometry.curve_size + 1, &hair->geometry.offsets); - - /* Materials */ - BLO_read_pointer_array(reader, (void **)&hair->mat); -} - -static void hair_blend_read_lib(BlendLibReader *reader, ID *id) -{ - Hair *hair = (Hair *)id; - for (int a = 0; a < hair->totcol; a++) { - BLO_read_id_address(reader, hair->id.lib, &hair->mat[a]); - } -} - -static void hair_blend_read_expand(BlendExpander *expander, ID *id) -{ - Hair *hair = (Hair *)id; - for (int a = 0; a < hair->totcol; a++) { - BLO_expand(expander, hair->mat[a]); - } -} - -IDTypeInfo IDType_ID_HA = { - /*id_code */ ID_HA, - /*id_filter */ FILTER_ID_HA, - /*main_listbase_index */ INDEX_ID_HA, - /*struct_size */ sizeof(Hair), - /*name */ "Hair", - /*name_plural */ "hairs", - /*translation_context */ BLT_I18NCONTEXT_ID_HAIR, - /*flags */ IDTYPE_FLAGS_APPEND_IS_REUSABLE, - /*asset_type_info */ nullptr, - - /*init_data */ hair_init_data, - /*copy_data */ hair_copy_data, - /*free_data */ hair_free_data, - /*make_local */ nullptr, - /*foreach_id */ hair_foreach_id, - /*foreach_cache */ nullptr, - /*foreach_path */ nullptr, - /*owner_get */ nullptr, - - /*blend_write */ hair_blend_write, - /*blend_read_data */ hair_blend_read_data, - /*blend_read_lib */ hair_blend_read_lib, - /*blend_read_expand */ hair_blend_read_expand, - - /*blend_read_undo_preserve */ nullptr, - - /*lib_override_apply_post */ nullptr, -}; - -static void hair_random(Hair *hair) -{ - CurvesGeometry &geometry = hair->geometry; - const int numpoints = 8; - - geometry.curve_size = 500; - - geometry.curve_size = 500; - geometry.point_size = geometry.curve_size * numpoints; - - hair->geometry.offsets = (int *)MEM_calloc_arrayN( - hair->geometry.curve_size + 1, sizeof(int), __func__); - CustomData_realloc(&geometry.point_data, geometry.point_size); - CustomData_realloc(&geometry.curve_data, geometry.curve_size); - BKE_hair_update_customdata_pointers(hair); - - MutableSpan offsets{geometry.offsets, geometry.curve_size + 1}; - MutableSpan positions{(float3 *)geometry.position, geometry.point_size}; - MutableSpan radii{geometry.radius, geometry.point_size}; - - for (const int i : offsets.index_range()) { - geometry.offsets[i] = numpoints * i; - } - - RandomNumberGenerator rng; - - for (int i = 0; i < geometry.curve_size; i++) { - const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); - MutableSpan curve_positions = positions.slice(curve_range); - MutableSpan curve_radii = radii.slice(curve_range); - - const float theta = 2.0f * M_PI * rng.get_float(); - const float phi = saacosf(2.0f * rng.get_float() - 1.0f); - - float3 no = {std::sin(theta) * std::sin(phi), std::cos(theta) * std::sin(phi), std::cos(phi)}; - no = blender::math::normalize(no); - - float3 co = no; - for (int key = 0; key < numpoints; key++) { - float t = key / (float)(numpoints - 1); - curve_positions[key] = co; - curve_radii[key] = 0.02f * (1.0f - t); - - float3 offset = float3(rng.get_float(), rng.get_float(), rng.get_float()) * 2.0f - 1.0f; - co += (offset + no) / numpoints; - } - } -} - -void *BKE_hair_add(Main *bmain, const char *name) -{ - Hair *hair = static_cast(BKE_id_new(bmain, ID_HA, name)); - - return hair; -} - -BoundBox *BKE_hair_boundbox_get(Object *ob) -{ - BLI_assert(ob->type == OB_HAIR); - Hair *hair = static_cast(ob->data); - - if (ob->runtime.bb != nullptr && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) { - return ob->runtime.bb; - } - - if (ob->runtime.bb == nullptr) { - ob->runtime.bb = MEM_cnew(__func__); - - float min[3], max[3]; - INIT_MINMAX(min, max); - - float(*hair_co)[3] = hair->geometry.position; - float *hair_radius = hair->geometry.radius; - for (int a = 0; a < hair->geometry.point_size; a++) { - float *co = hair_co[a]; - float radius = (hair_radius) ? hair_radius[a] : 0.0f; - const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; - const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; - DO_MIN(co_min, min); - DO_MAX(co_max, max); - } - - BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); - } - - return ob->runtime.bb; -} - -void BKE_hair_update_customdata_pointers(Hair *hair) -{ - hair->geometry.position = (float(*)[3])CustomData_get_layer_named( - &hair->geometry.point_data, CD_PROP_FLOAT3, HAIR_ATTR_POSITION); - hair->geometry.radius = (float *)CustomData_get_layer_named( - &hair->geometry.point_data, CD_PROP_FLOAT, HAIR_ATTR_RADIUS); -} - -bool BKE_hair_customdata_required(Hair *UNUSED(hair), CustomDataLayer *layer) -{ - return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, HAIR_ATTR_POSITION); -} - -/* Dependency Graph */ - -Hair *BKE_hair_new_for_eval(const Hair *hair_src, int totpoint, int totcurve) -{ - Hair *hair_dst = static_cast(BKE_id_new_nomain(ID_HA, nullptr)); - - STRNCPY(hair_dst->id.name, hair_src->id.name); - hair_dst->mat = static_cast(MEM_dupallocN(hair_src->mat)); - hair_dst->totcol = hair_src->totcol; - - hair_dst->geometry.point_size = totpoint; - hair_dst->geometry.curve_size = totcurve; - CustomData_copy(&hair_src->geometry.point_data, - &hair_dst->geometry.point_data, - CD_MASK_ALL, - CD_CALLOC, - totpoint); - CustomData_copy(&hair_src->geometry.curve_data, - &hair_dst->geometry.curve_data, - CD_MASK_ALL, - CD_CALLOC, - totcurve); - BKE_hair_update_customdata_pointers(hair_dst); - - return hair_dst; -} - -Hair *BKE_hair_copy_for_eval(Hair *hair_src, bool reference) -{ - int flags = LIB_ID_COPY_LOCALIZE; - - if (reference) { - flags |= LIB_ID_COPY_CD_REFERENCE; - } - - Hair *result = (Hair *)BKE_id_copy_ex(nullptr, &hair_src->id, nullptr, flags); - return result; -} - -static Hair *hair_evaluate_modifiers(struct Depsgraph *depsgraph, - struct Scene *scene, - Object *object, - Hair *hair_input) -{ - Hair *hair = hair_input; - - /* Modifier evaluation modes. */ - const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); - const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; - ModifierApplyFlag apply_flag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE; - const ModifierEvalContext mectx = {depsgraph, object, apply_flag}; - - /* Get effective list of modifiers to execute. Some effects like shape keys - * are added as virtual modifiers before the user created modifiers. */ - VirtualModifierData virtualModifierData; - ModifierData *md = BKE_modifiers_get_virtual_modifierlist(object, &virtualModifierData); - - /* Evaluate modifiers. */ - for (; md; md = md->next) { - const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast(md->type)); - - if (!BKE_modifier_is_enabled(scene, md, required_mode)) { - continue; - } - - if ((mti->type == eModifierTypeType_OnlyDeform) && - (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly)) { - /* Ensure we are not modifying the input. */ - if (hair == hair_input) { - hair = BKE_hair_copy_for_eval(hair, true); - } - - /* Ensure we are not overwriting referenced data. */ - CustomData_duplicate_referenced_layer_named(&hair->geometry.point_data, - CD_PROP_FLOAT3, - HAIR_ATTR_POSITION, - hair->geometry.point_size); - BKE_hair_update_customdata_pointers(hair); - - /* Created deformed coordinates array on demand. */ - mti->deformVerts(md, &mectx, nullptr, hair->geometry.position, hair->geometry.point_size); - } - } - - return hair; -} - -void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) -{ - /* Free any evaluated data and restore original data. */ - BKE_object_free_derived_caches(object); - - /* Evaluate modifiers. */ - Hair *hair = static_cast(object->data); - Hair *hair_eval = hair_evaluate_modifiers(depsgraph, scene, object, hair); - - /* Assign evaluated object. */ - const bool is_owned = (hair != hair_eval); - BKE_object_eval_assign_data(object, &hair_eval->id, is_owned); -} - -/* Draw Cache */ - -void (*BKE_hair_batch_cache_dirty_tag_cb)(Hair *hair, int mode) = nullptr; -void (*BKE_hair_batch_cache_free_cb)(Hair *hair) = nullptr; - -void BKE_hair_batch_cache_dirty_tag(Hair *hair, int mode) -{ - if (hair->batch_cache) { - BKE_hair_batch_cache_dirty_tag_cb(hair, mode); - } -} - -void BKE_hair_batch_cache_free(Hair *hair) -{ - if (hair->batch_cache) { - BKE_hair_batch_cache_free_cb(hair); - } -} diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index e6fd6c14d42..e9c8df76351 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -110,7 +110,7 @@ static void id_type_init(void) INIT_TYPE(ID_CF); INIT_TYPE(ID_WS); INIT_TYPE(ID_LP); - INIT_TYPE(ID_HA); + INIT_TYPE(ID_CV); INIT_TYPE(ID_PT); INIT_TYPE(ID_VO); INIT_TYPE(ID_SIM); @@ -237,7 +237,7 @@ uint64_t BKE_idtype_idcode_to_idfilter(const short idcode) CASE_IDFILTER(CU); CASE_IDFILTER(GD); CASE_IDFILTER(GR); - CASE_IDFILTER(HA); + CASE_IDFILTER(CV); CASE_IDFILTER(IM); CASE_IDFILTER(LA); CASE_IDFILTER(LS); @@ -286,7 +286,7 @@ short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter) CASE_IDFILTER(CU); CASE_IDFILTER(GD); CASE_IDFILTER(GR); - CASE_IDFILTER(HA); + CASE_IDFILTER(CV); CASE_IDFILTER(IM); CASE_IDFILTER(LA); CASE_IDFILTER(LS); @@ -334,7 +334,7 @@ int BKE_idtype_idcode_to_index(const short idcode) CASE_IDINDEX(CU); CASE_IDINDEX(GD); CASE_IDINDEX(GR); - CASE_IDINDEX(HA); + CASE_IDINDEX(CV); CASE_IDINDEX(IM); CASE_IDINDEX(IP); CASE_IDINDEX(KE); @@ -393,7 +393,7 @@ short BKE_idtype_idcode_from_index(const int index) CASE_IDCODE(CU); CASE_IDCODE(GD); CASE_IDCODE(GR); - CASE_IDCODE(HA); + CASE_IDCODE(CV); CASE_IDCODE(IM); CASE_IDCODE(IP); CASE_IDCODE(KE); diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index e73b53c4bf8..f69fba5b540 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -471,7 +471,7 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used) return ELEM(id_type_used, ID_MA); case ID_WS: return ELEM(id_type_used, ID_SCR, ID_SCE); - case ID_HA: + case ID_CV: return ELEM(id_type_used, ID_MA); case ID_PT: return ELEM(id_type_used, ID_MA); diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index e4e0466416a..a9de5b4a189 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -558,7 +558,7 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ case ID_ME: case ID_CU: case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: if (new_id) { /* Only affects us in case obdata was relinked (changed). */ diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 64731be57ac..53b1a9c9e16 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -643,8 +643,8 @@ ListBase *which_libbase(Main *bmain, short type) return &(bmain->cachefiles); case ID_WS: return &(bmain->workspaces); - case ID_HA: - return &(bmain->hairs); + case ID_CV: + return &(bmain->hair_curves); case ID_PT: return &(bmain->pointclouds); case ID_VO: @@ -688,7 +688,7 @@ int set_listbasepointers(Main *bmain, ListBase *lb[/*INDEX_ID_MAX*/]) lb[INDEX_ID_ME] = &(bmain->meshes); lb[INDEX_ID_CU] = &(bmain->curves); lb[INDEX_ID_MB] = &(bmain->metaballs); - lb[INDEX_ID_HA] = &(bmain->hairs); + lb[INDEX_ID_CV] = &(bmain->hair_curves); lb[INDEX_ID_PT] = &(bmain->pointclouds); lb[INDEX_ID_VO] = &(bmain->volumes); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 15469f910b4..1c1b2c2cd27 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -36,10 +36,10 @@ #include "DNA_anim_types.h" #include "DNA_collection_types.h" #include "DNA_curve_types.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" #include "DNA_defaults.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -341,9 +341,9 @@ Material ***BKE_object_material_array_p(Object *ob) bGPdata *gpd = ob->data; return &(gpd->mat); } - if (ob->type == OB_HAIR) { - Hair *hair = ob->data; - return &(hair->mat); + if (ob->type == OB_CURVES) { + Curves *curves = ob->data; + return &(curves->mat); } if (ob->type == OB_POINTCLOUD) { PointCloud *pointcloud = ob->data; @@ -374,9 +374,9 @@ short *BKE_object_material_len_p(Object *ob) bGPdata *gpd = ob->data; return &(gpd->totcol); } - if (ob->type == OB_HAIR) { - Hair *hair = ob->data; - return &(hair->totcol); + if (ob->type == OB_CURVES) { + Curves *curves = ob->data; + return &(curves->totcol); } if (ob->type == OB_POINTCLOUD) { PointCloud *pointcloud = ob->data; @@ -403,8 +403,8 @@ Material ***BKE_id_material_array_p(ID *id) return &(((MetaBall *)id)->mat); case ID_GD: return &(((bGPdata *)id)->mat); - case ID_HA: - return &(((Hair *)id)->mat); + case ID_CV: + return &(((Curves *)id)->mat); case ID_PT: return &(((PointCloud *)id)->mat); case ID_VO: @@ -429,8 +429,8 @@ short *BKE_id_material_len_p(ID *id) return &(((MetaBall *)id)->totcol); case ID_GD: return &(((bGPdata *)id)->totcol); - case ID_HA: - return &(((Hair *)id)->totcol); + case ID_CV: + return &(((Curves *)id)->totcol); case ID_PT: return &(((PointCloud *)id)->totcol); case ID_VO: @@ -454,7 +454,7 @@ static void material_data_index_remove_id(ID *id, short index) BKE_curve_material_index_remove((Curve *)id, index); break; case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: /* No material indices for these object data types. */ @@ -509,7 +509,7 @@ static void material_data_index_clear_id(ID *id) BKE_curve_material_index_clear((Curve *)id); break; case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: /* No material indices for these object data types. */ diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 04d60c096f2..8faae6efb26 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -89,6 +89,7 @@ #include "BKE_constraint.h" #include "BKE_crazyspace.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_deform.h" #include "BKE_displist.h" #include "BKE_duplilist.h" @@ -103,7 +104,6 @@ #include "BKE_gpencil.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_icons.h" #include "BKE_idprop.h" #include "BKE_idtype.h" @@ -1415,7 +1415,7 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) } /* Only geometry objects should be able to get modifiers T25291. */ - if (ELEM(ob->type, OB_POINTCLOUD, OB_VOLUME, OB_HAIR)) { + if (ELEM(ob->type, OB_POINTCLOUD, OB_VOLUME, OB_CURVES)) { return (mti->modifyGeometrySet != nullptr); } if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { @@ -2098,8 +2098,8 @@ static const char *get_obdata_defname(int type) return DATA_("Armature"); case OB_SPEAKER: return DATA_("Speaker"); - case OB_HAIR: - return DATA_("Hair"); + case OB_CURVES: + return DATA_("HairCurves"); case OB_POINTCLOUD: return DATA_("PointCloud"); case OB_VOLUME: @@ -2173,8 +2173,8 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) return BKE_lightprobe_add(bmain, name); case OB_GPENCIL: return BKE_gpencil_data_addnew(bmain, name); - case OB_HAIR: - return BKE_hair_add(bmain, name); + case OB_CURVES: + return BKE_curves_add(bmain, name); case OB_POINTCLOUD: return BKE_pointcloud_add_default(bmain, name); case OB_VOLUME: @@ -2211,8 +2211,8 @@ int BKE_object_obdata_to_type(const ID *id) return OB_ARMATURE; case ID_LP: return OB_LIGHTPROBE; - case ID_HA: - return OB_HAIR; + case ID_CV: + return OB_CURVES; case ID_PT: return OB_POINTCLOUD; case ID_VO: @@ -2729,8 +2729,8 @@ Object *BKE_object_duplicate(Main *bmain, Object *ob, uint dupflag, uint duplica id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; - case OB_HAIR: - if (dupflag & USER_DUP_HAIR) { + case OB_CURVES: + if (dupflag & USER_DUP_CURVES) { id_new = BKE_id_copy_for_duplicate(bmain, id_old, dupflag, copy_flags); } break; @@ -3624,8 +3624,8 @@ BoundBox *BKE_object_boundbox_get(Object *ob) case OB_GPENCIL: bb = BKE_gpencil_boundbox_get(ob); break; - case OB_HAIR: - bb = BKE_hair_boundbox_get(ob); + case OB_CURVES: + bb = BKE_curves_boundbox_get(ob); break; case OB_POINTCLOUD: bb = BKE_pointcloud_boundbox_get(ob); @@ -3826,8 +3826,8 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us } break; } - case OB_HAIR: { - BoundBox bb = *BKE_hair_boundbox_get(ob); + case OB_CURVES: { + BoundBox bb = *BKE_curves_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; @@ -4941,7 +4941,7 @@ bool BKE_object_supports_material_slots(struct Object *ob) OB_SURF, OB_FONT, OB_MBALL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME, OB_GPENCIL); diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 9c2b48303b2..803dde50d96 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -41,12 +41,12 @@ #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_effect.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_image.h" #include "BKE_key.h" #include "BKE_lattice.h" @@ -214,8 +214,8 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o BKE_gpencil_update_layer_transforms(depsgraph, ob); break; } - case OB_HAIR: - BKE_hair_data_update(depsgraph, scene, ob); + case OB_CURVES: + BKE_curves_data_update(depsgraph, scene, ob); break; case OB_POINTCLOUD: BKE_pointcloud_data_update(depsgraph, scene, ob); @@ -326,8 +326,8 @@ void BKE_object_data_batch_cache_dirty_tag(ID *object_data) case ID_GD: BKE_gpencil_batch_cache_dirty_tag((struct bGPdata *)object_data); break; - case ID_HA: - BKE_hair_batch_cache_dirty_tag((struct Hair *)object_data, BKE_HAIR_BATCH_DIRTY_ALL); + case ID_CV: + BKE_curves_batch_cache_dirty_tag((struct Curves *)object_data, BKE_CURVES_BATCH_DIRTY_ALL); break; case ID_PT: BKE_pointcloud_batch_cache_dirty_tag((struct PointCloud *)object_data, diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2ba66657499..90366f5b80d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2988,7 +2988,7 @@ static const char *dataname(short id_code) return "Data from CF"; case ID_WS: return "Data from WS"; - case ID_HA: + case ID_CV: return "Data from HA"; case ID_PT: return "Data from PT"; diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index ef146606ff0..87b5da09a60 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -32,11 +32,11 @@ #include "DNA_cachefile_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_fluid_types.h" #include "DNA_genfile.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_light_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -1120,10 +1120,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Hair and PointCloud attributes. */ - for (Hair *hair = bmain->hairs.first; hair != NULL; hair = hair->id.next) { - do_versions_point_attributes(&hair->geometry.point_data); - } + /* PointCloud attributes. */ for (PointCloud *pointcloud = bmain->pointclouds.first; pointcloud != NULL; pointcloud = pointcloud->id.next) { do_versions_point_attributes(&pointcloud->pdata); @@ -1422,10 +1419,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Hair and PointCloud attributes names. */ - LISTBASE_FOREACH (Hair *, hair, &bmain->hairs) { - do_versions_point_attribute_names(&hair->geometry.point_data); - } + /* PointCloud attributes names. */ LISTBASE_FOREACH (PointCloud *, pointcloud, &bmain->pointclouds) { do_versions_point_attribute_names(&pointcloud->pdata); } diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h index 8785eadf5f1..379ff923229 100644 --- a/source/blender/blentranslation/BLT_translation.h +++ b/source/blender/blentranslation/BLT_translation.h @@ -111,7 +111,7 @@ bool BLT_lang_is_ime_supported(void); #define BLT_I18NCONTEXT_ID_CURVE "Curve" #define BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE "FreestyleLineStyle" #define BLT_I18NCONTEXT_ID_GPENCIL "GPencil" -#define BLT_I18NCONTEXT_ID_HAIR "Hair" +#define BLT_I18NCONTEXT_ID_CURVES "Curves" #define BLT_I18NCONTEXT_ID_ID "ID" #define BLT_I18NCONTEXT_ID_IMAGE "Image" // #define BLT_I18NCONTEXT_ID_IPO "Ipo" /* DEPRECATED */ @@ -173,7 +173,7 @@ typedef struct { BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVE, "id_curve"), \ BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, "id_fs_linestyle"), \ BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_GPENCIL, "id_gpencil"), \ - BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_HAIR, "id_hair"), \ + BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVES, "id_curves"), \ BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ID, "id_id"), \ BLT_I18NCONTEXTS_ITEM( \ BLT_I18NCONTEXT_ID_IMAGE, \ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index b886d5a5b9a..ba1432d9ec8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -599,7 +599,7 @@ void DepsgraphNodeBuilder::build_id(ID *id) case ID_CU: case ID_LT: case ID_GD: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: build_object_data_geometry_datablock(id); @@ -894,7 +894,7 @@ void DepsgraphNodeBuilder::build_object_data(Object *object) case OB_MBALL: case OB_LATTICE: case OB_GPENCIL: - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: build_object_data_geometry(object); @@ -1563,7 +1563,7 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata) op_node->set_as_entry(); break; } - case ID_HA: { + case ID_CV: { op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL); op_node->set_as_entry(); break; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 97dae46c75f..26dd7bc1363 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -555,7 +555,7 @@ void DepsgraphRelationBuilder::build_id(ID *id) case ID_MB: case ID_CU: case ID_LT: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_GD: @@ -849,7 +849,7 @@ void DepsgraphRelationBuilder::build_object_data(Object *object) case OB_MBALL: case OB_LATTICE: case OB_GPENCIL: - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: { build_object_data_geometry(object); @@ -2301,7 +2301,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) } break; } - case ID_HA: + case ID_CV: break; case ID_PT: break; @@ -2925,7 +2925,7 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) continue; } int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE); - if ((ELEM(id_type, ID_ME, ID_HA, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) || + if ((ELEM(id_type, ID_ME, ID_CV, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) || (id_type == ID_CF && comp_node->type == NodeType::CACHE)) { rel_flag &= ~RELATION_FLAG_NO_FLUSH; } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index d9147d88045..b9ec01d729c 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -87,7 +87,7 @@ void depsgraph_geometry_tag_to_component(const ID *id, NodeType *component_type) bool is_selectable_data_id_type(const ID_Type id_type) { - return ELEM(id_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_GD, ID_HA, ID_PT, ID_VO); + return ELEM(id_type, ID_ME, ID_CU, ID_MB, ID_LT, ID_GD, ID_CV, ID_PT, ID_VO); } void depsgraph_select_tag_to_component_opcode(const ID *id, @@ -591,7 +591,7 @@ NodeType geometry_tag_to_component(const ID *id) case OB_LATTICE: case OB_MBALL: case OB_GPENCIL: - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: return NodeType::GEOMETRY; @@ -605,7 +605,7 @@ NodeType geometry_tag_to_component(const ID *id) case ID_CU: case ID_LT: case ID_MB: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_GR: diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index 17369f723ec..10507948246 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -127,7 +127,7 @@ void ObjectRuntimeBackup::restore_to_object(Object *object) } } } - else if (ELEM(object->type, OB_HAIR, OB_POINTCLOUD, OB_VOLUME)) { + else if (ELEM(object->type, OB_CURVES, OB_POINTCLOUD, OB_VOLUME)) { if (object->id.recalc & ID_RECALC_GEOMETRY) { /* Free evaluated caches. */ object->data = data_orig; diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 47d99963ef9..17feb39a072 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -86,9 +86,9 @@ set(SRC intern/mesh_extractors/extract_mesh_vbo_vcol.cc intern/mesh_extractors/extract_mesh_vbo_weights.cc intern/draw_cache_impl_curve.cc + intern/draw_cache_impl_curves.cc intern/draw_cache_impl_displist.c intern/draw_cache_impl_gpencil.c - intern/draw_cache_impl_hair.cc intern/draw_cache_impl_lattice.c intern/draw_cache_impl_mesh.c intern/draw_cache_impl_metaball.c diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index 80207523a65..8f02e96b168 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -56,7 +56,7 @@ #include "BLI_math_bits.h" #include "BLI_rect.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" @@ -248,25 +248,25 @@ static DRWShadingGroup *eevee_cryptomatte_shading_group_create(EEVEE_Data *vedat return grp; } -static void eevee_cryptomatte_hair_cache_populate(EEVEE_Data *vedata, - EEVEE_ViewLayerData *sldata, - Object *ob, - ParticleSystem *psys, - ModifierData *md, - Material *material) +static void eevee_cryptomatte_curves_cache_populate(EEVEE_Data *vedata, + EEVEE_ViewLayerData *sldata, + Object *ob, + ParticleSystem *psys, + ModifierData *md, + Material *material) { DRWShadingGroup *grp = eevee_cryptomatte_shading_group_create( vedata, sldata, ob, material, true); DRW_shgroup_hair_create_sub(ob, psys, md, grp, NULL); } -void EEVEE_cryptomatte_object_hair_cache_populate(EEVEE_Data *vedata, - EEVEE_ViewLayerData *sldata, - Object *ob) +void EEVEE_cryptomatte_object_curves_cache_populate(EEVEE_Data *vedata, + EEVEE_ViewLayerData *sldata, + Object *ob) { - BLI_assert(ob->type == OB_HAIR); - Material *material = BKE_object_material_get_eval(ob, HAIR_MATERIAL_NR); - eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, NULL, NULL, material); + BLI_assert(ob->type == OB_CURVES); + Material *material = BKE_object_material_get_eval(ob, CURVES_MATERIAL_NR); + eevee_cryptomatte_curves_cache_populate(vedata, sldata, ob, NULL, NULL, material); } void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, @@ -291,7 +291,7 @@ void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, continue; } Material *material = BKE_object_material_get_eval(ob, part->omat); - eevee_cryptomatte_hair_cache_populate(vedata, sldata, ob, psys, md, material); + eevee_cryptomatte_curves_cache_populate(vedata, sldata, ob, psys, md, material); } } } diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c index b453df284ed..64553acd228 100644 --- a/source/blender/draw/engines/eevee/eevee_data.c +++ b/source/blender/draw/engines/eevee/eevee_data.c @@ -177,7 +177,7 @@ static void *motion_blur_deform_data_get(EEVEE_MotionBlurData *mb, Object *ob, b if (hair) { EEVEE_HairMotionData *hair_step; /* Ugly, we allocate for each modifiers and just fill based on modifier index in the list. */ - int psys_len = (ob->type != OB_HAIR) ? BLI_listbase_count(&ob->modifiers) : 1; + int psys_len = (ob->type != OB_CURVES) ? BLI_listbase_count(&ob->modifiers) : 1; hair_step = MEM_callocN(sizeof(EEVEE_HairMotionData) + sizeof(hair_step->psys[0]) * psys_len, __func__); hair_step->psys_len = psys_len; diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index fc9b8b0cde4..9b6b5c5f08d 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -125,7 +125,7 @@ void EEVEE_cache_populate(void *vedata, Object *ob) if (ELEM(ob->type, OB_MESH, OB_SURF, OB_MBALL)) { EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow); } - else if (ob->type == OB_HAIR) { + else if (ob->type == OB_CURVES) { EEVEE_object_hair_cache_populate(vedata, sldata, ob, &cast_shadow); } else if (ob->type == OB_VOLUME) { diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index a027a29c813..b8586ee0f68 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -33,7 +33,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_modifier_types.h" #include "DNA_view3d_types.h" #include "DNA_world_types.h" @@ -925,7 +925,7 @@ void EEVEE_object_hair_cache_populate(EEVEE_Data *vedata, Object *ob, bool *cast_shadow) { - eevee_hair_cache_populate(vedata, sldata, ob, NULL, NULL, HAIR_MATERIAL_NR, cast_shadow); + eevee_hair_cache_populate(vedata, sldata, ob, NULL, NULL, CURVES_MATERIAL_NR, cast_shadow); } void EEVEE_materials_cache_finish(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 766e721b1b8..883d2eff852 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -1385,9 +1385,9 @@ void EEVEE_cryptomatte_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *s void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob); -void EEVEE_cryptomatte_object_hair_cache_populate(EEVEE_Data *vedata, - EEVEE_ViewLayerData *sldata, - Object *ob); +void EEVEE_cryptomatte_object_curves_cache_populate(EEVEE_Data *vedata, + EEVEE_ViewLayerData *sldata, + Object *ob); void EEVEE_cryptomatte_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); /** * Register the render passes needed for cryptomatte diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index e4e7f6fa4e3..2fd033b6745 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -244,10 +244,10 @@ void EEVEE_render_cache(void *vedata, EEVEE_cryptomatte_cache_populate(data, sldata, ob); } } - else if (ob->type == OB_HAIR) { + else if (ob->type == OB_CURVES) { EEVEE_object_hair_cache_populate(vedata, sldata, ob, &cast_shadow); if (do_cryptomatte) { - EEVEE_cryptomatte_object_hair_cache_populate(data, sldata, ob); + EEVEE_cryptomatte_object_curves_cache_populate(data, sldata, ob); } } else if (ob->type == OB_VOLUME) { diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 12db2bd02cf..54e8ef80854 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -262,7 +262,7 @@ static bool overlay_object_is_edit_mode(const OVERLAY_PrivateData *pd, const Obj return pd->ctx_mode == CTX_MODE_EDIT_METABALL; case OB_FONT: return pd->ctx_mode == CTX_MODE_EDIT_TEXT; - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: /* No edit mode yet. */ @@ -316,7 +316,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) OB_MBALL, OB_FONT, OB_GPENCIL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME); const bool draw_surface = (ob->dt >= OB_WIRE) && (renderable || (ob->dt == OB_WIRE)); diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index a2362cd8850..de0003625a2 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -484,7 +484,7 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons texcosize = mb->size; break; } - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: { /* No user defined texture space support. */ diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 0dfc3c4b119..8773c78e82f 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -34,8 +34,8 @@ #include "BKE_paint.h" #include "BKE_particle.h" +#include "DNA_curves_types.h" #include "DNA_fluid_types.h" -#include "DNA_hair_types.h" #include "DNA_image_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" @@ -419,9 +419,9 @@ void workbench_cache_populate(void *ved, Object *ob) workbench_shadow_cache_populate(vedata, ob, has_transp_mat); } } - else if (ob->type == OB_HAIR) { + else if (ob->type == OB_CURVES) { int color_type = workbench_color_type_get(wpd, ob, NULL, NULL, NULL); - workbench_cache_hair_populate(wpd, ob, NULL, NULL, color_type, false, HAIR_MATERIAL_NR); + workbench_cache_hair_populate(wpd, ob, NULL, NULL, color_type, false, CURVES_MATERIAL_NR); } else if (ob->type == OB_VOLUME) { if (wpd->shading.type != OB_WIRE) { diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a4564ce2668..430b28f1224 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -19,7 +19,7 @@ */ #include "DNA_curve_types.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" @@ -835,7 +835,7 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) return NULL; case OB_MBALL: return DRW_cache_mball_edge_detection_get(ob, r_is_manifold); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return NULL; @@ -859,7 +859,7 @@ GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob) return NULL; case OB_MBALL: return DRW_cache_mball_face_wireframe_get(ob); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return DRW_pointcloud_batch_cache_get_dots(ob); @@ -886,7 +886,7 @@ GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob) return NULL; case OB_MBALL: return NULL; - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return NULL; @@ -910,7 +910,7 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob) return NULL; case OB_MBALL: return DRW_cache_mball_surface_get(ob); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return DRW_cache_pointcloud_surface_get(ob); @@ -935,7 +935,7 @@ GPUVertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob) return DRW_curve_batch_cache_pos_vertbuf_get(ob->data); case OB_MBALL: return DRW_mball_batch_cache_pos_vertbuf_get(ob); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return NULL; @@ -967,8 +967,8 @@ int DRW_cache_object_material_count_get(struct Object *ob) return DRW_curve_material_count_get(ob->data); case OB_MBALL: return DRW_metaball_material_count_get(ob->data); - case OB_HAIR: - return DRW_hair_material_count_get(ob->data); + case OB_CURVES: + return DRW_curves_material_count_get(ob->data); case OB_POINTCLOUD: return DRW_pointcloud_material_count_get(ob->data); case OB_VOLUME: @@ -994,7 +994,7 @@ GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob, return NULL; case OB_MBALL: return DRW_cache_mball_surface_shaded_get(ob, gpumat_array, gpumat_array_len); - case OB_HAIR: + case OB_CURVES: return NULL; case OB_POINTCLOUD: return DRW_cache_pointcloud_surface_shaded_get(ob, gpumat_array, gpumat_array_len); @@ -3403,8 +3403,8 @@ void drw_batch_cache_validate(Object *ob) case OB_LATTICE: DRW_lattice_batch_cache_validate((Lattice *)ob->data); break; - case OB_HAIR: - DRW_hair_batch_cache_validate((Hair *)ob->data); + case OB_CURVES: + DRW_curves_batch_cache_validate((Curves *)ob->data); break; case OB_POINTCLOUD: DRW_pointcloud_batch_cache_validate((PointCloud *)ob->data); diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 30e5a10df91..b94dd466364 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -246,14 +246,14 @@ struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUBatch *DRW_cache_mball_face_wireframe_get(struct Object *ob); struct GPUBatch *DRW_cache_mball_edge_detection_get(struct Object *ob, bool *r_is_manifold); -/* Hair */ - -struct GPUBatch *DRW_cache_hair_surface_get(struct Object *ob); -struct GPUBatch **DRW_cache_hair_surface_shaded_get(struct Object *ob, - struct GPUMaterial **gpumat_array, - uint gpumat_array_len); -struct GPUBatch *DRW_cache_hair_face_wireframe_get(struct Object *ob); -struct GPUBatch *DRW_cache_hair_edge_detection_get(struct Object *ob, bool *r_is_manifold); +/* Curves */ + +struct GPUBatch *DRW_cache_curves_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_curves_surface_shaded_get(struct Object *ob, + struct GPUMaterial **gpumat_array, + uint gpumat_array_len); +struct GPUBatch *DRW_cache_curves_face_wireframe_get(struct Object *ob); +struct GPUBatch *DRW_cache_curves_edge_detection_get(struct Object *ob, bool *r_is_manifold); /* PointCloud */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 6a2f4b91ad1..9c6814d910e 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -33,7 +33,7 @@ struct ParticleSystem; struct TaskGraph; struct Curve; -struct Hair; +struct Curves; struct Lattice; struct Mesh; struct MetaBall; @@ -73,9 +73,9 @@ void DRW_particle_batch_cache_free(struct ParticleSystem *psys); void DRW_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd); void DRW_gpencil_batch_cache_free(struct bGPdata *gpd); -void DRW_hair_batch_cache_dirty_tag(struct Hair *hair, int mode); -void DRW_hair_batch_cache_validate(struct Hair *hair); -void DRW_hair_batch_cache_free(struct Hair *hair); +void DRW_curves_batch_cache_dirty_tag(struct Curves *curves, int mode); +void DRW_curves_batch_cache_validate(struct Curves *curves); +void DRW_curves_batch_cache_free(struct Curves *curves); void DRW_pointcloud_batch_cache_dirty_tag(struct PointCloud *pointcloud, int mode); void DRW_pointcloud_batch_cache_validate(struct PointCloud *pointcloud); @@ -188,7 +188,7 @@ struct GPUBatch *DRW_lattice_batch_cache_get_edit_verts(struct Lattice *lt); /** \name Hair * \{ */ -int DRW_hair_material_count_get(struct Hair *hair); +int DRW_curves_material_count_get(struct Curves *curves); /** \} */ diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc new file mode 100644 index 00000000000..8ec97495fcf --- /dev/null +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -0,0 +1,389 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2017 by Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup draw + * + * \brief Hair API for render engines + */ + +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math_base.h" +#include "BLI_math_vec_types.hh" +#include "BLI_math_vector.h" +#include "BLI_math_vector.hh" +#include "BLI_span.hh" +#include "BLI_utildefines.h" + +#include "DNA_curves_types.h" +#include "DNA_object_types.h" + +#include "BKE_curves.h" + +#include "GPU_batch.h" +#include "GPU_material.h" +#include "GPU_texture.h" + +#include "draw_cache_impl.h" /* own include */ +#include "draw_hair_private.h" /* own include */ + +using blender::float3; +using blender::IndexRange; +using blender::Span; + +static void curves_batch_cache_clear(Curves *curves); + +/* ---------------------------------------------------------------------- */ +/* Hair GPUBatch Cache */ + +struct HairBatchCache { + ParticleHairCache hair; + + /* settings to determine if cache is invalid */ + bool is_dirty; +}; + +/* GPUBatch cache management. */ + +static bool curves_batch_cache_valid(Curves *curves) +{ + HairBatchCache *cache = static_cast(curves->batch_cache); + return (cache && cache->is_dirty == false); +} + +static void curves_batch_cache_init(Curves *curves) +{ + HairBatchCache *cache = static_cast(curves->batch_cache); + + if (!cache) { + cache = MEM_cnew(__func__); + curves->batch_cache = cache; + } + else { + memset(cache, 0, sizeof(*cache)); + } + + cache->is_dirty = false; +} + +void DRW_curves_batch_cache_validate(Curves *curves) +{ + if (!curves_batch_cache_valid(curves)) { + curves_batch_cache_clear(curves); + curves_batch_cache_init(curves); + } +} + +static HairBatchCache *curves_batch_cache_get(Curves *curves) +{ + DRW_curves_batch_cache_validate(curves); + return static_cast(curves->batch_cache); +} + +void DRW_curves_batch_cache_dirty_tag(Curves *curves, int mode) +{ + HairBatchCache *cache = static_cast(curves->batch_cache); + if (cache == nullptr) { + return; + } + switch (mode) { + case BKE_CURVES_BATCH_DIRTY_ALL: + cache->is_dirty = true; + break; + default: + BLI_assert(0); + } +} + +static void curves_batch_cache_clear(Curves *curves) +{ + HairBatchCache *cache = static_cast(curves->batch_cache); + if (!cache) { + return; + } + + particle_batch_cache_clear_hair(&cache->hair); +} + +void DRW_curves_batch_cache_free(Curves *curves) +{ + curves_batch_cache_clear(curves); + MEM_SAFE_FREE(curves->batch_cache); +} + +static void ensure_seg_pt_count(Curves *curves, ParticleHairCache *curves_cache) +{ + if ((curves_cache->pos != nullptr && curves_cache->indices != nullptr) || + (curves_cache->proc_point_buf != nullptr)) { + return; + } + + curves_cache->strands_len = curves->geometry.curve_size; + curves_cache->elems_len = curves->geometry.point_size + curves->geometry.curve_size; + curves_cache->point_len = curves->geometry.point_size; +} + +static void curves_batch_cache_fill_segments_proc_pos(Curves *curves, + GPUVertBufRaw *attr_step, + GPUVertBufRaw *length_step) +{ + /* TODO: use hair radius layer if available. */ + const int curve_size = curves->geometry.curve_size; + Span offsets{curves->geometry.offsets, curves->geometry.curve_size + 1}; + + Span positions{(float3 *)curves->geometry.position, curves->geometry.point_size}; + + for (const int i : IndexRange(curve_size)) { + const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); + + Span spline_positions = positions.slice(curve_range); + float total_len = 0.0f; + float *seg_data_first; + for (const int i_spline : spline_positions.index_range()) { + float *seg_data = (float *)GPU_vertbuf_raw_step(attr_step); + copy_v3_v3(seg_data, spline_positions[i_spline]); + if (i_spline == 0) { + seg_data_first = seg_data; + } + else { + total_len += blender::math::distance(spline_positions[i_spline - 1], + spline_positions[i_spline]); + } + seg_data[3] = total_len; + } + /* Assign length value. */ + *(float *)GPU_vertbuf_raw_step(length_step) = total_len; + if (total_len > 0.0f) { + /* Divide by total length to have a [0-1] number. */ + for ([[maybe_unused]] const int i_spline : spline_positions.index_range()) { + seg_data_first[3] /= total_len; + seg_data_first += 4; + } + } + } +} + +static void curves_batch_cache_ensure_procedural_pos(Curves *curves, + ParticleHairCache *cache, + GPUMaterial *gpu_material) +{ + if (cache->proc_point_buf == nullptr) { + /* initialize vertex format */ + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "posTime", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + + cache->proc_point_buf = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); + + GPUVertBufRaw point_step; + GPU_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &point_step); + + GPUVertFormat length_format = {0}; + uint length_id = GPU_vertformat_attr_add( + &length_format, "hairLength", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + + cache->proc_length_buf = GPU_vertbuf_create_with_format(&length_format); + GPU_vertbuf_data_alloc(cache->proc_length_buf, cache->strands_len); + + GPUVertBufRaw length_step; + GPU_vertbuf_attr_get_raw_data(cache->proc_length_buf, length_id, &length_step); + + curves_batch_cache_fill_segments_proc_pos(curves, &point_step, &length_step); + + /* Create vbo immediately to bind to texture buffer. */ + GPU_vertbuf_use(cache->proc_point_buf); + cache->point_tex = GPU_texture_create_from_vertbuf("hair_point", cache->proc_point_buf); + } + + if (gpu_material && cache->proc_length_buf != nullptr && cache->length_tex) { + ListBase gpu_attrs = GPU_material_attributes(gpu_material); + LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &gpu_attrs) { + if (attr->type == CD_HAIRLENGTH) { + GPU_vertbuf_use(cache->proc_length_buf); + cache->length_tex = GPU_texture_create_from_vertbuf("hair_length", cache->proc_length_buf); + break; + } + } + } +} + +static void curves_batch_cache_fill_strands_data(Curves *curves, + GPUVertBufRaw *data_step, + GPUVertBufRaw *seg_step) +{ + const int curve_size = curves->geometry.curve_size; + Span offsets{curves->geometry.offsets, curves->geometry.curve_size + 1}; + + for (const int i : IndexRange(curve_size)) { + const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); + + *(uint *)GPU_vertbuf_raw_step(data_step) = curve_range.start(); + *(ushort *)GPU_vertbuf_raw_step(seg_step) = curve_range.size() - 1; + } +} + +static void curves_batch_cache_ensure_procedural_strand_data(Curves *curves, + ParticleHairCache *cache) +{ + GPUVertBufRaw data_step, seg_step; + + GPUVertFormat format_data = {0}; + uint data_id = GPU_vertformat_attr_add(&format_data, "data", GPU_COMP_U32, 1, GPU_FETCH_INT); + + GPUVertFormat format_seg = {0}; + uint seg_id = GPU_vertformat_attr_add(&format_seg, "data", GPU_COMP_U16, 1, GPU_FETCH_INT); + + /* Strand Data */ + cache->proc_strand_buf = GPU_vertbuf_create_with_format(&format_data); + GPU_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); + + cache->proc_strand_seg_buf = GPU_vertbuf_create_with_format(&format_seg); + GPU_vertbuf_data_alloc(cache->proc_strand_seg_buf, cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_strand_seg_buf, seg_id, &seg_step); + + curves_batch_cache_fill_strands_data(curves, &data_step, &seg_step); + + /* Create vbo immediately to bind to texture buffer. */ + GPU_vertbuf_use(cache->proc_strand_buf); + cache->strand_tex = GPU_texture_create_from_vertbuf("curves_strand", cache->proc_strand_buf); + + GPU_vertbuf_use(cache->proc_strand_seg_buf); + cache->strand_seg_tex = GPU_texture_create_from_vertbuf("curves_strand_seg", + cache->proc_strand_seg_buf); +} + +static void curves_batch_cache_ensure_procedural_final_points(ParticleHairCache *cache, int subdiv) +{ + /* Same format as point_tex. */ + GPUVertFormat format = {0}; + GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + + cache->final[subdiv].proc_buf = GPU_vertbuf_create_with_format_ex(&format, + GPU_USAGE_DEVICE_ONLY); + + /* Create a destination buffer for the transform feedback. Sized appropriately */ + /* Those are points! not line segments. */ + GPU_vertbuf_data_alloc(cache->final[subdiv].proc_buf, + cache->final[subdiv].strands_res * cache->strands_len); + + /* Create vbo immediately to bind to texture buffer. */ + GPU_vertbuf_use(cache->final[subdiv].proc_buf); + + cache->final[subdiv].proc_tex = GPU_texture_create_from_vertbuf("hair_proc", + cache->final[subdiv].proc_buf); +} + +static void curves_batch_cache_fill_segments_indices(Curves *curves, + const int res, + GPUIndexBufBuilder *elb) +{ + const int curve_size = curves->geometry.curve_size; + + uint curr_point = 0; + + for ([[maybe_unused]] const int i : IndexRange(curve_size)) { + for (int k = 0; k < res; k++) { + GPU_indexbuf_add_generic_vert(elb, curr_point++); + } + GPU_indexbuf_add_primitive_restart(elb); + } +} + +static void curves_batch_cache_ensure_procedural_indices(Curves *curves, + ParticleHairCache *cache, + int thickness_res, + int subdiv) +{ + BLI_assert(thickness_res <= MAX_THICKRES); /* Cylinder strip not currently supported. */ + + if (cache->final[subdiv].proc_hairs[thickness_res - 1] != nullptr) { + return; + } + + int verts_per_hair = cache->final[subdiv].strands_res * thickness_res; + /* +1 for primitive restart */ + int element_count = (verts_per_hair + 1) * cache->strands_len; + GPUPrimType prim_type = (thickness_res == 1) ? GPU_PRIM_LINE_STRIP : GPU_PRIM_TRI_STRIP; + + static GPUVertFormat format = {0}; + GPU_vertformat_clear(&format); + + /* initialize vertex format */ + GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); + + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); + + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, prim_type, element_count, element_count); + + curves_batch_cache_fill_segments_indices(curves, verts_per_hair, &elb); + + cache->final[subdiv].proc_hairs[thickness_res - 1] = GPU_batch_create_ex( + prim_type, vbo, GPU_indexbuf_build(&elb), GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); +} + +bool hair_ensure_procedural_data(Object *object, + ParticleHairCache **r_hair_cache, + GPUMaterial *gpu_material, + int subdiv, + int thickness_res) +{ + bool need_ft_update = false; + Curves *curves = static_cast(object->data); + + HairBatchCache *cache = curves_batch_cache_get(curves); + *r_hair_cache = &cache->hair; + + const int steps = 2; /* TODO: don't hard-code? */ + (*r_hair_cache)->final[subdiv].strands_res = 1 << (steps + subdiv); + + /* Refreshed on combing and simulation. */ + if ((*r_hair_cache)->proc_point_buf == nullptr) { + ensure_seg_pt_count(curves, &cache->hair); + curves_batch_cache_ensure_procedural_pos(curves, &cache->hair, gpu_material); + need_ft_update = true; + } + + /* Refreshed if active layer or custom data changes. */ + if ((*r_hair_cache)->strand_tex == nullptr) { + curves_batch_cache_ensure_procedural_strand_data(curves, &cache->hair); + } + + /* Refreshed only on subdiv count change. */ + if ((*r_hair_cache)->final[subdiv].proc_buf == nullptr) { + curves_batch_cache_ensure_procedural_final_points(&cache->hair, subdiv); + need_ft_update = true; + } + if ((*r_hair_cache)->final[subdiv].proc_hairs[thickness_res - 1] == nullptr) { + curves_batch_cache_ensure_procedural_indices(curves, &cache->hair, thickness_res, subdiv); + } + + return need_ft_update; +} + +int DRW_curves_material_count_get(Curves *curves) +{ + return max_ii(1, curves->totcol); +} diff --git a/source/blender/draw/intern/draw_cache_impl_hair.cc b/source/blender/draw/intern/draw_cache_impl_hair.cc deleted file mode 100644 index cdc06b121b0..00000000000 --- a/source/blender/draw/intern/draw_cache_impl_hair.cc +++ /dev/null @@ -1,388 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2017 by Blender Foundation. - * All rights reserved. - */ - -/** \file - * \ingroup draw - * - * \brief Hair API for render engines - */ - -#include - -#include "MEM_guardedalloc.h" - -#include "BLI_listbase.h" -#include "BLI_math_base.h" -#include "BLI_math_vec_types.hh" -#include "BLI_math_vector.h" -#include "BLI_math_vector.hh" -#include "BLI_span.hh" -#include "BLI_utildefines.h" - -#include "DNA_hair_types.h" -#include "DNA_object_types.h" - -#include "BKE_hair.h" - -#include "GPU_batch.h" -#include "GPU_material.h" -#include "GPU_texture.h" - -#include "draw_cache_impl.h" /* own include */ -#include "draw_hair_private.h" /* own include */ - -using blender::float3; -using blender::IndexRange; -using blender::Span; - -static void hair_batch_cache_clear(Hair *hair); - -/* ---------------------------------------------------------------------- */ -/* Hair GPUBatch Cache */ - -struct HairBatchCache { - ParticleHairCache hair; - - /* settings to determine if cache is invalid */ - bool is_dirty; -}; - -/* GPUBatch cache management. */ - -static bool hair_batch_cache_valid(Hair *hair) -{ - HairBatchCache *cache = static_cast(hair->batch_cache); - return (cache && cache->is_dirty == false); -} - -static void hair_batch_cache_init(Hair *hair) -{ - HairBatchCache *cache = static_cast(hair->batch_cache); - - if (!cache) { - cache = MEM_cnew(__func__); - hair->batch_cache = cache; - } - else { - memset(cache, 0, sizeof(*cache)); - } - - cache->is_dirty = false; -} - -void DRW_hair_batch_cache_validate(Hair *hair) -{ - if (!hair_batch_cache_valid(hair)) { - hair_batch_cache_clear(hair); - hair_batch_cache_init(hair); - } -} - -static HairBatchCache *hair_batch_cache_get(Hair *hair) -{ - DRW_hair_batch_cache_validate(hair); - return static_cast(hair->batch_cache); -} - -void DRW_hair_batch_cache_dirty_tag(Hair *hair, int mode) -{ - HairBatchCache *cache = static_cast(hair->batch_cache); - if (cache == nullptr) { - return; - } - switch (mode) { - case BKE_HAIR_BATCH_DIRTY_ALL: - cache->is_dirty = true; - break; - default: - BLI_assert(0); - } -} - -static void hair_batch_cache_clear(Hair *hair) -{ - HairBatchCache *cache = static_cast(hair->batch_cache); - if (!cache) { - return; - } - - particle_batch_cache_clear_hair(&cache->hair); -} - -void DRW_hair_batch_cache_free(Hair *hair) -{ - hair_batch_cache_clear(hair); - MEM_SAFE_FREE(hair->batch_cache); -} - -static void ensure_seg_pt_count(Hair *hair, ParticleHairCache *hair_cache) -{ - if ((hair_cache->pos != nullptr && hair_cache->indices != nullptr) || - (hair_cache->proc_point_buf != nullptr)) { - return; - } - - hair_cache->strands_len = hair->geometry.curve_size; - hair_cache->elems_len = hair->geometry.point_size + hair->geometry.curve_size; - hair_cache->point_len = hair->geometry.point_size; -} - -static void hair_batch_cache_fill_segments_proc_pos(Hair *hair, - GPUVertBufRaw *attr_step, - GPUVertBufRaw *length_step) -{ - /* TODO: use hair radius layer if available. */ - const int curve_size = hair->geometry.curve_size; - Span offsets{hair->geometry.offsets, hair->geometry.curve_size + 1}; - - Span positions{(float3 *)hair->geometry.position, hair->geometry.point_size}; - - for (const int i : IndexRange(curve_size)) { - const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); - - Span spline_positions = positions.slice(curve_range); - float total_len = 0.0f; - float *seg_data_first; - for (const int i_spline : spline_positions.index_range()) { - float *seg_data = (float *)GPU_vertbuf_raw_step(attr_step); - copy_v3_v3(seg_data, spline_positions[i_spline]); - if (i_spline == 0) { - seg_data_first = seg_data; - } - else { - total_len += blender::math::distance(spline_positions[i_spline - 1], - spline_positions[i_spline]); - } - seg_data[3] = total_len; - } - /* Assign length value. */ - *(float *)GPU_vertbuf_raw_step(length_step) = total_len; - if (total_len > 0.0f) { - /* Divide by total length to have a [0-1] number. */ - for ([[maybe_unused]] const int i_spline : spline_positions.index_range()) { - seg_data_first[3] /= total_len; - seg_data_first += 4; - } - } - } -} - -static void hair_batch_cache_ensure_procedural_pos(Hair *hair, - ParticleHairCache *cache, - GPUMaterial *gpu_material) -{ - if (cache->proc_point_buf == nullptr) { - /* initialize vertex format */ - GPUVertFormat format = {0}; - uint pos_id = GPU_vertformat_attr_add(&format, "posTime", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - - cache->proc_point_buf = GPU_vertbuf_create_with_format(&format); - GPU_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); - - GPUVertBufRaw point_step; - GPU_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &point_step); - - GPUVertFormat length_format = {0}; - uint length_id = GPU_vertformat_attr_add( - &length_format, "hairLength", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); - - cache->proc_length_buf = GPU_vertbuf_create_with_format(&length_format); - GPU_vertbuf_data_alloc(cache->proc_length_buf, cache->strands_len); - - GPUVertBufRaw length_step; - GPU_vertbuf_attr_get_raw_data(cache->proc_length_buf, length_id, &length_step); - - hair_batch_cache_fill_segments_proc_pos(hair, &point_step, &length_step); - - /* Create vbo immediately to bind to texture buffer. */ - GPU_vertbuf_use(cache->proc_point_buf); - cache->point_tex = GPU_texture_create_from_vertbuf("hair_point", cache->proc_point_buf); - } - - if (gpu_material && cache->proc_length_buf != nullptr && cache->length_tex) { - ListBase gpu_attrs = GPU_material_attributes(gpu_material); - LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &gpu_attrs) { - if (attr->type == CD_HAIRLENGTH) { - GPU_vertbuf_use(cache->proc_length_buf); - cache->length_tex = GPU_texture_create_from_vertbuf("hair_length", cache->proc_length_buf); - break; - } - } - } -} - -static void hair_batch_cache_fill_strands_data(Hair *hair, - GPUVertBufRaw *data_step, - GPUVertBufRaw *seg_step) -{ - const int curve_size = hair->geometry.curve_size; - Span offsets{hair->geometry.offsets, hair->geometry.curve_size + 1}; - - for (const int i : IndexRange(curve_size)) { - const IndexRange curve_range(offsets[i], offsets[i + 1] - offsets[i]); - - *(uint *)GPU_vertbuf_raw_step(data_step) = curve_range.start(); - *(ushort *)GPU_vertbuf_raw_step(seg_step) = curve_range.size() - 1; - } -} - -static void hair_batch_cache_ensure_procedural_strand_data(Hair *hair, ParticleHairCache *cache) -{ - GPUVertBufRaw data_step, seg_step; - - GPUVertFormat format_data = {0}; - uint data_id = GPU_vertformat_attr_add(&format_data, "data", GPU_COMP_U32, 1, GPU_FETCH_INT); - - GPUVertFormat format_seg = {0}; - uint seg_id = GPU_vertformat_attr_add(&format_seg, "data", GPU_COMP_U16, 1, GPU_FETCH_INT); - - /* Strand Data */ - cache->proc_strand_buf = GPU_vertbuf_create_with_format(&format_data); - GPU_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); - GPU_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); - - cache->proc_strand_seg_buf = GPU_vertbuf_create_with_format(&format_seg); - GPU_vertbuf_data_alloc(cache->proc_strand_seg_buf, cache->strands_len); - GPU_vertbuf_attr_get_raw_data(cache->proc_strand_seg_buf, seg_id, &seg_step); - - hair_batch_cache_fill_strands_data(hair, &data_step, &seg_step); - - /* Create vbo immediately to bind to texture buffer. */ - GPU_vertbuf_use(cache->proc_strand_buf); - cache->strand_tex = GPU_texture_create_from_vertbuf("hair_strand", cache->proc_strand_buf); - - GPU_vertbuf_use(cache->proc_strand_seg_buf); - cache->strand_seg_tex = GPU_texture_create_from_vertbuf("hair_strand_seg", - cache->proc_strand_seg_buf); -} - -static void hair_batch_cache_ensure_procedural_final_points(ParticleHairCache *cache, int subdiv) -{ - /* Same format as point_tex. */ - GPUVertFormat format = {0}; - GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - - cache->final[subdiv].proc_buf = GPU_vertbuf_create_with_format_ex(&format, - GPU_USAGE_DEVICE_ONLY); - - /* Create a destination buffer for the transform feedback. Sized appropriately */ - /* Those are points! not line segments. */ - GPU_vertbuf_data_alloc(cache->final[subdiv].proc_buf, - cache->final[subdiv].strands_res * cache->strands_len); - - /* Create vbo immediately to bind to texture buffer. */ - GPU_vertbuf_use(cache->final[subdiv].proc_buf); - - cache->final[subdiv].proc_tex = GPU_texture_create_from_vertbuf("hair_proc", - cache->final[subdiv].proc_buf); -} - -static void hair_batch_cache_fill_segments_indices(Hair *hair, - const int res, - GPUIndexBufBuilder *elb) -{ - const int curve_size = hair->geometry.curve_size; - - uint curr_point = 0; - - for ([[maybe_unused]] const int i : IndexRange(curve_size)) { - for (int k = 0; k < res; k++) { - GPU_indexbuf_add_generic_vert(elb, curr_point++); - } - GPU_indexbuf_add_primitive_restart(elb); - } -} - -static void hair_batch_cache_ensure_procedural_indices(Hair *hair, - ParticleHairCache *cache, - int thickness_res, - int subdiv) -{ - BLI_assert(thickness_res <= MAX_THICKRES); /* Cylinder strip not currently supported. */ - - if (cache->final[subdiv].proc_hairs[thickness_res - 1] != nullptr) { - return; - } - - int verts_per_hair = cache->final[subdiv].strands_res * thickness_res; - /* +1 for primitive restart */ - int element_count = (verts_per_hair + 1) * cache->strands_len; - GPUPrimType prim_type = (thickness_res == 1) ? GPU_PRIM_LINE_STRIP : GPU_PRIM_TRI_STRIP; - - static GPUVertFormat format = {0}; - GPU_vertformat_clear(&format); - - /* initialize vertex format */ - GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); - - GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); - GPU_vertbuf_data_alloc(vbo, 1); - - GPUIndexBufBuilder elb; - GPU_indexbuf_init_ex(&elb, prim_type, element_count, element_count); - - hair_batch_cache_fill_segments_indices(hair, verts_per_hair, &elb); - - cache->final[subdiv].proc_hairs[thickness_res - 1] = GPU_batch_create_ex( - prim_type, vbo, GPU_indexbuf_build(&elb), GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); -} - -bool hair_ensure_procedural_data(Object *object, - ParticleHairCache **r_hair_cache, - GPUMaterial *gpu_material, - int subdiv, - int thickness_res) -{ - bool need_ft_update = false; - Hair *hair = static_cast(object->data); - - HairBatchCache *cache = hair_batch_cache_get(hair); - *r_hair_cache = &cache->hair; - - const int steps = 2; /* TODO: don't hard-code? */ - (*r_hair_cache)->final[subdiv].strands_res = 1 << (steps + subdiv); - - /* Refreshed on combing and simulation. */ - if ((*r_hair_cache)->proc_point_buf == nullptr) { - ensure_seg_pt_count(hair, &cache->hair); - hair_batch_cache_ensure_procedural_pos(hair, &cache->hair, gpu_material); - need_ft_update = true; - } - - /* Refreshed if active layer or custom data changes. */ - if ((*r_hair_cache)->strand_tex == nullptr) { - hair_batch_cache_ensure_procedural_strand_data(hair, &cache->hair); - } - - /* Refreshed only on subdiv count change. */ - if ((*r_hair_cache)->final[subdiv].proc_buf == nullptr) { - hair_batch_cache_ensure_procedural_final_points(&cache->hair, subdiv); - need_ft_update = true; - } - if ((*r_hair_cache)->final[subdiv].proc_hairs[thickness_res - 1] == nullptr) { - hair_batch_cache_ensure_procedural_indices(hair, &cache->hair, thickness_res, subdiv); - } - - return need_ft_update; -} - -int DRW_hair_material_count_get(Hair *hair) -{ - return max_ii(1, hair->totcol); -} diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 65afc5ed3d8..82b830f6799 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -431,7 +431,7 @@ bool DRW_object_is_flat(Object *ob, int *r_axis) OB_SURF, OB_FONT, OB_MBALL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME)) { /* Non-meshes object cannot be considered as flat. */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1249004eda0..039fae43329 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -35,11 +35,11 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_duplilist.h" #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_gpencil.h" -#include "BKE_hair.h" #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_mball.h" @@ -2948,8 +2948,8 @@ void DRW_engines_register(void) BKE_gpencil_batch_cache_dirty_tag_cb = DRW_gpencil_batch_cache_dirty_tag; BKE_gpencil_batch_cache_free_cb = DRW_gpencil_batch_cache_free; - BKE_hair_batch_cache_dirty_tag_cb = DRW_hair_batch_cache_dirty_tag; - BKE_hair_batch_cache_free_cb = DRW_hair_batch_cache_free; + BKE_curves_batch_cache_dirty_tag_cb = DRW_curves_batch_cache_dirty_tag; + BKE_curves_batch_cache_free_cb = DRW_curves_batch_cache_free; BKE_pointcloud_batch_cache_dirty_tag_cb = DRW_pointcloud_batch_cache_dirty_tag; BKE_pointcloud_batch_cache_free_cb = DRW_pointcloud_batch_cache_free; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 5afb9334612..a697fd2fc96 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -35,8 +35,8 @@ #include "DNA_armature_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" #include "DNA_light_types.h" @@ -700,8 +700,8 @@ static int acf_object_icon(bAnimListElem *ale) return ICON_OUTLINER_OB_FONT; case OB_SURF: return ICON_OUTLINER_OB_SURFACE; - case OB_HAIR: - return ICON_OUTLINER_OB_HAIR; + case OB_CURVES: + return ICON_OUTLINER_OB_CURVES; case OB_POINTCLOUD: return ICON_OUTLINER_OB_POINTCLOUD; case OB_VOLUME: @@ -2813,15 +2813,15 @@ static bAnimChannelType ACF_DSSPK = { /* Hair Expander ------------------------------------------- */ /* TODO: just get this from RNA? */ -static int acf_dshair_icon(bAnimListElem *UNUSED(ale)) +static int acf_dscurves_icon(bAnimListElem *UNUSED(ale)) { - return ICON_HAIR_DATA; + return ICON_CURVES_DATA; } /* Get the appropriate flag(s) for the setting when it is valid. */ -static int acf_dshair_setting_flag(bAnimContext *UNUSED(ac), - eAnimChannel_Settings setting, - bool *neg) +static int acf_dscurves_setting_flag(bAnimContext *UNUSED(ac), + eAnimChannel_Settings setting, + bool *neg) { /* clear extra return data first */ *neg = false; @@ -2846,22 +2846,24 @@ static int acf_dshair_setting_flag(bAnimContext *UNUSED(ac), } /* get pointer to the setting */ -static void *acf_dshair_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) +static void *acf_dscurves_setting_ptr(bAnimListElem *ale, + eAnimChannel_Settings setting, + short *type) { - Hair *hair = (Hair *)ale->data; + Curves *curves = (Curves *)ale->data; /* clear extra return data first */ *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ - return GET_ACF_FLAG_PTR(hair->flag, type); + return GET_ACF_FLAG_PTR(curves->flag, type); case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ - if (hair->adt) { - return GET_ACF_FLAG_PTR(hair->adt->flag, type); + if (curves->adt) { + return GET_ACF_FLAG_PTR(curves->adt->flag, type); } return NULL; @@ -2870,9 +2872,9 @@ static void *acf_dshair_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se } } -/* hair expander type define */ +/* Curves expander type define */ static bAnimChannelType ACF_DSHAIR = { - "Hair Expander", /* type name */ + "Curves Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ acf_generic_dataexpand_color, /* backdrop color */ @@ -2882,11 +2884,11 @@ static bAnimChannelType ACF_DSHAIR = { acf_generic_idblock_name, /* name */ acf_generic_idblock_name_prop, /* name prop */ - acf_dshair_icon, /* icon */ + acf_dscurves_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dshair_setting_flag, /* flag for setting */ - acf_dshair_setting_ptr /* pointer for setting */ + acf_dscurves_setting_flag, /* flag for setting */ + acf_dscurves_setting_ptr /* pointer for setting */ }; /* PointCloud Expander ------------------------------------------- */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index c1a09b9d21f..3307385b84a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -47,8 +47,8 @@ #include "DNA_brush_types.h" #include "DNA_cachefile_types.h" #include "DNA_camera_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" #include "DNA_layer_types.h" @@ -791,10 +791,10 @@ static bAnimListElem *make_new_animlistelem(void *data, break; } case ANIMTYPE_DSHAIR: { - Hair *hair = (Hair *)data; - AnimData *adt = hair->adt; + Curves *curves = (Curves *)data; + AnimData *adt = curves->adt; - ale->flag = FILTER_HAIR_OBJD(hair); + ale->flag = FILTER_CURVES_OBJD(curves); ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; @@ -2616,16 +2616,16 @@ static size_t animdata_filter_ds_obdata( expanded = FILTER_SPK_OBJD(spk); break; } - case OB_HAIR: /* ---------- Hair ----------- */ + case OB_CURVES: /* ---------- Curves ----------- */ { - Hair *hair = (Hair *)ob->data; + Curves *curves = (Curves *)ob->data; if (ads->filterflag2 & ADS_FILTER_NOHAIR) { return 0; } type = ANIMTYPE_DSHAIR; - expanded = FILTER_HAIR_OBJD(hair); + expanded = FILTER_CURVES_OBJD(curves); break; } case OB_POINTCLOUD: /* ---------- PointCloud ----------- */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 3294316f880..04a892ab411 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -378,7 +378,7 @@ typedef enum eAnimFilter_Flags { #define FILTER_MESH_OBJD(me) (CHECK_TYPE_INLINE(me, Mesh *), ((me->flag & ME_DS_EXPAND))) #define FILTER_LATTICE_OBJD(lt) (CHECK_TYPE_INLINE(lt, Lattice *), ((lt->flag & LT_DS_EXPAND))) #define FILTER_SPK_OBJD(spk) (CHECK_TYPE_INLINE(spk, Speaker *), ((spk->flag & SPK_DS_EXPAND))) -#define FILTER_HAIR_OBJD(ha) (CHECK_TYPE_INLINE(ha, Hair *), ((ha->flag & HA_DS_EXPAND))) +#define FILTER_CURVES_OBJD(ha) (CHECK_TYPE_INLINE(ha, Curves *), ((ha->flag & HA_DS_EXPAND))) #define FILTER_POINTS_OBJD(pt) (CHECK_TYPE_INLINE(pt, PointCloud *), ((pt->flag & PT_DS_EXPAND))) #define FILTER_VOLUME_OBJD(vo) (CHECK_TYPE_INLINE(vo, Volume *), ((vo->flag & VO_DS_EXPAND))) #define FILTER_SIMULATION_OBJD(sim) \ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 4cf606bf98d..05353de2f92 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -752,9 +752,9 @@ DEF_ICON_BLANK(257) DEF_ICON_BLANK(257b) /* ADDITIONAL OBJECT TYPES */ -DEF_ICON_OBJECT(OUTLINER_OB_HAIR) -DEF_ICON_OBJECT_DATA(OUTLINER_DATA_HAIR) -DEF_ICON_OBJECT_DATA(HAIR_DATA) +DEF_ICON_OBJECT(OUTLINER_OB_CURVES) +DEF_ICON_OBJECT_DATA(OUTLINER_DATA_CURVES) +DEF_ICON_OBJECT_DATA(CURVES_DATA) DEF_ICON_OBJECT(OUTLINER_OB_POINTCLOUD) DEF_ICON_OBJECT_DATA(OUTLINER_DATA_POINTCLOUD) DEF_ICON_OBJECT_DATA(POINTCLOUD_DATA) @@ -840,7 +840,7 @@ DEF_ICON(MATPLANE) DEF_ICON(MATSPHERE) DEF_ICON(MATCUBE) DEF_ICON(MONKEY) -DEF_ICON(HAIR) +DEF_ICON(CURVES) DEF_ICON(ALIASED) DEF_ICON(ANTIALIASED) DEF_ICON(MAT_SPHERE_SKY) diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index c0d6b8a1a6c..d7d3288a68d 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2335,8 +2335,8 @@ int UI_icon_from_idcode(const int idcode) return ICON_TEXT; case ID_VF: return ICON_FONT_DATA; - case ID_HA: - return ICON_HAIR_DATA; + case ID_CV: + return ICON_CURVES_DATA; case ID_PT: return ICON_POINTCLOUD_DATA; case ID_VO: diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d605847c270..1f81dd21b83 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -792,8 +792,8 @@ static const char *template_id_browse_tip(const StructRNA *type) return N_("Browse Workspace to be linked"); case ID_LP: return N_("Browse LightProbe to be linked"); - case ID_HA: - return N_("Browse Hair Data to be linked"); + case ID_CV: + return N_("Browse Hair Curves Data to be linked"); case ID_PT: return N_("Browse Point Cloud Data to be linked"); case ID_VO: @@ -874,7 +874,7 @@ static uiBut *template_id_def_new_but(uiBlock *block, BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, BLT_I18NCONTEXT_ID_WORKSPACE, BLT_I18NCONTEXT_ID_LIGHTPROBE, - BLT_I18NCONTEXT_ID_HAIR, + BLT_I18NCONTEXT_ID_CURVES, BLT_I18NCONTEXT_ID_POINTCLOUD, BLT_I18NCONTEXT_ID_VOLUME, BLT_I18NCONTEXT_ID_SIMULATION, ); diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index a953c7d7f89..df76e605ebb 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -88,7 +88,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) add_definitions(-DWITH_POINT_CLOUD) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() blender_add_lib(bf_editor_object "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 0f1b0f5bdc0..d1deb6824ea 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -62,6 +62,7 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_duplilist.h" #include "BKE_effect.h" @@ -69,7 +70,6 @@ #include "BKE_gpencil_curve.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_layer.h" @@ -1894,18 +1894,18 @@ void OBJECT_OT_speaker_add(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Add Hair Operator +/** \name Add Hair Curves Operator * \{ */ -static bool object_hair_add_poll(bContext *C) +static bool object_hair_curves_add_poll(bContext *C) { - if (!U.experimental.use_new_hair_type) { + if (!U.experimental.use_new_curves_type) { return false; } return ED_operator_objectmode(C); } -static int object_hair_add_exec(bContext *C, wmOperator *op) +static int object_hair_curves_add_exec(bContext *C, wmOperator *op) { ushort local_view_bits; float loc[3], rot[3]; @@ -1913,22 +1913,22 @@ static int object_hair_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Object *object = ED_object_add_type(C, OB_HAIR, NULL, loc, rot, false, local_view_bits); + Object *object = ED_object_add_type(C, OB_CURVES, NULL, loc, rot, false, local_view_bits); object->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */ return OPERATOR_FINISHED; } -void OBJECT_OT_hair_add(wmOperatorType *ot) +void OBJECT_OT_hair_curves_add(wmOperatorType *ot) { /* identifiers */ - ot->name = "Add Hair"; - ot->description = "Add a hair object to the scene"; - ot->idname = "OBJECT_OT_hair_add"; + ot->name = "Add Hair Curves"; + ot->description = "Add a hair curves object to the scene"; + ot->idname = "OBJECT_OT_hair_curves_add"; /* api callbacks */ - ot->exec = object_hair_add_exec; - ot->poll = object_hair_add_poll; + ot->exec = object_hair_curves_add_exec; + ot->poll = object_hair_curves_add_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index f478f5004d4..ddd44fb9ded 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -129,7 +129,7 @@ void OBJECT_OT_light_add(struct wmOperatorType *ot); void OBJECT_OT_effector_add(struct wmOperatorType *ot); void OBJECT_OT_camera_add(struct wmOperatorType *ot); void OBJECT_OT_speaker_add(struct wmOperatorType *ot); -void OBJECT_OT_hair_add(struct wmOperatorType *ot); +void OBJECT_OT_hair_curves_add(struct wmOperatorType *ot); void OBJECT_OT_pointcloud_add(struct wmOperatorType *ot); /** * Only used as menu. diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 775fac96d57..af428512cfd 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -53,12 +53,12 @@ #include "BKE_armature.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_gpencil_modifier.h" -#include "BKE_hair.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_lib_id.h" @@ -132,8 +132,8 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object * else if (ob->type == OB_GPENCIL) { BKE_gpencil_modifiers_calc(depsgraph, scene_eval, ob_eval); } - else if (ob->type == OB_HAIR) { - BKE_hair_data_update(depsgraph, scene_eval, ob); + else if (ob->type == OB_CURVES) { + BKE_curves_data_update(depsgraph, scene_eval, ob); } else if (ob->type == OB_POINTCLOUD) { BKE_pointcloud_data_update(depsgraph, scene_eval, ob); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 03a36006fea..a9a429e7e6f 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -105,7 +105,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_light_add); WM_operatortype_append(OBJECT_OT_camera_add); WM_operatortype_append(OBJECT_OT_speaker_add); - WM_operatortype_append(OBJECT_OT_hair_add); + WM_operatortype_append(OBJECT_OT_hair_curves_add); WM_operatortype_append(OBJECT_OT_pointcloud_add); WM_operatortype_append(OBJECT_OT_volume_add); WM_operatortype_append(OBJECT_OT_volume_import); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 57a0fe0a39d..8678bf9bd92 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -63,11 +63,11 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.h" #include "BKE_fcurve.h" #include "BKE_gpencil.h" -#include "BKE_hair.h" #include "BKE_idprop.h" #include "BKE_idtype.h" #include "BKE_lattice.h" @@ -1872,7 +1872,7 @@ static void single_obdata_users( ob->data, BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; - case OB_HAIR: + case OB_CURVES: ob->data = ID_NEW_SET( ob->data, BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index c4ce8bac126..fb6742c9fd5 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -635,7 +635,7 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data) case ID_MC: /* MovieClip */ case ID_MSK: /* Mask */ case ID_LP: /* LightProbe */ - case ID_HA: /* Hair */ + case ID_CV: /* Curves */ case ID_PT: /* PointCloud */ case ID_VO: /* Volume */ case ID_SIM: /* Simulation */ diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index e2b2579c256..14cc03e3120 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -48,7 +48,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) add_definitions(-DWITH_POINT_CLOUD) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index f5107cb13fd..b83396b10d9 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -273,8 +273,8 @@ static bool buttons_context_path_data(ButsContextPath *path, int type) if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (ELEM(type, -1, OB_GPENCIL))) { return true; } -#ifdef WITH_HAIR_NODES - if (RNA_struct_is_a(ptr->type, &RNA_Hair) && (ELEM(type, -1, OB_HAIR))) { +#ifdef WITH_NEW_CURVES_TYPE + if (RNA_struct_is_a(ptr->type, &RNA_Curves) && (ELEM(type, -1, OB_CURVES))) { return true; } #endif @@ -314,7 +314,7 @@ static bool buttons_context_path_modifier(ButsContextPath *path) OB_SURF, OB_LATTICE, OB_GPENCIL, - OB_HAIR, + OB_CURVES, OB_POINTCLOUD, OB_VOLUME)) { ModifierData *md = BKE_object_active_modifier(ob); @@ -845,8 +845,8 @@ const char *buttons_context_dir[] = { "line_style", "collection", "gpencil", -#ifdef WITH_HAIR_NODES - "hair", +#ifdef WITH_NEW_CURVES_TYPE + "curves", #endif #ifdef WITH_POINT_CLOUD "pointcloud", @@ -941,9 +941,9 @@ int /*eContextResult*/ buttons_context(const bContext *C, set_pointer_type(path, result, &RNA_LightProbe); return CTX_RESULT_OK; } -#ifdef WITH_HAIR_NODES - if (CTX_data_equals(member, "hair")) { - set_pointer_type(path, result, &RNA_Hair); +#ifdef WITH_NEW_CURVES_TYPE + if (CTX_data_equals(member, "curves")) { + set_pointer_type(path, result, &RNA_Curves); return CTX_RESULT_OK; } #endif diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 005ae0214cd..a1eacc2bc3a 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -219,7 +219,7 @@ static void stats_object(Object *ob, } break; } - case OB_HAIR: + case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: { break; diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 259fdd4e009..13c273d1ec9 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -2632,8 +2632,8 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) case OB_LIGHTPROBE: data.icon = ICON_OUTLINER_OB_LIGHTPROBE; break; - case OB_HAIR: - data.icon = ICON_OUTLINER_OB_HAIR; + case OB_CURVES: + data.icon = ICON_OUTLINER_OB_CURVES; break; case OB_POINTCLOUD: data.icon = ICON_OUTLINER_OB_POINTCLOUD; @@ -2746,8 +2746,8 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) case ID_GR: data.icon = ICON_OUTLINER_COLLECTION; break; - case ID_HA: - data.icon = ICON_OUTLINER_DATA_HAIR; + case ID_CV: + data.icon = ICON_OUTLINER_DATA_CURVES; break; case ID_PT: data.icon = ICON_OUTLINER_DATA_POINTCLOUD; diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index bd288241a63..efbd8a32716 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -145,7 +145,7 @@ typedef struct TreeElementIcon { ID_GD, \ ID_LS, \ ID_LP, \ - ID_HA, \ + ID_CV, \ ID_PT, \ ID_VO, \ ID_SIM) || /* Only in 'blendfile' mode ... :/ */ \ diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index ebb4e529b04..f256475c0da 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -1198,7 +1198,7 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE case ID_AR: case ID_GD: case ID_LP: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: context = BCONTEXT_DATA; diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 3b8c284cd65..337649834a4 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -29,8 +29,8 @@ #include "DNA_armature_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_light_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" @@ -164,7 +164,7 @@ static void get_element_operation_type( case ID_CF: case ID_WS: case ID_LP: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_SIM: @@ -262,10 +262,10 @@ static void unlink_material_fn(bContext *UNUSED(C), totcol = mb->totcol; matar = mb->mat; } - else if (GS(tsep->id->name) == ID_HA) { - Hair *hair = (Hair *)tsep->id; - totcol = hair->totcol; - matar = hair->mat; + else if (GS(tsep->id->name) == ID_CV) { + Curves *curves = (Curves *)tsep->id; + totcol = curves->totcol; + matar = curves->mat; } else if (GS(tsep->id->name) == ID_PT) { PointCloud *pointcloud = (PointCloud *)tsep->id; diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 4e16fe64988..60f5437ad88 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -32,9 +32,9 @@ #include "DNA_camera_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" #include "DNA_key_types.h" #include "DNA_light_types.h" #include "DNA_lightprobe_types.h" @@ -773,10 +773,10 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, } break; } - case ID_HA: { - Hair *hair = (Hair *)id; - if (outliner_animdata_test(hair->adt)) { - outliner_add_element(space_outliner, &te->subtree, hair, te, TSE_ANIM_DATA, 0); + case ID_CV: { + Curves *curves = (Curves *)id; + if (outliner_animdata_test(curves->adt)) { + outliner_add_element(space_outliner, &te->subtree, curves, te, TSE_ANIM_DATA, 0); } break; } diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc index afbbd171cf4..3289cb8ac76 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -69,7 +69,7 @@ std::unique_ptr TreeElementID::createFromID(TreeElement &legacy_t case ID_LP: case ID_GD: case ID_WS: - case ID_HA: + case ID_CV: case ID_PT: case ID_VO: case ID_SIM: diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 243d4033cbc..bfc18eed847 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1764,7 +1764,7 @@ static void view3d_panel_transform(const bContext *C, Panel *panel) v3d_transform_butsR(col, &obptr); /* Dimensions and editmode are mostly the same check. */ - if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || ELEM(ob->type, OB_VOLUME, OB_HAIR, OB_POINTCLOUD)) { + if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || ELEM(ob->type, OB_VOLUME, OB_CURVES, OB_POINTCLOUD)) { View3D *v3d = CTX_wm_view3d(C); v3d_object_dimension_buts(NULL, col, v3d, ob); } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 132121064c8..4f479abe2b0 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -890,7 +890,7 @@ typedef enum IDRecalcFlag { #define FILTER_ID_CF (1ULL << 28) #define FILTER_ID_WS (1ULL << 29) #define FILTER_ID_LP (1ULL << 31) -#define FILTER_ID_HA (1ULL << 32) +#define FILTER_ID_CV (1ULL << 32) #define FILTER_ID_PT (1ULL << 33) #define FILTER_ID_VO (1ULL << 34) #define FILTER_ID_SIM (1ULL << 35) @@ -901,7 +901,7 @@ typedef enum IDRecalcFlag { FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | \ FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | \ FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | \ - FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM) + FILTER_ID_LP | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM) /** * This enum defines the index assigned to each type of IDs in the array returned by @@ -984,7 +984,7 @@ enum { INDEX_ID_ME, INDEX_ID_CU, INDEX_ID_MB, - INDEX_ID_HA, + INDEX_ID_CV, INDEX_ID_PT, INDEX_ID_VO, INDEX_ID_LT, diff --git a/source/blender/makesdna/DNA_ID_enums.h b/source/blender/makesdna/DNA_ID_enums.h index 45faf9e7f57..839c1e8933f 100644 --- a/source/blender/makesdna/DNA_ID_enums.h +++ b/source/blender/makesdna/DNA_ID_enums.h @@ -90,7 +90,7 @@ typedef enum ID_Type { ID_CF = MAKE_ID2('C', 'F'), /* CacheFile */ ID_WS = MAKE_ID2('W', 'S'), /* WorkSpace */ ID_LP = MAKE_ID2('L', 'P'), /* LightProbe */ - ID_HA = MAKE_ID2('H', 'A'), /* Hair */ + ID_CV = MAKE_ID2('C', 'V'), /* Curves */ ID_PT = MAKE_ID2('P', 'T'), /* PointCloud */ ID_VO = MAKE_ID2('V', 'O'), /* Volume */ ID_SIM = MAKE_ID2('S', 'I'), /* Simulation (geometry node groups) */ diff --git a/source/blender/makesdna/DNA_curves_defaults.h b/source/blender/makesdna/DNA_curves_defaults.h new file mode 100644 index 00000000000..66c7a1bd71b --- /dev/null +++ b/source/blender/makesdna/DNA_curves_defaults.h @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +/* Struct members on own line. */ +/* clang-format off */ + +/* -------------------------------------------------------------------- */ +/** \name Curves Struct + * \{ */ + +#define _DNA_DEFAULT_Curves \ + { \ + .flag = 0, \ + } + +/** \} */ + +/* clang-format on */ diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h new file mode 100644 index 00000000000..c7f31557e48 --- /dev/null +++ b/source/blender/makesdna/DNA_curves_types.h @@ -0,0 +1,108 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup DNA + */ + +#pragma once + +#include "DNA_ID.h" +#include "DNA_customdata_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A reusable data structure for geometry consisting of many curves. All control point data is + * stored contiguously for better efficiency. Data for each curve is stored as a slice of the + * main #point_data array. + * + * The data structure is meant to be embedded in other data-blocks to allow reusing + * curve-processing algorithms for multiple Blender data-block types. + */ +typedef struct CurvesGeometry { + /** + * A runtime pointer to the "position" attribute data. + * \note This data is owned by #point_data. + */ + float (*position)[3]; + /** + * A runtime pointer to the "radius" attribute data. + * \note This data is owned by #point_data. + */ + float *radius; + + /** + * The start index of each curve in the point data. The size of each curve can be calculated by + * subtracting the offset from the next offset. That is valid even for the last curve because + * this array is allocated with a length one larger than the number of splines. + * + * \note This is *not* stored in #CustomData because its size is one larger than #curve_data. + */ + int *offsets; + + /** + * All attributes stored on control points (#ATTR_DOMAIN_POINT). + */ + CustomData point_data; + + /** + * All attributes stored on curves (#ATTR_DOMAIN_CURVE). + */ + CustomData curve_data; + + /** + * The total number of control points in all curves. + */ + int point_size; + /** + * The number of curves in the data-block. + */ + int curve_size; +} CurvesGeometry; + +typedef struct Curves { + ID id; + /* Animation data (must be immediately after id). */ + struct AnimData *adt; + + CurvesGeometry geometry; + + int flag; + int attributes_active_index; + + /* Materials. */ + struct Material **mat; + short totcol; + short _pad2[3]; + + /* Draw Cache. */ + void *batch_cache; +} Curves; + +/* Curves.flag */ +enum { + HA_DS_EXPAND = (1 << 0), +}; + +/* Only one material supported currently. */ +#define CURVES_MATERIAL_NR 1 + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/makesdna/DNA_hair_defaults.h b/source/blender/makesdna/DNA_hair_defaults.h deleted file mode 100644 index 095e4fdf583..00000000000 --- a/source/blender/makesdna/DNA_hair_defaults.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** \file - * \ingroup DNA - */ - -#pragma once - -/* Struct members on own line. */ -/* clang-format off */ - -/* -------------------------------------------------------------------- */ -/** \name Hair Struct - * \{ */ - -#define _DNA_DEFAULT_Hair \ - { \ - .flag = 0, \ - } - -/** \} */ - -/* clang-format on */ diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h deleted file mode 100644 index 5d54a4bb8cc..00000000000 --- a/source/blender/makesdna/DNA_hair_types.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** \file - * \ingroup DNA - */ - -#pragma once - -#include "DNA_ID.h" -#include "DNA_customdata_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * A reusable data structure for geometry consisting of many curves. All control point data is - * stored contiguously for better efficiency. Data for each curve is stored as a slice of the - * main #point_data array. - * - * The data structure is meant to be embedded in other data-blocks to allow reusing - * curve-processing algorithms for multiple Blender data-block types. - */ -typedef struct CurvesGeometry { - /** - * A runtime pointer to the "position" attribute data. - * \note This data is owned by #point_data. - */ - float (*position)[3]; - /** - * A runtime pointer to the "radius" attribute data. - * \note This data is owned by #point_data. - */ - float *radius; - - /** - * The start index of each curve in the point data. The size of each curve can be calculated by - * subtracting the offset from the next offset. That is valid even for the last curve because - * this array is allocated with a length one larger than the number of splines. - * - * \note This is *not* stored in #CustomData because its size is one larger than #curve_data. - */ - int *offsets; - - /** - * All attributes stored on control points (#ATTR_DOMAIN_POINT). - */ - CustomData point_data; - - /** - * All attributes stored on curves (#ATTR_DOMAIN_CURVE). - */ - CustomData curve_data; - - /** - * The total number of control points in all curves. - */ - int point_size; - /** - * The number of curves in the data-block. - */ - int curve_size; -} CurvesGeometry; - -typedef struct Hair { - ID id; - /* Animation data (must be immediately after id). */ - struct AnimData *adt; - - CurvesGeometry geometry; - - int flag; - int attributes_active_index; - - /* Materials. */ - struct Material **mat; - short totcol; - short _pad2[3]; - - /* Draw Cache. */ - void *batch_cache; -} Hair; - -/* Hair.flag */ -enum { - HA_DS_EXPAND = (1 << 0), -}; - -/* Only one material supported currently. */ -#define HAIR_MATERIAL_NR 1 - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index ce735ad79c4..ca8696d1326 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -505,7 +505,7 @@ enum { /** Grease Pencil object used in 3D view but not used for annotation in 2D. */ OB_GPENCIL = 26, - OB_HAIR = 27, + OB_CURVES = 27, OB_POINTCLOUD = 28, @@ -520,7 +520,15 @@ enum { (((_type) >= OB_MESH && (_type) <= OB_MBALL) || ((_type) >= OB_GPENCIL && (_type) <= OB_VOLUME)) /** Does the object have some render-able geometry (unlike empties, cameras, etc.). */ #define OB_TYPE_IS_GEOMETRY(_type) \ - (ELEM(_type, OB_MESH, OB_SURF, OB_FONT, OB_MBALL, OB_GPENCIL, OB_HAIR, OB_POINTCLOUD, OB_VOLUME)) + (ELEM(_type, \ + OB_MESH, \ + OB_SURF, \ + OB_FONT, \ + OB_MBALL, \ + OB_GPENCIL, \ + OB_CURVES, \ + OB_POINTCLOUD, \ + OB_VOLUME)) #define OB_TYPE_SUPPORT_VGROUP(_type) (ELEM(_type, OB_MESH, OB_LATTICE, OB_GPENCIL)) #define OB_TYPE_SUPPORT_EDITMODE(_type) \ (ELEM(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) @@ -542,7 +550,7 @@ enum { ID_LT, \ ID_GD, \ ID_AR, \ - ID_HA, \ + ID_CV, \ ID_PT, \ ID_VO)) @@ -557,7 +565,7 @@ enum { case ID_LT: \ case ID_GD: \ case ID_AR: \ - case ID_HA: \ + case ID_CV: \ case ID_PT: \ case ID_VO diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 637dd216935..d1b015485c9 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -658,7 +658,7 @@ typedef struct UserDef_Experimental { char SANITIZE_AFTER_HERE; /* The following options are automatically sanitized (set to 0) * when the release cycle is not alpha. */ - char use_new_hair_type; + char use_new_curves_type; char use_new_point_cloud_type; char use_full_frame_compositor; char use_sculpt_vertex_colors; @@ -1252,7 +1252,7 @@ typedef enum eDupli_ID_Flags { USER_DUP_PSYS = (1 << 11), USER_DUP_LIGHTPROBE = (1 << 12), USER_DUP_GPENCIL = (1 << 13), - USER_DUP_HAIR = (1 << 14), + USER_DUP_CURVES = (1 << 14), USER_DUP_POINTCLOUD = (1 << 15), USER_DUP_VOLUME = (1 << 16), USER_DUP_LATTICE = (1 << 17), diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index a3c54e91780..af30fa5cc9e 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -142,7 +142,7 @@ set(SRC ../DNA_defaults.h ../DNA_fluid_defaults.h ../DNA_gpencil_modifier_defaults.h - ../DNA_hair_defaults.h + ../DNA_curves_defaults.h ../DNA_image_defaults.h ../DNA_lattice_defaults.h ../DNA_light_defaults.h diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 5bc5de7a20b..fd23c5c618f 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -94,9 +94,9 @@ #include "DNA_cloth_types.h" #include "DNA_collection_types.h" #include "DNA_curve_types.h" +#include "DNA_curves_types.h" #include "DNA_fluid_types.h" #include "DNA_gpencil_modifier_types.h" -#include "DNA_hair_types.h" #include "DNA_image_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" @@ -127,9 +127,9 @@ #include "DNA_camera_defaults.h" #include "DNA_collection_defaults.h" #include "DNA_curve_defaults.h" +#include "DNA_curves_defaults.h" #include "DNA_fluid_defaults.h" #include "DNA_gpencil_modifier_defaults.h" -#include "DNA_hair_defaults.h" #include "DNA_image_defaults.h" #include "DNA_lattice_defaults.h" #include "DNA_light_defaults.h" @@ -184,8 +184,8 @@ SDNA_DEFAULT_DECL_STRUCT(FluidEffectorSettings); /* DNA_image_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Image); -/* DNA_hair_defaults.h */ -SDNA_DEFAULT_DECL_STRUCT(Hair); +/* DNA_curves_defaults.h */ +SDNA_DEFAULT_DECL_STRUCT(Curves); /* DNA_lattice_defaults.h */ SDNA_DEFAULT_DECL_STRUCT(Lattice); @@ -392,8 +392,8 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { /* DNA_image_defaults.h */ SDNA_DEFAULT_DECL(Image), - /* DNA_hair_defaults.h */ - SDNA_DEFAULT_DECL(Hair), + /* DNA_curves_defaults.h */ + SDNA_DEFAULT_DECL(Curves), /* DNA_lattice_defaults.h */ SDNA_DEFAULT_DECL(Lattice), diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index d94b95fc6f4..b61f5315020 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -134,7 +134,7 @@ static const char *includefiles[] = { "DNA_lightprobe_types.h", "DNA_curveprofile_types.h", "DNA_xr_types.h", - "DNA_hair_types.h", + "DNA_curves_types.h", "DNA_pointcloud_types.h", "DNA_volume_types.h", "DNA_simulation_types.h", @@ -1644,7 +1644,7 @@ int main(int argc, char **argv) #include "DNA_freestyle_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_hair_types.h" +#include "DNA_curves_types.h" #include "DNA_image_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 43439428ea7..47afa0f9a13 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -308,7 +308,7 @@ extern StructRNA RNA_GizmoProperties; extern StructRNA RNA_GlowSequence; extern StructRNA RNA_GpencilModifier; extern StructRNA RNA_GreasePencil; -extern StructRNA RNA_Hair; +extern StructRNA RNA_Curves; extern StructRNA RNA_Header; extern StructRNA RNA_Histogram; extern StructRNA RNA_HookGpencilModifier; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index e3c89af6186..91d7c5a1394 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -101,9 +101,9 @@ set(DEFSRC if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) list(APPEND DEFSRC - rna_hair.c + rna_curves.c rna_simulation.c ) endif() diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1e9cebbc3ea..0fadbda5a18 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -4376,8 +4376,8 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"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}, -#ifdef WITH_HAIR_NODES - {"rna_hair.c", NULL, RNA_def_hair}, +#ifdef WITH_NEW_CURVES_TYPE + {"rna_curves.c", NULL, RNA_def_curves}, #endif {"rna_image.c", "rna_image_api.c", RNA_def_image}, {"rna_key.c", NULL, RNA_def_key}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 8fc634fc087..9bb78cb483d 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -76,7 +76,7 @@ const EnumPropertyItem rna_enum_id_type_items[] = { {ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""}, {ID_TXT, "TEXT", ICON_TEXT, "Text", ""}, {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""}, - {ID_HA, "HAIR", ICON_HAIR_DATA, "Hair", ""}, + {ID_CV, "CURVES", ICON_CURVES_DATA, "Hair Curves", ""}, {ID_PT, "POINTCLOUD", ICON_POINTCLOUD_DATA, "Point Cloud", ""}, {ID_VO, "VOLUME", ICON_VOLUME_DATA, "Volume", ""}, {ID_WM, "WINDOWMANAGER", ICON_WINDOW, "Window Manager", ""}, @@ -151,7 +151,7 @@ const struct IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = { ICON_OUTLINER_COLLECTION, "Collections", "Show Collection data-blocks"}, - {FILTER_ID_HA, "filter_hair", ICON_HAIR_DATA, "Hairs", "Show/hide Hair data-blocks"}, + {FILTER_ID_CV, "filter_hair", ICON_CURVES_DATA, "Hairs", "Show/hide Hair data-blocks"}, {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"}, {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"}, {FILTER_ID_LP, @@ -385,9 +385,9 @@ short RNA_type_to_ID_code(const StructRNA *type) if (base_type == &RNA_FreestyleLineStyle) { return ID_LS; } -# ifdef WITH_HAIR_NODES - if (base_type == &RNA_Hair) { - return ID_HA; +# ifdef WITH_NEW_CURVES_TYPE + if (base_type == &RNA_Curves) { + return ID_CV; } # endif if (base_type == &RNA_Lattice) { @@ -492,9 +492,9 @@ StructRNA *ID_code_to_RNA_type(short idcode) return &RNA_GreasePencil; case ID_GR: return &RNA_Collection; - case ID_HA: -# ifdef WITH_HAIR_NODES - return &RNA_Hair; + case ID_CV: +# ifdef WITH_NEW_CURVES_TYPE + return &RNA_Curves; # else return &RNA_ID; # endif diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 6b134977c5a..f4236a860ab 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -625,11 +625,11 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_FILE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - prop = RNA_def_property(srna, "show_hairs", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "show_hair_curves", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag2", ADS_FILTER_NOHAIR); RNA_def_property_ui_text( prop, "Display Hair", "Include visualization of hair related animation data"); - RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_HAIR, 0); + RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CURVES, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_pointclouds", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index da835fb89c4..dc0d00aaa77 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -26,8 +26,8 @@ #include "rna_internal.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" -#include "DNA_hair_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_pointcloud_types.h" @@ -188,7 +188,7 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, if (id_type == ID_PT && !ELEM(domain_item->value, ATTR_DOMAIN_POINT)) { continue; } - if (id_type == ID_HA && !ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { + if (id_type == ID_CV && !ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) { continue; } if (id_type == ID_ME && ELEM(domain_item->value, ATTR_DOMAIN_CURVE)) { diff --git a/source/blender/makesrna/intern/rna_curves.c b/source/blender/makesrna/intern/rna_curves.c new file mode 100644 index 00000000000..faa067000bb --- /dev/null +++ b/source/blender/makesrna/intern/rna_curves.c @@ -0,0 +1,296 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup RNA + */ + +#include + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "DNA_curves_types.h" + +#include "BLI_math_base.h" +#include "BLI_string.h" + +#ifdef RNA_RUNTIME + +# include "BLI_math_vector.h" + +# include "BKE_attribute.h" +# include "BKE_curves.h" + +# include "DEG_depsgraph.h" + +# include "WM_api.h" +# include "WM_types.h" + +static Curves *rna_curves(PointerRNA *ptr) +{ + return (Curves *)ptr->owner_id; +} + +static int rna_Curves_curve_offset_data_length(PointerRNA *ptr) +{ + const Curves *curves = rna_curves(ptr); + return curves->geometry.curve_size + 1; +} + +static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + const Curves *curves = rna_curves(ptr); + rna_iterator_array_begin(iter, + (void *)curves->geometry.offsets, + sizeof(int), + curves->geometry.curve_size + 1, + false, + NULL); +} + +static int rna_CurvePoint_index_get(PointerRNA *ptr) +{ + const Curves *curves = rna_curves(ptr); + const float(*co)[3] = ptr->data; + return (int)(co - curves->geometry.position); +} + +static void rna_CurvePoint_location_get(PointerRNA *ptr, float value[3]) +{ + copy_v3_v3(value, (const float *)ptr->data); +} + +static void rna_CurvePoint_location_set(PointerRNA *ptr, const float value[3]) +{ + copy_v3_v3((float *)ptr->data, value); +} + +static float rna_CurvePoint_radius_get(PointerRNA *ptr) +{ + const Curves *curves = rna_curves(ptr); + if (curves->geometry.radius == NULL) { + return 0.0f; + } + const float(*co)[3] = ptr->data; + return curves->geometry.radius[co - curves->geometry.position]; +} + +static void rna_CurvePoint_radius_set(PointerRNA *ptr, float value) +{ + const Curves *curves = rna_curves(ptr); + if (curves->geometry.radius == NULL) { + return; + } + const float(*co)[3] = ptr->data; + curves->geometry.radius[co - curves->geometry.position] = value; +} + +static char *rna_CurvePoint_path(PointerRNA *ptr) +{ + return BLI_sprintfN("points[%d]", rna_CurvePoint_index_get(ptr)); +} + +static int rna_CurveSlice_index_get(PointerRNA *ptr) +{ + Curves *curves = rna_curves(ptr); + return (int)((int *)ptr->data - curves->geometry.offsets); +} + +static char *rna_CurveSlice_path(PointerRNA *ptr) +{ + return BLI_sprintfN("curves[%d]", rna_CurveSlice_index_get(ptr)); +} + +static void rna_CurveSlice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Curves *curves = rna_curves(ptr); + const int *offset_ptr = (int *)ptr->data; + const int offset = *offset_ptr; + const int size = *(offset_ptr + 1) - offset; + float(*co)[3] = curves->geometry.position + *offset_ptr; + rna_iterator_array_begin(iter, co, sizeof(float[3]), size, 0, NULL); +} + +static int rna_CurveSlice_first_point_index_get(PointerRNA *ptr) +{ + const int *offset_ptr = (int *)ptr->data; + return *offset_ptr; +} + +static int rna_CurveSlice_points_length_get(PointerRNA *ptr) +{ + const int *offset_ptr = (int *)ptr->data; + const int offset = *offset_ptr; + return *(offset_ptr + 1) - offset; +} + +static void rna_Curves_update_data(struct Main *UNUSED(bmain), + struct Scene *UNUSED(scene), + PointerRNA *ptr) +{ + ID *id = ptr->owner_id; + + /* cheating way for importers to avoid slow updates */ + if (id->us > 0) { + DEG_id_tag_update(id, 0); + WM_main_add_notifier(NC_GEOM | ND_DATA, id); + } +} + +#else + +static void rna_def_curves_point(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CurvePoint", NULL); + RNA_def_struct_ui_text(srna, "Curve Point", "Curve curve control point"); + RNA_def_struct_path_func(srna, "rna_CurvePoint_path"); + + prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs( + prop, "rna_CurvePoint_location_get", "rna_CurvePoint_location_set", NULL); + RNA_def_property_ui_text(prop, "Position", ""); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); + + prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_funcs( + prop, "rna_CurvePoint_radius_get", "rna_CurvePoint_radius_set", NULL); + RNA_def_property_ui_text(prop, "Radius", ""); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_CurvePoint_index_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Index", "Index of this points"); +} + +static void rna_def_curves_curve(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CurveSlice", NULL); + RNA_def_struct_ui_text(srna, "Curve Slice", "A single curve from a curves data-block"); + RNA_def_struct_path_func(srna, "rna_CurveSlice_path"); + + prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "CurvePoint"); + RNA_def_property_ui_text(prop, "Points", "Control points of the curve"); + RNA_def_property_collection_funcs(prop, + "rna_CurveSlice_points_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_CurveSlice_points_length_get", + NULL, + NULL, + NULL); + + prop = RNA_def_property(srna, "first_point_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_CurveSlice_first_point_index_get", NULL, NULL); + RNA_def_property_ui_text( + prop, "First Point Index", "The index of this curve's first control point"); + + prop = RNA_def_property(srna, "points_length", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_CurveSlice_points_length_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Number of Points", "Number of control points in the curve"); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_CurveSlice_index_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Index", "Index of this curve"); +} + +static void rna_def_curves(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "Curves", "ID"); + RNA_def_struct_ui_text(srna, "Hair Curves", "Hair data-block for hair curves"); + RNA_def_struct_ui_icon(srna, ICON_CURVES_DATA); + + /* Point and Curve RNA API helpers. */ + + prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", "geometry.curve_size"); + RNA_def_property_struct_type(prop, "CurveSlice"); + RNA_def_property_ui_text(prop, "Curves", "All curves in the data-block"); + + /* TODO: better solution for (*co)[3] parsing issue. */ + + RNA_define_verify_sdna(0); + prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "geometry.position", "geometry.point_size"); + RNA_def_property_struct_type(prop, "CurvePoint"); + RNA_def_property_ui_text(prop, "Points", "Control points of all curves"); + RNA_define_verify_sdna(1); + + /* Direct access to built-in attributes. */ + + RNA_define_verify_sdna(0); + prop = RNA_def_property(srna, "position_data", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "geometry.position", "geometry.point_size"); + RNA_def_property_struct_type(prop, "FloatVectorAttributeValue"); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); + RNA_define_verify_sdna(1); + + prop = RNA_def_property(srna, "curve_offset_data", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", NULL); + RNA_def_property_struct_type(prop, "IntAttributeValue"); + RNA_def_property_collection_funcs(prop, + "rna_Curves_curve_offset_data_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_get", + "rna_Curves_curve_offset_data_length", + NULL, + NULL, + NULL); + RNA_def_property_update(prop, 0, "rna_Curves_update_data"); + + /* materials */ + prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_ui_text(prop, "Materials", ""); + RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ + RNA_def_property_collection_funcs( + prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); + + /* attributes */ + rna_def_attributes_common(srna); + + /* common */ + rna_def_animdata_common(srna); +} + +void RNA_def_curves(BlenderRNA *brna) +{ + rna_def_curves_point(brna); + rna_def_curves_curve(brna); + rna_def_curves(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c deleted file mode 100644 index 30e1fd48c03..00000000000 --- a/source/blender/makesrna/intern/rna_hair.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** \file - * \ingroup RNA - */ - -#include - -#include "RNA_define.h" -#include "RNA_enum_types.h" - -#include "rna_internal.h" - -#include "DNA_hair_types.h" - -#include "BLI_math_base.h" -#include "BLI_string.h" - -#ifdef RNA_RUNTIME - -# include "BLI_math_vector.h" - -# include "BKE_attribute.h" -# include "BKE_hair.h" - -# include "DEG_depsgraph.h" - -# include "WM_api.h" -# include "WM_types.h" - -static Hair *rna_hair(PointerRNA *ptr) -{ - return (Hair *)ptr->owner_id; -} - -static int rna_Hair_curve_offset_data_length(PointerRNA *ptr) -{ - const Hair *curves = rna_hair(ptr); - return curves->geometry.curve_size + 1; -} - -static void rna_Hair_curve_offset_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - const Hair *curves = rna_hair(ptr); - rna_iterator_array_begin(iter, - (void *)curves->geometry.offsets, - sizeof(int), - curves->geometry.curve_size + 1, - false, - NULL); -} - -static int rna_CurvePoint_index_get(PointerRNA *ptr) -{ - const Hair *hair = rna_hair(ptr); - const float(*co)[3] = ptr->data; - return (int)(co - hair->geometry.position); -} - -static void rna_CurvePoint_location_get(PointerRNA *ptr, float value[3]) -{ - copy_v3_v3(value, (const float *)ptr->data); -} - -static void rna_CurvePoint_location_set(PointerRNA *ptr, const float value[3]) -{ - copy_v3_v3((float *)ptr->data, value); -} - -static float rna_CurvePoint_radius_get(PointerRNA *ptr) -{ - const Hair *hair = rna_hair(ptr); - if (hair->geometry.radius == NULL) { - return 0.0f; - } - const float(*co)[3] = ptr->data; - return hair->geometry.radius[co - hair->geometry.position]; -} - -static void rna_CurvePoint_radius_set(PointerRNA *ptr, float value) -{ - const Hair *hair = rna_hair(ptr); - if (hair->geometry.radius == NULL) { - return; - } - const float(*co)[3] = ptr->data; - hair->geometry.radius[co - hair->geometry.position] = value; -} - -static char *rna_CurvePoint_path(PointerRNA *ptr) -{ - return BLI_sprintfN("points[%d]", rna_CurvePoint_index_get(ptr)); -} - -static int rna_CurveSlice_index_get(PointerRNA *ptr) -{ - Hair *hair = rna_hair(ptr); - return (int)((int *)ptr->data - hair->geometry.offsets); -} - -static char *rna_CurveSlice_path(PointerRNA *ptr) -{ - return BLI_sprintfN("curves[%d]", rna_CurveSlice_index_get(ptr)); -} - -static void rna_CurveSlice_points_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Hair *hair = rna_hair(ptr); - const int *offset_ptr = (int *)ptr->data; - const int offset = *offset_ptr; - const int size = *(offset_ptr + 1) - offset; - float(*co)[3] = hair->geometry.position + *offset_ptr; - rna_iterator_array_begin(iter, co, sizeof(float[3]), size, 0, NULL); -} - -static int rna_CurveSlice_first_point_index_get(PointerRNA *ptr) -{ - const int *offset_ptr = (int *)ptr->data; - return *offset_ptr; -} - -static int rna_CurveSlice_points_length_get(PointerRNA *ptr) -{ - const int *offset_ptr = (int *)ptr->data; - const int offset = *offset_ptr; - return *(offset_ptr + 1) - offset; -} - -static void rna_Hair_update_data(struct Main *UNUSED(bmain), - struct Scene *UNUSED(scene), - PointerRNA *ptr) -{ - ID *id = ptr->owner_id; - - /* cheating way for importers to avoid slow updates */ - if (id->us > 0) { - DEG_id_tag_update(id, 0); - WM_main_add_notifier(NC_GEOM | ND_DATA, id); - } -} - -#else - -static void rna_def_hair_point(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "CurvePoint", NULL); - RNA_def_struct_ui_text(srna, "Curve Point", "Curve curve control point"); - RNA_def_struct_path_func(srna, "rna_CurvePoint_path"); - - prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_array(prop, 3); - RNA_def_property_float_funcs( - prop, "rna_CurvePoint_location_get", "rna_CurvePoint_location_set", NULL); - RNA_def_property_ui_text(prop, "Position", ""); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); - - prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_funcs( - prop, "rna_CurvePoint_radius_get", "rna_CurvePoint_radius_set", NULL); - RNA_def_property_ui_text(prop, "Radius", ""); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); - - prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_CurvePoint_index_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Index", "Index of this points"); -} - -static void rna_def_hair_curve(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "CurveSlice", NULL); - RNA_def_struct_ui_text(srna, "Curve Slice", "A single curve from a curves data-block"); - RNA_def_struct_path_func(srna, "rna_CurveSlice_path"); - - prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "CurvePoint"); - RNA_def_property_ui_text(prop, "Points", "Control points of the curve"); - RNA_def_property_collection_funcs(prop, - "rna_CurveSlice_points_begin", - "rna_iterator_array_next", - "rna_iterator_array_end", - "rna_iterator_array_get", - "rna_CurveSlice_points_length_get", - NULL, - NULL, - NULL); - - prop = RNA_def_property(srna, "first_point_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_CurveSlice_first_point_index_get", NULL, NULL); - RNA_def_property_ui_text( - prop, "First Point Index", "The index of this curve's first control point"); - - prop = RNA_def_property(srna, "points_length", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_CurveSlice_points_length_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Number of Points", "Number of control points in the curve"); - - prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_CurveSlice_index_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Index", "Index of this curve"); -} - -static void rna_def_hair(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "Hair", "ID"); - RNA_def_struct_ui_text(srna, "Hair", "Hair data-block for hair curves"); - RNA_def_struct_ui_icon(srna, ICON_HAIR_DATA); - - /* Point and Curve RNA API helpers. */ - - prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", "geometry.curve_size"); - RNA_def_property_struct_type(prop, "CurveSlice"); - RNA_def_property_ui_text(prop, "Curves", "All hair curves"); - - /* TODO: better solution for (*co)[3] parsing issue. */ - - RNA_define_verify_sdna(0); - prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "geometry.position", "geometry.point_size"); - RNA_def_property_struct_type(prop, "CurvePoint"); - RNA_def_property_ui_text(prop, "Points", "Control points of all hair curves"); - RNA_define_verify_sdna(1); - - /* Direct access to built-in attributes. */ - - RNA_define_verify_sdna(0); - prop = RNA_def_property(srna, "position_data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "geometry.position", "geometry.point_size"); - RNA_def_property_struct_type(prop, "FloatVectorAttributeValue"); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); - RNA_define_verify_sdna(1); - - prop = RNA_def_property(srna, "curve_offset_data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "geometry.offsets", NULL); - RNA_def_property_struct_type(prop, "IntAttributeValue"); - RNA_def_property_collection_funcs(prop, - "rna_Hair_curve_offset_data_begin", - "rna_iterator_array_next", - "rna_iterator_array_end", - "rna_iterator_array_get", - "rna_Hair_curve_offset_data_length", - NULL, - NULL, - NULL); - RNA_def_property_update(prop, 0, "rna_Hair_update_data"); - - /* materials */ - prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); - RNA_def_property_struct_type(prop, "Material"); - RNA_def_property_ui_text(prop, "Materials", ""); - RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ - RNA_def_property_collection_funcs( - prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); - - /* attributes */ - rna_def_attributes_common(srna); - - /* common */ - rna_def_animdata_common(srna); -} - -void RNA_def_hair(BlenderRNA *brna) -{ - rna_def_hair_point(brna); - rna_def_hair_curve(brna); - rna_def_hair(brna); -} - -#endif diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 0e0391197ea..407f474ddab 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -170,7 +170,7 @@ void RNA_def_fcurve(struct BlenderRNA *brna); void RNA_def_gpencil(struct BlenderRNA *brna); void RNA_def_greasepencil_modifier(struct BlenderRNA *brna); void RNA_def_shader_fx(struct BlenderRNA *brna); -void RNA_def_hair(struct BlenderRNA *brna); +void RNA_def_curves(struct BlenderRNA *brna); void RNA_def_image(struct BlenderRNA *brna); void RNA_def_key(struct BlenderRNA *brna); void RNA_def_light(struct BlenderRNA *brna); @@ -496,8 +496,8 @@ void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop); -#ifdef WITH_HAIR_NODES -void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop); +#ifdef WITH_NEW_CURVES_TYPE +void RNA_def_main_hair_curves(BlenderRNA *brna, PropertyRNA *cprop); #endif void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 57a2a867d0a..230c04bfd9c 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -110,8 +110,8 @@ RNA_MAIN_LISTBASE_FUNCS_DEF(collections) RNA_MAIN_LISTBASE_FUNCS_DEF(curves) RNA_MAIN_LISTBASE_FUNCS_DEF(fonts) RNA_MAIN_LISTBASE_FUNCS_DEF(gpencils) -# ifdef WITH_HAIR_NODES -RNA_MAIN_LISTBASE_FUNCS_DEF(hairs) +# ifdef WITH_NEW_CURVES_TYPE +RNA_MAIN_LISTBASE_FUNCS_DEF(hair_curves) # endif RNA_MAIN_LISTBASE_FUNCS_DEF(images) RNA_MAIN_LISTBASE_FUNCS_DEF(lattices) @@ -389,8 +389,17 @@ void RNA_def_main(BlenderRNA *brna) "Light Probes", "Light Probe data-blocks", RNA_def_main_lightprobes}, -# ifdef WITH_HAIR_NODES - {"hairs", "Hair", "rna_Main_hairs_begin", "Hairs", "Hair data-blocks", RNA_def_main_hairs}, +# ifdef WITH_NEW_CURVES_TYPE + /** + * \note The name `hair_curves` is chosen to be different than `curves`, + * but they are generic curve data-blocks, not just for hair. + */ + {"hair_curves", + "Curves", + "rna_Main_hair_curves_begin", + "Hair Curves", + "Hair curve data-blocks", + RNA_def_main_hair_curves}, # endif {"pointclouds", "PointCloud", diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 4344ed0dff5..f8d2d6524c2 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -46,9 +46,9 @@ # include "BKE_camera.h" # include "BKE_collection.h" # include "BKE_curve.h" +# include "BKE_curves.h" # include "BKE_displist.h" # include "BKE_gpencil.h" -# include "BKE_hair.h" # include "BKE_icons.h" # include "BKE_idtype.h" # include "BKE_image.h" @@ -86,8 +86,8 @@ # include "DNA_camera_types.h" # include "DNA_collection_types.h" # include "DNA_curve_types.h" +# include "DNA_curves_types.h" # include "DNA_gpencil_types.h" -# include "DNA_hair_types.h" # include "DNA_lattice_types.h" # include "DNA_light_types.h" # include "DNA_lightprobe_types.h" @@ -763,18 +763,18 @@ static bGPdata *rna_Main_gpencils_new(Main *bmain, const char *name) return gpd; } -# ifdef WITH_HAIR_NODES -static Hair *rna_Main_hairs_new(Main *bmain, const char *name) +# ifdef WITH_NEW_CURVES_TYPE +static Curves *rna_Main_hair_curves_new(Main *bmain, const char *name) { char safe_name[MAX_ID_NAME - 2]; rna_idname_validate(name, safe_name); - Hair *hair = BKE_hair_add(bmain, safe_name); - id_us_min(&hair->id); + Curves *curves = BKE_curves_add(bmain, safe_name); + id_us_min(&curves->id); WM_main_add_notifier(NC_ID | NA_ADDED, NULL); - return hair; + return curves; } # endif @@ -861,8 +861,8 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC) RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) RNA_MAIN_ID_TAG_FUNCS_DEF(lightprobes, lightprobes, ID_LP) -# ifdef WITH_HAIR_NODES -RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA) +# ifdef WITH_NEW_CURVES_TYPE +RNA_MAIN_ID_TAG_FUNCS_DEF(hair_curves, hair_curves, ID_CV) # endif RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT) RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO) @@ -2269,47 +2269,47 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } -# ifdef WITH_HAIR_NODES -void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop) +# ifdef WITH_NEW_CURVES_TYPE +void RNA_def_main_hair_curves(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; FunctionRNA *func; PropertyRNA *parm; - RNA_def_property_srna(cprop, "BlendDataHairs"); - srna = RNA_def_struct(brna, "BlendDataHairs", NULL); + RNA_def_property_srna(cprop, "BlendDataHairCurves"); + srna = RNA_def_struct(brna, "BlendDataHairCurves", NULL); RNA_def_struct_sdna(srna, "Main"); - RNA_def_struct_ui_text(srna, "Main Hairs", "Collection of hairs"); + RNA_def_struct_ui_text(srna, "Main Hair Curves", "Collection of hair curves"); - func = RNA_def_function(srna, "new", "rna_Main_hairs_new"); + func = RNA_def_function(srna, "new", "rna_Main_hair_curves_new"); RNA_def_function_ui_description(func, "Add a new hair to the main database"); - parm = RNA_def_string(func, "name", "Hair", 0, "", "New name for the data-block"); + parm = RNA_def_string(func, "name", "Curves", 0, "", "New name for the data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* return type */ - parm = RNA_def_pointer(func, "hair", "Hair", "", "New hair data-block"); + parm = RNA_def_pointer(func, "curves", "Curves", "", "New curves data-block"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_function_ui_description(func, "Remove a hair from the current blendfile"); - parm = RNA_def_pointer(func, "hair", "Hair", "", "Hair to remove"); + RNA_def_function_ui_description(func, "Remove a curves data-block from the current blendfile"); + parm = RNA_def_pointer(func, "curves", "Curves", "", "Curves data-block to remove"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); RNA_def_boolean(func, "do_unlink", true, "", - "Unlink all usages of this hair before deleting it " - "(WARNING: will also delete objects instancing that hair data)"); + "Unlink all usages of this curves before deleting it " + "(WARNING: will also delete objects instancing that curves data)"); RNA_def_boolean(func, "do_id_user", true, "", - "Decrement user counter of all datablocks used by this hair data"); + "Decrement user counter of all datablocks used by this curves data"); RNA_def_boolean( - func, "do_ui_user", true, "", "Make sure interface does not reference this hair data"); + func, "do_ui_user", true, "", "Make sure interface does not reference this curves data"); - func = RNA_def_function(srna, "tag", "rna_Main_hairs_tag"); + func = RNA_def_function(srna, "tag", "rna_Main_hair_curves_tag"); parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 22a75c0d992..67943b290da 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -718,7 +718,7 @@ void RNA_def_material(BlenderRNA *brna) {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"}, {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"}, {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"}, - {MA_HAIR, "HAIR", ICON_HAIR, "Hair", "Hair strands"}, + {MA_HAIR, "HAIR", ICON_CURVES, "Hair", "Hair strands"}, {MA_SHADERBALL, "SHADERBALL", ICON_MATSHADERBALL, "Shader Ball", "Shader ball"}, {MA_CLOTH, "CLOTH", ICON_MATCLOTH, "Cloth", "Cloth"}, {MA_FLUID, "FLUID", ICON_MATFLUID, "Fluid", "Fluid"}, diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 2bb341e00fb..be37e574c9c 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -271,7 +271,7 @@ const EnumPropertyItem rna_enum_object_type_items[] = { OBTYPE_CU_SURF, {OB_MBALL, "META", ICON_OUTLINER_OB_META, "Metaball", ""}, OBTYPE_CU_FONT, - {OB_HAIR, "HAIR", ICON_OUTLINER_OB_HAIR, "Hair", ""}, + {OB_CURVES, "CURVES", ICON_OUTLINER_OB_CURVES, "Hair Curves", ""}, {OB_POINTCLOUD, "POINTCLOUD", ICON_OUTLINER_OB_POINTCLOUD, "Point Cloud", ""}, {OB_VOLUME, "VOLUME", ICON_OUTLINER_OB_VOLUME, "Volume", ""}, {OB_GPENCIL, "GPENCIL", ICON_OUTLINER_OB_GREASEPENCIL, "Grease Pencil", ""}, @@ -613,9 +613,9 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) return &RNA_LightProbe; case OB_GPENCIL: return &RNA_GreasePencil; - case OB_HAIR: -# ifdef WITH_HAIR_NODES - return &RNA_Hair; + case OB_CURVES: +# ifdef WITH_NEW_CURVES_TYPE + return &RNA_Curves; # else return &RNA_ID; # endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9a3c40bf306..07521d39256 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3277,7 +3277,7 @@ static struct IDFilterEnumPropertyItem rna_enum_space_file_id_filter_categories[ ICON_OUTLINER_COLLECTION, "Objects & Collections", "Show objects and collections"}, - {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_HA | + {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO, "category_geometry", ICON_NODETREE, @@ -5004,7 +5004,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) {"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}}, {"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}}, {"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}}, - {"Hair", (1 << OB_HAIR), {"show_object_viewport_hair", "show_object_select_hair"}}, + {"Hair", (1 << OB_CURVES), {"show_object_viewport_hair", "show_object_select_hair"}}, {"Point Cloud", (1 << OB_POINTCLOUD), {"show_object_viewport_pointcloud", "show_object_select_pointcloud"}}, diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index aef219c4236..53af3f5bed5 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -5293,7 +5293,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) prop, "Duplicate GPencil", "Causes grease pencil data to be duplicated with the object"); prop = RNA_def_property(srna, "use_duplicate_hair", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_HAIR); + RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_CURVES); RNA_def_property_ui_text( prop, "Duplicate Hair", "Causes hair data to be duplicated with the object"); @@ -6399,9 +6399,9 @@ static void rna_def_userdef_experimental(BlenderRNA *brna) "reduces execution time and memory usage)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "use_new_hair_type", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "use_new_hair_type", 1); - RNA_def_property_ui_text(prop, "New Hair Type", "Enable the new hair type in the ui"); + prop = RNA_def_property(srna, "use_new_curves_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_new_curves_type", 1); + RNA_def_property_ui_text(prop, "New Curves Type", "Enable the new curves data type in the UI"); prop = RNA_def_property(srna, "use_cycles_debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_cycles_debug", 1); diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 5065a23ee1b..719a07adbab 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -232,7 +232,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() # So we can have special tricks in modifier system. -- cgit v1.2.3 From 880e85fc80853334ddbe0a88ad8dd5730a66368a Mon Sep 17 00:00:00 2001 From: Myles Walcott Date: Mon, 7 Feb 2022 14:27:25 -0500 Subject: Cleanup: Grammar in doc/python_api * Its -> It's * Scripts -> Script's * then -> than Several phrasing grammar fixes. Reviewed By: Blendify Differential Revision: https://developer.blender.org/D14021 --- doc/python_api/rst/info_api_reference.rst | 10 +++---- doc/python_api/rst/info_best_practice.rst | 6 ++-- doc/python_api/rst/info_gotcha.rst | 46 ++++++++++++++--------------- doc/python_api/rst/info_tips_and_tricks.rst | 6 ++-- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/python_api/rst/info_api_reference.rst b/doc/python_api/rst/info_api_reference.rst index 19d09aee66c..70d201016f0 100644 --- a/doc/python_api/rst/info_api_reference.rst +++ b/doc/python_api/rst/info_api_reference.rst @@ -22,7 +22,7 @@ Data Access =========== The most common case for using the reference API is to find out how to access data in the blend-file. -Before going any further its best to be aware of ID data-blocks in Blender since you will often find properties +Before going any further it's best to be aware of ID data-blocks in Blender since you will often find properties relative to them. @@ -55,9 +55,9 @@ Start by collecting the information where the data is located. First find this setting in the interface ``Properties editor -> Object -> Transform -> Location``. From the button context menu select *Online Python Reference*, this will link you to: :class:`bpy.types.Object.location`. -Being an API reference, this link often gives little more information then the tooltip, though some of the pages +Being an API reference, this link often gives little more information than the tooltip, though some of the pages include examples (normally at the top of the page). -But you now know that you have to use ``.location`` and that its an array of three floats. +But you now know that you have to use ``.location`` and that it's an array of three floats. So the next step is to find out where to access objects, go down to the bottom of the page to the references section, for objects there are many references, but one of the most common places to access objects is via the context. @@ -154,7 +154,7 @@ The tooltip includes :class:`bpy.types.SubsurfModifier.levels` but you want the Note that the text copied won't include the ``bpy.data.collection["name"].`` component since its assumed that you won't be doing collection look-ups on every access and typically you'll want to use the context rather -then access each :class:`bpy.types.ID` instance by name. +than access each :class:`bpy.types.ID` instance by name. Type in the ID path into a Python console :mod:`bpy.context.active_object`. Include the trailing dot and don't execute the code, yet. @@ -252,6 +252,6 @@ Each entry can be selected, then copied :kbd:`Ctrl-C`, usually to paste in the t .. note:: Not all operators get registered for display, - zooming the view for example isn't so useful to repeat so its excluded from the output. + zooming the view for example isn't so useful to repeat so it's excluded from the output. To display *every* operator that runs see :ref:`Show All Operators `. diff --git a/doc/python_api/rst/info_best_practice.rst b/doc/python_api/rst/info_best_practice.rst index 2607d047997..e88adcc0d70 100644 --- a/doc/python_api/rst/info_best_practice.rst +++ b/doc/python_api/rst/info_best_practice.rst @@ -229,7 +229,7 @@ removing the last items first, which is faster (as explained above): This example shows a fast way of removing items, -for use in cases where you can alter the list order without breaking the scripts functionality. +for use in cases where you can alter the list order without breaking the script's functionality. This works by swapping two list items, so the item you remove is always last: .. code-block:: python @@ -278,7 +278,7 @@ Here are three ways of joining multiple strings into one string for writing. This also applies to any area of your code that involves a lot of string joining: String concatenation - This is the slowest option, do **not** use if you can avoid it, especially when writing data in a loop. + This is the slowest option, do **not** use this if you can avoid it, especially when writing data in a loop. >>> file.write(str1 + " " + str2 + " " + str3 + "\n") @@ -288,7 +288,7 @@ String formatting >>> file.write("%s %s %s\n" % (str1, str2, str3)) String joining - Use to join a list of strings (the list may be temporary). In the following example, the strings are joined with + Use this to join a list of strings (the list may be temporary). In the following example, the strings are joined with a space " " in between, other examples are "" or ", ". >>> file.write(" ".join((str1, str2, str3, "\n"))) diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst index 867599dab68..bef76a5e479 100644 --- a/doc/python_api/rst/info_gotcha.rst +++ b/doc/python_api/rst/info_gotcha.rst @@ -12,7 +12,7 @@ that can be troublesome and avoid practices that are known to cause instability. Using Operators =============== -Blender's operators are tools for users to access, that can access with Python too which is very useful. +Blender's operators are tools for users to access, that can be accessed with Python too which is very useful. Still operators have limitations that can make them cumbersome to script. The main limits are: @@ -20,13 +20,13 @@ The main limits are: - Can't pass data such as objects, meshes or materials to operate on (operators use the context instead). - The return value from calling an operator is the success (if it finished or was canceled), in some cases it would be more logical from an API perspective to return the result of the operation. -- Operators poll function can fail where an API function would raise an exception giving details on exactly why. +- Operators' poll function can fail where an API function would raise an exception giving details on exactly why. Why does an operator's poll fail? --------------------------------- -When calling an operator gives an error like this: +When calling an operator it gives an error like this: >>> bpy.ops.action.clean(threshold=0.001) RuntimeError: Operator bpy.ops.action.clean.poll() failed, context is incorrect @@ -49,9 +49,9 @@ you should be able to find the poll function with no knowledge of C. .. note:: Blender does have the functionality for poll functions to describe why they fail, - but its currently not used much, if you're interested to help improve the API + but it's currently not used much, if you're interested to help improve the API feel free to add calls to :class:`bpy.types.Operator.poll_message_set` (``CTX_wm_operator_poll_msg_set`` in C) - where its not obvious why poll fails, e.g: + where it's not obvious why poll fails, e.g: >>> bpy.ops.gpencil.draw() RuntimeError: Operator bpy.ops.gpencil.draw.poll() Failed to find Grease Pencil data to draw into @@ -107,7 +107,7 @@ In this case you need to call :class:`bpy.types.ViewLayer.update` after modifyin Now all dependent data (child objects, modifiers, drivers, etc.) -has been recalculated and is available to the script within active view layer. +have been recalculated and are available to the script within the active view layer. Can I redraw during script execution? @@ -116,13 +116,13 @@ Can I redraw during script execution? The official answer to this is no, or... *"You don't want to do that"*. To give some background on the topic: -While a script executes Blender waits for it to finish and is effectively locked until its done, +While a script executes, Blender waits for it to finish and is effectively locked until it's done; while in this state Blender won't redraw or respond to user input. Normally this is not such a problem because scripts distributed with Blender tend not to run for an extended period of time, nevertheless scripts *can* take a long time to complete and it would be nice to see progress in the viewport. -When tools lock Blender in a loop redraw are highly discouraged +Tools that lock Blender in a loop redraw are highly discouraged since they conflict with Blender's ability to run multiple operators at once and update different parts of the interface as the tool runs. @@ -130,7 +130,7 @@ So the solution here is to write a **modal** operator, which is an operator that See the modal operator template in the text editor. Modal operators execute on user input or setup their own timers to run frequently, they can handle the events or pass through to be handled by the keymap or other modal operators. -Examples of a modal operators are Transform, Painting, Fly Navigation and File Select. +Examples of modal operators are Transform, Painting, Fly Navigation and File Select. Writing modal operators takes more effort than a simple ``for`` loop that contains draw calls but is more flexible and integrates better with Blender's design. @@ -240,7 +240,7 @@ Editing Editing is where the three data types vary most. - Polygons are very limited for editing, - changing materials and options like smooth works but for anything else + changing materials and options like smooth works, but for anything else they are too inflexible and are only intended for storage. - Tessfaces should not be used for editing geometry because doing so will cause existing n-gons to be tessellated. - BMesh-faces are by far the best way to manipulate geometry. @@ -256,7 +256,7 @@ the choice mostly depends on whether the target format supports n-gons or not. - Tessfaces work well for exporting to formats which don't support n-gons, in fact this is the only place where their use is encouraged. - BMesh-Faces can work for exporting too but may not be necessary if polygons can be used - since using BMesh gives some overhead because its not the native storage format in Object-Mode. + since using BMesh gives some overhead because it's not the native storage format in Object-Mode. Edit Bones, Pose Bones, Bone... Bones @@ -348,7 +348,7 @@ Armature Mode Switching While writing scripts that deal with armatures you may find you have to switch between modes, when doing so take care when switching out of Edit-Mode not to keep references to the edit bones or their head/tail vectors. -Further access to these will crash Blender so its important the script +Further access to these will crash Blender so it's important that the script clearly separates sections of the code which operate in different modes. This is mainly an issue with Edit-Mode since pose data can be manipulated without having to be in Pose-Mode, @@ -386,11 +386,11 @@ Or with name assignment: Data names may not match the assigned values if they exceed the maximum length, are already used or an empty string. -Its better practice not to reference objects by names at all, +It's better practice not to reference objects by names at all, once created you can store the data in a list, dictionary, on a class, etc; there is rarely a reason to have to keep searching for the same data by name. -If you do need to use name references, its best to use a dictionary to maintain +If you do need to use name references, it's best to use a dictionary to maintain a mapping between the names of the imported assets and the newly created data, this way you don't run this risk of referencing existing data from the blend-file, or worse modifying it. @@ -414,11 +414,11 @@ Library Collisions Blender keeps data names unique (:class:`bpy.types.ID.name`) so you can't name two objects, meshes, scenes, etc., the same by accident. However, when linking in library data from another blend-file naming collisions can occur, -so its best to avoid referencing data by name at all. +so it's best to avoid referencing data by name at all. -This can be tricky at times and not even Blender handles this correctly in some case +This can be tricky at times and not even Blender handles this correctly in some cases (when selecting the modifier object for e.g. you can't select between multiple objects with the same name), -but its still good to try avoiding these problems in this area. +but it's still good to try avoiding these problems in this area. If you need to select between local and library data, there is a feature in ``bpy.data`` members to allow for this. .. code-block:: python @@ -467,11 +467,11 @@ writing a script in ``latin1`` or ``iso-8859-15``. See `PEP 263 `__. However, this complicates matters for Blender's Python API because ``.blend`` files don't have an explicit encoding. -To avoid the problem for Python integration and script authors we have decided all strings in blend-files +To avoid the problem for Python integration and script authors we have decided that all strings in blend-files **must** be ``UTF-8``, ``ASCII`` compatible. -This means assigning strings with different encodings to an object names for instance will raise an error. +This means assigning strings with different encodings to an object name, for instance, will raise an error. -Paths are an exception to this rule since the existence of non-UTF-8 paths on user's file system cannot be ignored. +Paths are an exception to this rule since the existence of non-UTF-8 paths on the user's file system cannot be ignored. This means seemingly harmless expressions can raise errors, e.g: >>> print(bpy.data.filepath) @@ -505,7 +505,7 @@ to keep it short about encoding problems -- here are some suggestions: .. note:: Sometimes it's preferable to avoid string encoding issues by using bytes instead of Python strings, - when reading some input its less trouble to read it as binary data + when reading some input it's less trouble to read it as binary data though you will still need to decide how to treat any strings you want to use with Blender, some importers do this. @@ -679,7 +679,7 @@ Undo/Redo --------- For safety, you should assume that undo and redo always invalidates all :class:`bpy.types.ID` -instances (Object, Scene, Mesh, Light, etc.), as weel obviously as all of their sub-data. +instances (Object, Scene, Mesh, Light, etc.), as well obviously as all of their sub-data. This example shows how you can tell undo changes the memory locations: @@ -716,7 +716,7 @@ Tools in Blender are not allowed to modify library data. But Python does not enforce this restriction. This can be useful in some cases, using a script to adjust material values for example. -But its also possible to use a script to make library data point to newly created local data, +But it's also possible to use a script to make library data point to newly created local data, which is not supported since a call to undo will remove the local data but leave the library referencing it and likely crash. diff --git a/doc/python_api/rst/info_tips_and_tricks.rst b/doc/python_api/rst/info_tips_and_tricks.rst index d16dcc077df..691cfb50b4f 100644 --- a/doc/python_api/rst/info_tips_and_tricks.rst +++ b/doc/python_api/rst/info_tips_and_tricks.rst @@ -81,7 +81,7 @@ but reference an external file rather than including it directly. Executing External Scripts -------------------------- -This is the equivalent to running the script directly, referencing a scripts path from a two line code block. +This is the equivalent to running the script directly, referencing a script's path from a two line code block. .. code-block:: python @@ -124,7 +124,7 @@ small script which is often useful for testing different settings quickly. The other issue with this is the script has to be in Python's module search path. While this is not best practice -- for testing purposes you can extend the search path, -this following example adds the current blend-files directory to the search path +this following example adds the current blend-file's directory to the search path and then loads the script as a module. .. code-block:: python @@ -302,7 +302,7 @@ Python Safety (Build Option) ---------------------------- Since it's possible to access data which has been removed (see :doc:`Gotchas `), -can make it hard to track down the cause of crashes. +it can be hard to track down the cause of crashes. To raise Python exceptions on accessing freed data (rather than crashing), enable the CMake build option ``WITH_PYTHON_SAFETY``. This enables data tracking which makes data access about two times slower -- cgit v1.2.3 From 11d785edea7c96a34c4990b88ab833faa52b581c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 7 Feb 2022 20:51:03 +0100 Subject: Fix T95502: macOS app has both python 3.9 and 3.10 executables --- source/creator/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 6f23fbe486a..bc4d912405c 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -1104,9 +1104,9 @@ elseif(APPLE) ${TARGETDIR_VER}/python/lib ) - install(DIRECTORY ${LIBDIR}/python/bin - DESTINATION ${TARGETDIR_VER}/python - USE_SOURCE_PERMISSIONS + install( + PROGRAMS ${PYTHON_EXECUTABLE} + DESTINATION ${TARGETDIR_VER}/python/bin ) # Needed for distutils/pip -- cgit v1.2.3 From 229d0ace026ffb3591fdad4c5a6e0530c1243025 Mon Sep 17 00:00:00 2001 From: Wannes Malfait Date: Mon, 7 Feb 2022 16:08:36 -0600 Subject: Fix T95532: Merge node deletes everything for empty selections The problem was that nullptr was returned which is a valid value for Mesh * and hence the returned optional was treated as having some value. There was no check for point clouds so that was fixed as well. Differential Revision: https://developer.blender.org/D14026 --- source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc index 3c790079b5b..89227c773cc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc @@ -60,7 +60,7 @@ static std::optional mesh_merge_by_distance(const MeshComponent &mesh_co const IndexMask selection = evaluator.get_evaluated_as_mask(0); if (selection.is_empty()) { - return nullptr; + return std::nullopt; } const Mesh &mesh = *mesh_component.get_for_read(); @@ -78,7 +78,9 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry_set.has_pointcloud()) { PointCloud *result = pointcloud_merge_by_distance( *geometry_set.get_component_for_read(), merge_distance, selection); - geometry_set.replace_pointcloud(result); + if (result) { + geometry_set.replace_pointcloud(result); + } } if (geometry_set.has_mesh()) { std::optional result = mesh_merge_by_distance( -- cgit v1.2.3 From b76918717dbfd8363f4cf114619861dac0110e52 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 7 Feb 2022 18:42:31 -0600 Subject: Fix T95573: Incorrect bounding box of evaluated curve Account for `CurveEval`, which stores the proper deformed and procedurally created data, unlike the `nurb` list, which has always just meant a copy of the original curve. Also account for the case when the curve is empty by using a -1, 1, fallback bounding box in that case, just like mesh objects. --- source/blender/blenkernel/intern/curve.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index dda2b5076a8..f83a672b2ee 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -32,6 +32,7 @@ #include "BLI_ghash.h" #include "BLI_index_range.hh" #include "BLI_math.h" +#include "BLI_math_vec_types.hh" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -59,6 +60,7 @@ #include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_spline.hh" #include "BKE_vfont.h" #include "DEG_depsgraph.h" @@ -68,6 +70,7 @@ #include "BLO_read_write.h" +using blender::float3; using blender::IndexRange; /* globals */ @@ -503,7 +506,10 @@ BoundBox *BKE_curve_boundbox_get(Object *ob) float min[3], max[3]; INIT_MINMAX(min, max); - BKE_curve_minmax(cu, true, min, max); + if (!BKE_curve_minmax(cu, true, min, max)) { + copy_v3_fl(min, -1.0f); + copy_v3_fl(max, 1.0f); + } if (ob->runtime.bb == nullptr) { ob->runtime.bb = (BoundBox *)MEM_mallocN(sizeof(*ob->runtime.bb), __func__); @@ -5066,6 +5072,16 @@ void BKE_curve_nurb_vert_active_validate(Curve *cu) bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3]) { + if (cu->curve_eval != nullptr) { + float3 eval_min(FLT_MAX); + float3 eval_max(-FLT_MAX); + if (cu->curve_eval->bounds_min_max(eval_min, eval_max, false)) { + copy_v3_v3(min, eval_min); + copy_v3_v3(max, eval_max); + return true; + } + } + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); ListBase temp_nurb_lb = {nullptr, nullptr}; const bool is_font = (BLI_listbase_is_empty(nurb_lb)) && (cu->len != 0); -- cgit v1.2.3 From 7df651367fbd8c9510c7e02b18301bd2f28c3574 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2022 11:50:14 +1100 Subject: Cleanup: use an intermediate value for cast_primitive_type Assign the actual value before casting to large uint64_t/double types. This improves readability, especially in cases where both pointer and integer casts were used in one expression, to make matters worse clang-format treated these casts as a multiplication. This also made debugging/printing the values more of a hassle. No functional changes (GCC produced identical output). --- source/blender/makesdna/intern/dna_genfile.c | 60 ++++++++++++++++++---------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 6322cb459dd..7e9fabcc998 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -737,45 +737,65 @@ static void cast_primitive_type(const eSDNA_Type old_type, for (int a = 0; a < array_len; a++) { switch (old_type) { - case SDNA_TYPE_CHAR: - old_value_i = *old_data; + case SDNA_TYPE_CHAR: { + const char value = *old_data; + old_value_i = value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_UCHAR: - old_value_i = *((unsigned char *)old_data); + } + case SDNA_TYPE_UCHAR: { + const uchar value = *((uchar *)old_data); + old_value_i = value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_SHORT: - old_value_i = *((short *)old_data); + } + case SDNA_TYPE_SHORT: { + const short value = *((short *)old_data); + old_value_i = value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_USHORT: - old_value_i = *((unsigned short *)old_data); + } + case SDNA_TYPE_USHORT: { + const ushort value = *((unsigned short *)old_data); + old_value_i = value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_INT: - old_value_i = *((int *)old_data); + } + case SDNA_TYPE_INT: { + const int value = *((int *)old_data); + old_value_i = value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_FLOAT: - old_value_f = *((float *)old_data); + } + case SDNA_TYPE_FLOAT: { + const float value = *((float *)old_data); + old_value_f = value; old_value_i = (uint64_t)(int64_t)old_value_f; break; - case SDNA_TYPE_DOUBLE: - old_value_f = *((double *)old_data); + } + case SDNA_TYPE_DOUBLE: { + const double value = *((double *)old_data); + old_value_f = value; old_value_i = (uint64_t)(int64_t)old_value_f; break; - case SDNA_TYPE_INT64: - old_value_i = (uint64_t) * ((int64_t *)old_data); + } + case SDNA_TYPE_INT64: { + const int64_t value = *((int64_t *)old_data); + old_value_i = (uint64_t)value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_UINT64: - old_value_i = *((uint64_t *)old_data); + } + case SDNA_TYPE_UINT64: { + const uint64_t value = *((uint64_t *)old_data); + old_value_i = value; old_value_f = (double)old_value_i; break; - case SDNA_TYPE_INT8: - old_value_i = (uint64_t) * ((int8_t *)old_data); + } + case SDNA_TYPE_INT8: { + const int8_t value = *((int8_t *)old_data); + old_value_i = (uint64_t)value; old_value_f = (double)old_value_i; + } } switch (new_type) { -- cgit v1.2.3 From 9d674d9852db07ade16b521d1c0864b494d232e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2022 11:50:15 +1100 Subject: Fix dna_genfile error converting signed int types to floating point Regression in 51befa4108128a7bacf7a201046cf7ede999833a caused negative values to overflow into a uint64_t. Resolve by casting to a signed int from originally signed types. This caused D14033 not to work properly. --- source/blender/makesdna/intern/dna_genfile.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 7e9fabcc998..9a71e516389 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -733,6 +733,9 @@ static void cast_primitive_type(const eSDNA_Type old_type, const int curlen = DNA_elem_type_size(new_type); double old_value_f = 0.0; + /* Intentionally overflow signed values into an unsigned type. + * Casting back to a signed value preserves the sign (when the new value is signed). + * It's also important to cast to `int64_t` when setting `old_value_f` from a signed value. */ uint64_t old_value_i = 0; for (int a = 0; a < array_len; a++) { @@ -752,7 +755,7 @@ static void cast_primitive_type(const eSDNA_Type old_type, case SDNA_TYPE_SHORT: { const short value = *((short *)old_data); old_value_i = value; - old_value_f = (double)old_value_i; + old_value_f = (double)(int64_t)old_value_i; break; } case SDNA_TYPE_USHORT: { @@ -764,7 +767,7 @@ static void cast_primitive_type(const eSDNA_Type old_type, case SDNA_TYPE_INT: { const int value = *((int *)old_data); old_value_i = value; - old_value_f = (double)old_value_i; + old_value_f = (double)(int64_t)old_value_i; break; } case SDNA_TYPE_FLOAT: { @@ -782,7 +785,7 @@ static void cast_primitive_type(const eSDNA_Type old_type, case SDNA_TYPE_INT64: { const int64_t value = *((int64_t *)old_data); old_value_i = (uint64_t)value; - old_value_f = (double)old_value_i; + old_value_f = (double)(int64_t)old_value_i; break; } case SDNA_TYPE_UINT64: { @@ -794,7 +797,7 @@ static void cast_primitive_type(const eSDNA_Type old_type, case SDNA_TYPE_INT8: { const int8_t value = *((int8_t *)old_data); old_value_i = (uint64_t)value; - old_value_f = (double)old_value_i; + old_value_f = (double)(int64_t)old_value_i; } } -- cgit v1.2.3 From 667b4bc0e424fe7d61e4f0c7a2168675ed5fa39c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2022 14:25:31 +1100 Subject: Cleanup: clang-format --- source/blender/editors/space_view3d/view3d_buttons.c | 3 ++- source/blender/makesdna/intern/makesdna.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index bfc18eed847..6edb0a070c0 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1764,7 +1764,8 @@ static void view3d_panel_transform(const bContext *C, Panel *panel) v3d_transform_butsR(col, &obptr); /* Dimensions and editmode are mostly the same check. */ - if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || ELEM(ob->type, OB_VOLUME, OB_CURVES, OB_POINTCLOUD)) { + if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || + ELEM(ob->type, OB_VOLUME, OB_CURVES, OB_POINTCLOUD)) { View3D *v3d = CTX_wm_view3d(C); v3d_object_dimension_buts(NULL, col, v3d, ob); } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index b61f5315020..5156203b71f 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -1636,6 +1636,7 @@ int main(int argc, char **argv) #include "DNA_constraint_types.h" #include "DNA_curve_types.h" #include "DNA_curveprofile_types.h" +#include "DNA_curves_types.h" #include "DNA_customdata_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_effect_types.h" @@ -1644,7 +1645,6 @@ int main(int argc, char **argv) #include "DNA_freestyle_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" -#include "DNA_curves_types.h" #include "DNA_image_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" -- cgit v1.2.3 From 7047bd41c6f4aa3b2c34909e00fcfdb6fca44c9c Mon Sep 17 00:00:00 2001 From: Dominik Fill Date: Tue, 8 Feb 2022 14:55:02 +1100 Subject: UI: Change computation of node socket position to align with label This Diff changes the computation of the input and output socket position to being always aligned with its corresponding label. Reviewed By: campbellbarton Ref D14025 --- source/blender/editors/space_node/node_draw.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 81c63e9bddb..2ab0a3fff44 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -397,7 +397,7 @@ static void node_update_basis(const bContext &C, bNodeTree &ntree, bNode &node, /* Round the socket location to stop it from jiggling. */ nsock->locx = round(loc.x + NODE_WIDTH(node)); - nsock->locy = round(0.5f * (dy + buty)); + nsock->locy = round(dy - NODE_DYS); dy = buty; if (nsock->next) { @@ -527,7 +527,7 @@ static void node_update_basis(const bContext &C, bNodeTree &ntree, bNode &node, nsock->locx = loc.x; /* Round the socket vertical position to stop it from jiggling. */ - nsock->locy = round(0.5f * (dy + buty)); + nsock->locy = round(dy - NODE_DYS); dy = buty - multi_input_socket_offset * 0.5; if (nsock->next) { -- cgit v1.2.3 From 8abd8865d2e4743035eedad21a72c92d70474907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Tue, 8 Feb 2022 06:10:13 +0100 Subject: Mesh: add option to select vertices by similar vertex crease This adds an option to the "Select Similar" operator in edit mode to select vertices based on vertex crease similarity. The implementation follows that of the edge crease, with a 1-dimensional KD-tree used to store and retrieve vertex indices base on crease values. To maintain compatibility with old files (scripts), the `SIMEDGE_CREASE` enumeration identifier remains `CREASE`, while the one for the new `SIMVERT_CREASE` is `VCREASE` to follow the naming convention of other enum values. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D14037 --- source/blender/bmesh/intern/bmesh_operators.h | 1 + .../blender/editors/mesh/editmesh_select_similar.c | 45 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index e5ede75f737..900844af4e5 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -93,6 +93,7 @@ enum { SIMVERT_FACE, SIMVERT_VGROUP, SIMVERT_EDGE, + SIMVERT_CREASE, }; /* Poke face center calculation */ diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index 949b12f9a65..5ea3c0d7b32 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -68,6 +68,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMVERT_FACE, "FACE", 0, "Amount of Adjacent Faces", ""}, {SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""}, {SIMVERT_EDGE, "EDGE", 0, "Amount of Connecting Edges", ""}, + {SIMVERT_CREASE, "VCREASE", 0, "Vertex Crease", ""}, {SIMEDGE_LENGTH, "LENGTH", 0, "Length", ""}, {SIMEDGE_DIR, "DIR", 0, "Direction", ""}, @@ -1009,12 +1010,16 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } KDTree_3d *tree_3d = NULL; + KDTree_1d *tree_1d = NULL; GSet *gset = NULL; switch (type) { case SIMVERT_NORMAL: tree_3d = BLI_kdtree_3d_new(tot_verts_selected_all); break; + case SIMVERT_CREASE: + tree_1d = BLI_kdtree_1d_new(tot_verts_selected_all); + break; case SIMVERT_EDGE: case SIMVERT_FACE: gset = BLI_gset_ptr_new("Select similar vertex: edge/face"); @@ -1025,6 +1030,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } int normal_tree_index = 0; + int tree_1d_index = 0; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; BMEditMesh *em = BKE_editmesh_from_object(ob); @@ -1050,6 +1056,12 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } defbase_selected = BLI_BITMAP_NEW(defbase_len, __func__); } + else if (type == SIMVERT_CREASE) { + if (!CustomData_has_layer(&bm->vdata, CD_CREASE)) { + BLI_kdtree_1d_insert(tree_1d, tree_1d_index++, (float[1]){0.0f}); + continue; + } + } BMVert *vert; /* Mesh vertex. */ BMIter iter; /* Selected verts iterator. */ @@ -1085,6 +1097,11 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } break; } + case SIMVERT_CREASE: { + const float *value = CustomData_bmesh_get(&bm->vdata, vert->head.data, CD_CREASE); + BLI_kdtree_1d_insert(tree_1d, tree_1d_index++, value); + break; + } } } } @@ -1113,6 +1130,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } /* Remove duplicated entries. */ + if (tree_1d != NULL) { + BLI_kdtree_1d_deduplicate(tree_1d); + BLI_kdtree_1d_balance(tree_1d); + } if (tree_3d != NULL) { BLI_kdtree_3d_deduplicate(tree_3d); BLI_kdtree_3d_balance(tree_3d); @@ -1124,6 +1145,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; bool changed = false; + bool has_crease_layer = false; int cd_dvert_offset = -1; BLI_bitmap *defbase_selected = NULL; int defbase_len = 0; @@ -1158,6 +1180,17 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) continue; } } + else if (type == SIMVERT_CREASE) { + has_crease_layer = CustomData_has_layer(&bm->vdata, CD_CREASE); + if (!has_crease_layer) { + /* Proceed only if we have to select all the vertices that have custom data value of 0.0f. + * In this case we will just select all the vertices. + * Otherwise continue the for loop. */ + if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, compare)) { + continue; + } + } + } BMVert *vert; /* Mesh vertex. */ BMIter iter; /* Selected verts iterator. */ @@ -1224,6 +1257,17 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } break; } + case SIMVERT_CREASE: { + if (!has_crease_layer) { + select = true; + break; + } + const float *value = CustomData_bmesh_get(&bm->vdata, vert->head.data, CD_CREASE); + if (ED_select_similar_compare_float_tree(tree_1d, *value, thresh, compare)) { + select = true; + } + break; + } } if (select) { @@ -1249,6 +1293,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } MEM_freeN(objects); + BLI_kdtree_1d_free(tree_1d); BLI_kdtree_3d_free(tree_3d); if (gset != NULL) { BLI_gset_free(gset, NULL); -- cgit v1.2.3 From 67c12ed765942ec27072fb0a2dfad2364d21d8c1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 8 Feb 2022 09:16:49 +0100 Subject: Cleanup: remove useless statement. Layouts are active by default when created, no need to set this explicitely. Leftover from proxy removal. --- release/scripts/startup/bl_ui/properties_data_armature.py | 1 - 1 file changed, 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 2a6bd53bff5..7fb8791f856 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -149,7 +149,6 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN' split = layout.split() - split.active = True col = split.column() col.prop(group, "color_set") -- cgit v1.2.3 From 1995aae6e3bf3c51b3945d6d31b4ad20fd11fb73 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 5 Jan 2022 12:32:00 +0100 Subject: Fix T94415: Nodes: poor selection behavior inside frame nodes Previously, node selection made no distinction between a frame node and other nodes. So a frame node would be selected by their whole rect or center (depending on box/lasso/circle select). As a consequence of this, box and lasso could not pratically be started inside a frame node (with the intention to select a subset of contained child nodes) because the frame would be selected immediately and tweak-transforming started. Circle selecting would always contain the frame node as well (making transforming a subset of nodes without also transforming the whole frame impossible). Now change selection behavior so that for all selection modes only the border [the margin area that is automatically added around all nodes, see note below] of a frame node is considered in selection. This makes for a much more intuitive experience when arranging nodes inside frames. note: to make the area of interest for selection/moving more obvious, the cursor changes when hovering over (as is done for resizing). note: this also makes the resize margin consistent with other nodes. note: this also fixes right resize border (was exclusive instead of inclusive as every other border) Also fixes T46540. --- source/blender/editors/space_node/drawnode.cc | 5 +- source/blender/editors/space_node/node_draw.cc | 7 + source/blender/editors/space_node/node_intern.hh | 2 + source/blender/editors/space_node/node_select.cc | 156 +++++++++++++++++++---- 4 files changed, 140 insertions(+), 30 deletions(-) diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 94da7d55e5d..30f2cc970bd 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -231,7 +231,6 @@ static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt NodeResizeDirection node_get_resize_direction(const bNode *node, const int x, const int y) { if (node->type == NODE_FRAME) { - const float size = 10.0f; NodeFrame *data = (NodeFrame *)node->storage; /* shrinking frame size is determined by child nodes */ @@ -242,7 +241,9 @@ NodeResizeDirection node_get_resize_direction(const bNode *node, const int x, co NodeResizeDirection dir = NODE_RESIZE_NONE; const rctf &totr = node->totr; - if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) { + const float size = NODE_RESIZE_MARGIN; + + if (x > totr.xmax - size && x <= totr.xmax && y >= totr.ymin && y < totr.ymax) { dir |= NODE_RESIZE_RIGHT; } if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) { diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 834bb3e5802..2c47883d831 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2270,6 +2270,13 @@ void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor) if (node) { NodeResizeDirection dir = node_get_resize_direction(node, cursor[0], cursor[1]); wmcursor = node_get_resize_cursor(dir); + /* We want to indicate that Frame nodes can be moved/selected on their borders. */ + if (node->type == NODE_FRAME && dir == NODE_RESIZE_NONE) { + const rctf frame_inside = node_frame_rect_inside(*node); + if (!BLI_rctf_isect_pt(&frame_inside, cursor[0], cursor[1])) { + wmcursor = WM_CURSOR_NSEW_SCROLL; + } + } } WM_cursor_set(&win, wmcursor); diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index c161fc70402..95f771cc00b 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -119,6 +119,8 @@ float2 node_link_calculate_multi_input_position(const float2 &socket_position, int index, int total_inputs); +rctf node_frame_rect_inside(const bNode &node); + int node_get_resize_cursor(NodeResizeDirection directions); NodeResizeDirection node_get_resize_direction(const bNode *node, int x, int y); /** diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index 2751a53e8af..6b0fa2cc37c 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -99,11 +99,51 @@ static bool has_workbench_in_texture_color(const wmWindowManager *wm, /** \name Public Node Selection API * \{ */ +rctf node_frame_rect_inside(const bNode &node) +{ + const float margin = 1.5f * U.widget_unit; + rctf frame_inside = { + node.totr.xmin, + node.totr.xmax, + node.totr.ymin, + node.totr.ymax, + }; + + BLI_rctf_pad(&frame_inside, -margin, -margin); + + return frame_inside; +} + +static bool node_frame_select_isect_mouse(bNode *node, const float2 &mouse) +{ + /* Frame nodes are selectable by their borders (including their whole rect - as for other nodes - + * would prevent e.g. box selection of nodes inside that frame). */ + const rctf frame_inside = node_frame_rect_inside(*node); + if (BLI_rctf_isect_pt(&node->totr, mouse.x, mouse.y) && + !BLI_rctf_isect_pt(&frame_inside, mouse.x, mouse.y)) { + return true; + } + + return false; +} + static bNode *node_under_mouse_select(bNodeTree &ntree, int mx, int my) { LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree.nodes) { - if (BLI_rctf_isect_pt(&node->totr, mx, my)) { - return node; + switch (node->type) { + case NODE_FRAME: { + const float2 mouse{(float)mx, (float)my}; + if (node_frame_select_isect_mouse(node, mouse)) { + return node; + } + break; + } + default: { + if (BLI_rctf_isect_pt(&node->totr, mx, my)) { + return node; + } + break; + } } } return nullptr; @@ -114,15 +154,27 @@ static bNode *node_under_mouse_tweak(bNodeTree &ntree, const float2 &mouse) using namespace blender::math; LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree.nodes) { - if (node->type == NODE_REROUTE) { - bNodeSocket *socket = (bNodeSocket *)node->inputs.first; - const float2 location{socket->locx, socket->locy}; - if (distance(mouse, location) < 24.0f) { - return node; + switch (node->type) { + case NODE_REROUTE: { + bNodeSocket *socket = (bNodeSocket *)node->inputs.first; + const float2 location{socket->locx, socket->locy}; + if (distance(mouse, location) < 24.0f) { + return node; + } + break; + } + case NODE_FRAME: { + if (node_frame_select_isect_mouse(node, mouse)) { + return node; + } + break; + } + default: { + if (BLI_rctf_isect_pt(&node->totr, mouse.x, mouse.y)) { + return node; + } + break; } - } - if (BLI_rctf_isect_pt(&node->totr, mouse.x, mouse.y)) { - return node; } } return nullptr; @@ -687,12 +739,24 @@ static int node_box_select_exec(bContext *C, wmOperator *op) } LISTBASE_FOREACH (bNode *, node, &node_tree.nodes) { - bool is_inside; - if (node->type == NODE_FRAME) { - is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr); - } - else { - is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr); + bool is_inside = false; + + switch (node->type) { + case NODE_FRAME: { + /* Frame nodes are selectable by their borders (including their whole rect - as for other + * nodes - would prevent selection of other nodes inside that frame. */ + const rctf frame_inside = node_frame_rect_inside(*node); + if (BLI_rctf_isect(&rectf, &node->totr, NULL) && + !BLI_rctf_inside_rctf(&frame_inside, &rectf)) { + nodeSetSelected(node, select); + is_inside = true; + } + break; + } + default: { + is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr); + break; + } } if (is_inside) { @@ -781,8 +845,25 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(®ion->v2d, x, y, &offset[0], &offset[1]); for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) { - if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) { - nodeSetSelected(node, select); + switch (node->type) { + case NODE_FRAME: { + /* Frame nodes are selectable by their borders (including their whole rect - as for other + * nodes - would prevent selection of _only_ other nodes inside that frame. */ + rctf frame_inside = node_frame_rect_inside(*node); + const float radius_adjusted = (float)radius / zoom; + BLI_rctf_pad(&frame_inside, -2.0f * radius_adjusted, -2.0f * radius_adjusted); + if (BLI_rctf_isect_circle(&node->totr, offset, radius_adjusted) && + !BLI_rctf_isect_circle(&frame_inside, offset, radius_adjusted)) { + nodeSetSelected(node, select); + } + break; + } + default: { + if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) { + nodeSetSelected(node, select); + } + break; + } } } @@ -859,16 +940,35 @@ static bool do_lasso_select_node(bContext *C, continue; } - int screen_co[2]; - const float cent[2] = {BLI_rctf_cent_x(&node->totr), BLI_rctf_cent_y(&node->totr)}; - - /* marker in screen coords */ - if (UI_view2d_view_to_region_clip( - ®ion->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) && - BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && - BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) { - nodeSetSelected(node, select); - changed = true; + switch (node->type) { + case NODE_FRAME: { + /* Frame nodes are selectable by their borders (including their whole rect - as for other + * nodes - would prevent selection of other nodes inside that frame. */ + rctf rectf; + BLI_rctf_rcti_copy(&rectf, &rect); + UI_view2d_region_to_view_rctf(®ion->v2d, &rectf, &rectf); + const rctf frame_inside = node_frame_rect_inside(*node); + if (BLI_rctf_isect(&rectf, &node->totr, NULL) && + !BLI_rctf_inside_rctf(&frame_inside, &rectf)) { + nodeSetSelected(node, select); + changed = true; + } + break; + } + default: { + int screen_co[2]; + const float cent[2] = {BLI_rctf_cent_x(&node->totr), BLI_rctf_cent_y(&node->totr)}; + + /* marker in screen coords */ + if (UI_view2d_view_to_region_clip( + ®ion->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) && + BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && + BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) { + nodeSetSelected(node, select); + changed = true; + } + break; + } } } -- cgit v1.2.3 From 32278b79a8de225a0edefa3d07693a098611a412 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 12 Jan 2022 10:43:42 +0100 Subject: LibOverride: Add 'hierarchy root ID' info. This change will make handling of liboverrides hierarchies (especially resyncing) much easier and efficient. It should also make it more resilient to 'degenerate' cases, and allow proper support of things like parenting an override to another override of the same linked data (e.g. a override character parented to another override of the same character). NOTE: this commit only implements minimal changes to add that data and generate it for existing files on load. Actual refactor of resync code to take advantage of this new info will happen separately. --- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenkernel/BKE_lib_override.h | 11 +- source/blender/blenkernel/intern/blendfile.c | 4 + source/blender/blenkernel/intern/lib_override.c | 201 ++++++++++++++++++++- source/blender/blenkernel/intern/lib_query.c | 2 + source/blender/blenloader/intern/readfile.c | 1 + .../editors/interface/interface_templates.c | 7 + source/blender/makesdna/DNA_ID.h | 9 +- source/blender/makesrna/intern/rna_ID.c | 7 + 9 files changed, 237 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index fe656166ada..1ba887903c8 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -39,7 +39,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 2 +#define BLENDER_FILE_SUBVERSION 3 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h index e8065566c97..e24f8dd8927 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -113,7 +113,7 @@ struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain, */ bool BKE_lib_override_library_create_from_tag(struct Main *bmain, struct Library *owner_library, - const struct Library *reference_library, + const struct ID *id_root_reference, bool do_no_main); /** * Advanced 'smart' function to create fully functional overrides. @@ -172,6 +172,15 @@ bool BKE_lib_override_library_proxy_convert(struct Main *bmain, */ void BKE_lib_override_library_main_proxy_convert(struct Main *bmain, struct BlendFileReadReport *reports); + +/** + * Find and set the 'hierarchy root' ID pointer of all library overrides in given `bmain`. + * + * NOTE: Cannot be called from `do_versions_after_linking` as this code needs a single complete + * Main database, not a split-by-libraries one. + */ +void BKE_lib_override_library_main_hierarchy_root_ensure(struct Main *bmain); + /** * Advanced 'smart' function to resync, re-create fully functional overrides up-to-date with linked * data, from an existing override hierarchy. diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 86c2593e2e6..07fd859765a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -374,6 +374,10 @@ static void setup_app_data(bContext *C, BKE_lib_override_library_main_proxy_convert(bmain, reports); } + if (mode != LOAD_UNDO && !blendfile_or_libraries_versions_atleast(bmain, 302, 3)) { + BKE_lib_override_library_main_hierarchy_root_ensure(bmain); + } + bmain->recovered = 0; /* startup.blend or recovered startup */ diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 314351e4ad7..a4cd057d7a9 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -161,6 +161,8 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f (ID *)src_id; id_us_plus(dst_id->override_library->reference); + dst_id->override_library->hierarchy_root = src_id->override_library->hierarchy_root; + if (do_full_copy) { BLI_duplicatelist(&dst_id->override_library->properties, &src_id->override_library->properties); @@ -293,6 +295,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain, * mess in case there are a lot of hidden, non-instantiated, non-properly organized dependencies. * Ref T94650. */ local_id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY; + local_id->override_library->hierarchy_root = local_id; if (do_tagged_remap) { Key *reference_key, *local_key = NULL; @@ -328,9 +331,11 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain, bool BKE_lib_override_library_create_from_tag(Main *bmain, Library *owner_library, - const Library *reference_library, + const ID *id_root_reference, const bool do_no_main) { + const Library *reference_library = id_root_reference->lib; + ID *reference_id; bool success = true; @@ -383,6 +388,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, /* Only remap new local ID's pointers, we don't want to force our new overrides onto our whole * existing linked IDs usages. */ if (success) { + ID *hierarchy_root_id = id_root_reference->newid; + for (todo_id_iter = todo_ids.first; todo_id_iter != NULL; todo_id_iter = todo_id_iter->next) { reference_id = todo_id_iter->data; ID *local_id = reference_id->newid; @@ -391,6 +398,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, continue; } + local_id->override_library->hierarchy_root = hierarchy_root_id; + Key *reference_key, *local_key = NULL; if ((reference_key = BKE_key_from_id(reference_id)) != NULL) { local_key = BKE_key_from_id(reference_id->newid); @@ -865,7 +874,10 @@ static bool lib_override_library_create_do(Main *bmain, BKE_main_relations_free(bmain); lib_override_group_tag_data_clear(&data); - return BKE_lib_override_library_create_from_tag(bmain, owner_library, id_root->lib, false); + const bool success = BKE_lib_override_library_create_from_tag( + bmain, owner_library, id_root, false); + + return success; } static void lib_override_library_create_post_process(Main *bmain, @@ -1047,6 +1059,189 @@ bool BKE_lib_override_library_template_create(struct ID *id) return true; } +static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int *r_best_level) +{ + if (curr_level > 1000) { + CLOG_ERROR(&LOG, + "Levels of dependency relationships between library overrides IDs is way too high, " + "skipping further processing loops (involves at least '%s')", + id->name); + BLI_assert(0); + return NULL; + } + + if (!ID_IS_OVERRIDE_LIBRARY(id)) { + BLI_assert(0); + return NULL; + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); + BLI_assert(entry != NULL); + + int best_level_candidate = curr_level; + ID *best_root_id_candidate = id; + + for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; + from_id_entry = from_id_entry->next) { + if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + ID *from_id = from_id_entry->id_pointer.from; + if (ELEM(from_id, NULL, id)) { + continue; + } + if (!ID_IS_OVERRIDE_LIBRARY(from_id) || (from_id->lib != id->lib)) { + continue; + } + + int level_candidate = curr_level + 1; + /* Recursively process the parent. */ + ID *root_id_candidate = lib_override_root_find( + bmain, from_id, curr_level + 1, &level_candidate); + if (level_candidate > best_level_candidate && root_id_candidate != NULL) { + best_root_id_candidate = root_id_candidate; + best_level_candidate = level_candidate; + } + } + + *r_best_level = best_level_candidate; + return best_root_id_candidate; +} + +static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID *id_from) +{ + if (ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + if (id->override_library->hierarchy_root == id_root) { + /* Already set, nothing else to do here, sub-hierarchy is also assumed to be properly set + * then. */ + return; + } + + /* Hierarchy root already set, and not matching currently propsed one, try to find which is + * best. */ + if (id->override_library->hierarchy_root != NULL) { + /* Check if given `id_from` matches with the hierarchy of the linked reference ID, in which + * case we assume that the given hierarchy root is the 'real' one. + * + * NOTE: This can fail if user mixed dependencies between several overrides of a same + * reference linked hierarchy. Not much to be done in that case, it's virtually impossible to + * fix this automatically in a reliable way. */ + if (id_from == NULL || !ID_IS_OVERRIDE_LIBRARY_REAL(id_from)) { + /* Too complicated to deal with for now. */ + CLOG_WARN(&LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tNot enough data to verify validity of current proposed root '%s', assuming " + "already set one '%s' is valid.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + return; + } + + ID *id_from_ref = id_from->override_library->reference; + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, + id->override_library->reference); + BLI_assert(entry != NULL); + + bool do_replace_root = false; + for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; + from_id_entry = from_id_entry->next) { + if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + if (id_from_ref == from_id_entry->id_pointer.from) { + /* A matching parent was found in reference linked data, assume given hierarchy root is + * the valid one. */ + do_replace_root = true; + CLOG_WARN( + &LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tCurrent proposed root '%s' detected as valid, will replace already set one '%s'.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + break; + } + } + + if (!do_replace_root) { + CLOG_WARN( + &LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tCurrent proposed root '%s' not detected as valid, keeping already set one '%s'.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + return; + } + } + + id->override_library->hierarchy_root = id_root; + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); + BLI_assert(entry != NULL); + + for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL; + to_id_entry = to_id_entry->next) { + if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + ID *to_id = *to_id_entry->id_pointer.to; + if (ELEM(to_id, NULL, id)) { + continue; + } + if (!ID_IS_OVERRIDE_LIBRARY(to_id) || (to_id->lib != id->lib)) { + continue; + } + + /* Recursively process the sub-hierarchy. */ + lib_override_root_hierarchy_set(bmain, id_root, to_id, id); + } +} + +void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) +{ + ID *id; + + BKE_main_relations_create(bmain, 0); + + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + continue; + } + if (id->override_library->hierarchy_root != NULL) { + continue; + } + + int best_level = 0; + ID *id_root = lib_override_root_find(bmain, id, best_level, &best_level); + + if (!ELEM(id_root->override_library->hierarchy_root, id_root, NULL)) { + CLOG_WARN(&LOG, + "Potential inconsistency in library override hierarchy of ID '%s', detected as " + "part of the hierarchy of '%s', which has a different root '%s'", + id->name, + id_root->name, + id_root->override_library->hierarchy_root->name); + continue; + } + + lib_override_root_hierarchy_set(bmain, id_root, id_root, NULL); + + BLI_assert(id->override_library->hierarchy_root != NULL); + } + FOREACH_MAIN_ID_END; + + BKE_main_relations_free(bmain); +} + static void lib_override_library_remap(Main *bmain, const ID *id_root_reference, GHash *linkedref_to_old_override) @@ -1214,7 +1409,7 @@ static bool lib_override_library_resync(Main *bmain, * override IDs (including within the old overrides themselves, since those are tagged too * above). */ const bool success = BKE_lib_override_library_create_from_tag( - bmain, NULL, id_root_reference->lib, true); + bmain, NULL, id_root_reference, true); if (!success) { return success; diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index f69fba5b540..f49af9abffe 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -323,6 +323,8 @@ static bool library_foreach_ID_link(Main *bmain, IDWALK_CB_USER | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE); CALLBACK_INVOKE_ID(id->override_library->storage, IDWALK_CB_USER | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE); + + CALLBACK_INVOKE_ID(id->override_library->hierarchy_root, IDWALK_CB_LOOPBACK); } IDP_foreach_property(id->properties, diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 90366f5b80d..6757177a385 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1999,6 +1999,7 @@ static void lib_link_id(BlendLibReader *reader, ID *id) if (id->override_library) { BLO_read_id_address(reader, id->lib, &id->override_library->reference); BLO_read_id_address(reader, id->lib, &id->override_library->storage); + BLO_read_id_address(reader, id->lib, &id->override_library->hierarchy_root); } lib_link_id_embedded_id(reader, id); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1f81dd21b83..03d0cba5ec8 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -667,6 +667,13 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) /* Assign new pointer, takes care of updates/notifiers */ RNA_id_pointer_create(override_id, &idptr); + /* Insert into override hierarchy if possible. */ + ID *owner_id = template_ui->ptr.owner_id; + if (owner_id != NULL && ID_IS_OVERRIDE_LIBRARY_REAL(owner_id)) { + override_id->override_library->hierarchy_root = + owner_id->override_library->hierarchy_root; + owner_id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY; + } } undo_push_label = "Make Library Override"; } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 4f479abe2b0..cfee35e147a 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -310,6 +310,13 @@ typedef struct IDOverrideLibrary { /** List of IDOverrideLibraryProperty structs. */ ListBase properties; + /** Override hierarchy root ID. Usually the actual root of the hierarchy, but not always + * in degenerated cases. + * + * All liboverrides of a same hierarchy (e.g. a character collection) share the same root. + */ + struct ID *hierarchy_root; + /* Read/write data. */ /* Temp ID storing extra override data (used for differential operations only currently). * Always NULL outside of read/write context. */ @@ -317,8 +324,6 @@ typedef struct IDOverrideLibrary { IDOverrideLibraryRuntime *runtime; - void *_pad_0; - unsigned int flag; char _pad_1[4]; } IDOverrideLibrary; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 9bb78cb483d..e7f885b2160 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -1822,6 +1822,13 @@ static void rna_def_ID_override_library(BlenderRNA *brna) srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override"); RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); + RNA_def_pointer( + srna, + "hierarchy_root", + "ID", + "Hierarchy Root ID", + "Library override ID used as root of the override hierarchy this ID is a member of"); + prop = RNA_def_boolean(srna, "is_in_hierarchy", true, -- cgit v1.2.3 From 98c242affddf88c524f5c76bc9d6eb8b0ba31181 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 12 Jan 2022 10:43:42 +0100 Subject: LibOverride: Add 'hierarchy root ID' info. This change will make handling of liboverrides hierarchies (especially resyncing) much easier and efficient. It should also make it more resilient to 'degenerate' cases, and allow proper support of things like parenting an override to another override of the same linked data (e.g. a override character parented to another override of the same character). NOTE: this commit only implements minimal changes to add that data and generate it for existing files on load. Actual refactor of resync code to take advantage of this new info will happen separately. --- source/blender/blenkernel/intern/lib_override.c | 183 ++++++++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index a4cd057d7a9..31e8e105eb6 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -1242,6 +1242,189 @@ void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) BKE_main_relations_free(bmain); } +static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int *r_best_level) +{ + if (curr_level > 1000) { + CLOG_ERROR(&LOG, + "Levels of dependency relationships between library overrides IDs is way too high, " + "skipping further processing loops (involves at least '%s')", + id->name); + BLI_assert(0); + return NULL; + } + + if (!ID_IS_OVERRIDE_LIBRARY(id)) { + BLI_assert(0); + return NULL; + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); + BLI_assert(entry != NULL); + + int best_level_candidate = curr_level; + ID *best_root_id_candidate = id; + + for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; + from_id_entry = from_id_entry->next) { + if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + ID *from_id = from_id_entry->id_pointer.from; + if (ELEM(from_id, NULL, id)) { + continue; + } + if (!ID_IS_OVERRIDE_LIBRARY(from_id) || (from_id->lib != id->lib)) { + continue; + } + + int level_candidate = curr_level + 1; + /* Recursively process the parent. */ + ID *root_id_candidate = lib_override_root_find( + bmain, from_id, curr_level + 1, &level_candidate); + if (level_candidate > best_level_candidate && root_id_candidate != NULL) { + best_root_id_candidate = root_id_candidate; + best_level_candidate = level_candidate; + } + } + + *r_best_level = best_level_candidate; + return best_root_id_candidate; +} + +static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID *id_from) +{ + if (ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + if (id->override_library->hierarchy_root == id_root) { + /* Already set, nothing else to do here, sub-hierarchy is also assumed to be properly set + * then. */ + return; + } + + /* Hierarchy root already set, and not matching currently propsed one, try to find which is + * best. */ + if (id->override_library->hierarchy_root != NULL) { + /* Check if given `id_from` matches with the hierarchy of the linked reference ID, in which + * case we assume that the given hierarchy root is the 'real' one. + * + * NOTE: This can fail if user mixed dependencies between several overrides of a same + * reference linked hierarchy. Not much to be done in that case, it's virtually impossible to + * fix this automatically in a reliable way. */ + if (id_from == NULL || !ID_IS_OVERRIDE_LIBRARY_REAL(id_from)) { + /* Too complicated to deal with for now. */ + CLOG_WARN(&LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tNot enough data to verify validity of current proposed root '%s', assuming " + "already set one '%s' is valid.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + return; + } + + ID *id_from_ref = id_from->override_library->reference; + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, + id->override_library->reference); + BLI_assert(entry != NULL); + + bool do_replace_root = false; + for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; + from_id_entry = from_id_entry->next) { + if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + if (id_from_ref == from_id_entry->id_pointer.from) { + /* A matching parent was found in reference linked data, assume given hierarchy root is + * the valid one. */ + do_replace_root = true; + CLOG_WARN( + &LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tCurrent proposed root '%s' detected as valid, will replace already set one '%s'.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + break; + } + } + + if (!do_replace_root) { + CLOG_WARN( + &LOG, + "Inconsistency in library override hierarchy of ID '%s'.\n" + "\tCurrent proposed root '%s' not detected as valid, keeping already set one '%s'.", + id->name, + id_root->name, + id->override_library->hierarchy_root->name); + return; + } + } + + id->override_library->hierarchy_root = id_root; + } + + MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); + BLI_assert(entry != NULL); + + for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL; + to_id_entry = to_id_entry->next) { + if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { + /* Never consider non-overridable relationships as actual dependencies. */ + continue; + } + + ID *to_id = *to_id_entry->id_pointer.to; + if (ELEM(to_id, NULL, id)) { + continue; + } + if (!ID_IS_OVERRIDE_LIBRARY(to_id) || (to_id->lib != id->lib)) { + continue; + } + + /* Recursively process the sub-hierarchy. */ + lib_override_root_hierarchy_set(bmain, id_root, to_id, id); + } +} + +void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) +{ + ID *id; + + BKE_main_relations_create(bmain, 0); + + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + continue; + } + if (id->override_library->hierarchy_root != NULL) { + continue; + } + + int best_level = 0; + ID *id_root = lib_override_root_find(bmain, id, best_level, &best_level); + + if (!ELEM(id_root->override_library->hierarchy_root, id_root, NULL)) { + CLOG_WARN(&LOG, + "Potential inconsistency in library override hierarchy of ID '%s', detected as " + "part of the hierarchy of '%s', which has a different root '%s'", + id->name, + id_root->name, + id_root->override_library->hierarchy_root->name); + continue; + } + + lib_override_root_hierarchy_set(bmain, id_root, id_root, NULL); + + BLI_assert(id->override_library->hierarchy_root != NULL); + } + FOREACH_MAIN_ID_END; + + BKE_main_relations_free(bmain); +} + static void lib_override_library_remap(Main *bmain, const ID *id_root_reference, GHash *linkedref_to_old_override) -- cgit v1.2.3 From 923ccf6b106ad3cb3900eb1062ac82ef21e3bb7e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 12 Jan 2022 12:27:44 +0100 Subject: LibOverride: Use new 'hierarchy root' info in relevant override code. This new info simplifies greatly the handling of resync and deleting liboverride hierarchies, and makes those operations more robust to complex dependencies cases between different hierarchies. Related to T95283. --- source/blender/blenkernel/intern/lib_override.c | 250 +++--------------------- 1 file changed, 28 insertions(+), 222 deletions(-) diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 31e8e105eb6..7158b71d7f1 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -468,6 +468,7 @@ typedef struct LibOverrideGroupTagData { Main *bmain; Scene *scene; ID *id_root; + ID *hierarchy_root_id; uint tag; uint missing_tag; /* Whether we are looping on override data, or their references (linked) one. */ @@ -778,6 +779,8 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * BLI_assert(ID_IS_OVERRIDE_LIBRARY(id_owner)); BLI_assert(data->is_override); + ID *id_hierarchy_root = data->hierarchy_root_id; + if (ID_IS_OVERRIDE_LIBRARY_REAL(id_owner) && (id_owner->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) != 0) { return; @@ -809,9 +812,15 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * if (ELEM(to_id, NULL, id_owner)) { continue; } + /* Different libraries or different hierarchy roots are break points in override hierarchies. + */ if (!ID_IS_OVERRIDE_LIBRARY(to_id) || (to_id->lib != id_owner->lib)) { continue; } + if (ID_IS_OVERRIDE_LIBRARY_REAL(to_id) && + to_id->override_library->hierarchy_root != id_hierarchy_root) { + continue; + } Library *reference_lib = lib_override_get(bmain, id_owner)->reference->lib; ID *to_id_reference = lib_override_get(bmain, to_id)->reference; @@ -841,6 +850,11 @@ static void lib_override_overrides_group_tag(LibOverrideGroupTagData *data) BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root)); BLI_assert(data->is_override); + ID *id_hierarchy_root = data->hierarchy_root_id; + BLI_assert(id_hierarchy_root != NULL); + BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root)); + UNUSED_VARS_NDEBUG(id_hierarchy_root); + if (id_root->override_library->reference->tag & LIB_TAG_MISSING) { id_root->tag |= data->missing_tag; } @@ -1242,189 +1256,6 @@ void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) BKE_main_relations_free(bmain); } -static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int *r_best_level) -{ - if (curr_level > 1000) { - CLOG_ERROR(&LOG, - "Levels of dependency relationships between library overrides IDs is way too high, " - "skipping further processing loops (involves at least '%s')", - id->name); - BLI_assert(0); - return NULL; - } - - if (!ID_IS_OVERRIDE_LIBRARY(id)) { - BLI_assert(0); - return NULL; - } - - MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); - BLI_assert(entry != NULL); - - int best_level_candidate = curr_level; - ID *best_root_id_candidate = id; - - for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; - from_id_entry = from_id_entry->next) { - if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { - /* Never consider non-overridable relationships as actual dependencies. */ - continue; - } - - ID *from_id = from_id_entry->id_pointer.from; - if (ELEM(from_id, NULL, id)) { - continue; - } - if (!ID_IS_OVERRIDE_LIBRARY(from_id) || (from_id->lib != id->lib)) { - continue; - } - - int level_candidate = curr_level + 1; - /* Recursively process the parent. */ - ID *root_id_candidate = lib_override_root_find( - bmain, from_id, curr_level + 1, &level_candidate); - if (level_candidate > best_level_candidate && root_id_candidate != NULL) { - best_root_id_candidate = root_id_candidate; - best_level_candidate = level_candidate; - } - } - - *r_best_level = best_level_candidate; - return best_root_id_candidate; -} - -static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID *id_from) -{ - if (ID_IS_OVERRIDE_LIBRARY_REAL(id)) { - if (id->override_library->hierarchy_root == id_root) { - /* Already set, nothing else to do here, sub-hierarchy is also assumed to be properly set - * then. */ - return; - } - - /* Hierarchy root already set, and not matching currently propsed one, try to find which is - * best. */ - if (id->override_library->hierarchy_root != NULL) { - /* Check if given `id_from` matches with the hierarchy of the linked reference ID, in which - * case we assume that the given hierarchy root is the 'real' one. - * - * NOTE: This can fail if user mixed dependencies between several overrides of a same - * reference linked hierarchy. Not much to be done in that case, it's virtually impossible to - * fix this automatically in a reliable way. */ - if (id_from == NULL || !ID_IS_OVERRIDE_LIBRARY_REAL(id_from)) { - /* Too complicated to deal with for now. */ - CLOG_WARN(&LOG, - "Inconsistency in library override hierarchy of ID '%s'.\n" - "\tNot enough data to verify validity of current proposed root '%s', assuming " - "already set one '%s' is valid.", - id->name, - id_root->name, - id->override_library->hierarchy_root->name); - return; - } - - ID *id_from_ref = id_from->override_library->reference; - MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, - id->override_library->reference); - BLI_assert(entry != NULL); - - bool do_replace_root = false; - for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; - from_id_entry = from_id_entry->next) { - if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { - /* Never consider non-overridable relationships as actual dependencies. */ - continue; - } - - if (id_from_ref == from_id_entry->id_pointer.from) { - /* A matching parent was found in reference linked data, assume given hierarchy root is - * the valid one. */ - do_replace_root = true; - CLOG_WARN( - &LOG, - "Inconsistency in library override hierarchy of ID '%s'.\n" - "\tCurrent proposed root '%s' detected as valid, will replace already set one '%s'.", - id->name, - id_root->name, - id->override_library->hierarchy_root->name); - break; - } - } - - if (!do_replace_root) { - CLOG_WARN( - &LOG, - "Inconsistency in library override hierarchy of ID '%s'.\n" - "\tCurrent proposed root '%s' not detected as valid, keeping already set one '%s'.", - id->name, - id_root->name, - id->override_library->hierarchy_root->name); - return; - } - } - - id->override_library->hierarchy_root = id_root; - } - - MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); - BLI_assert(entry != NULL); - - for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL; - to_id_entry = to_id_entry->next) { - if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { - /* Never consider non-overridable relationships as actual dependencies. */ - continue; - } - - ID *to_id = *to_id_entry->id_pointer.to; - if (ELEM(to_id, NULL, id)) { - continue; - } - if (!ID_IS_OVERRIDE_LIBRARY(to_id) || (to_id->lib != id->lib)) { - continue; - } - - /* Recursively process the sub-hierarchy. */ - lib_override_root_hierarchy_set(bmain, id_root, to_id, id); - } -} - -void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) -{ - ID *id; - - BKE_main_relations_create(bmain, 0); - - FOREACH_MAIN_ID_BEGIN (bmain, id) { - if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { - continue; - } - if (id->override_library->hierarchy_root != NULL) { - continue; - } - - int best_level = 0; - ID *id_root = lib_override_root_find(bmain, id, best_level, &best_level); - - if (!ELEM(id_root->override_library->hierarchy_root, id_root, NULL)) { - CLOG_WARN(&LOG, - "Potential inconsistency in library override hierarchy of ID '%s', detected as " - "part of the hierarchy of '%s', which has a different root '%s'", - id->name, - id_root->name, - id_root->override_library->hierarchy_root->name); - continue; - } - - lib_override_root_hierarchy_set(bmain, id_root, id_root, NULL); - - BLI_assert(id->override_library->hierarchy_root != NULL); - } - FOREACH_MAIN_ID_END; - - BKE_main_relations_free(bmain); -} - static void lib_override_library_remap(Main *bmain, const ID *id_root_reference, GHash *linkedref_to_old_override) @@ -1490,6 +1321,7 @@ static bool lib_override_library_resync(Main *bmain, LibOverrideGroupTagData data = {.bmain = bmain, .scene = scene, .id_root = id_root, + .hierarchy_root_id = id_root->override_library->hierarchy_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, .is_override = true, @@ -1911,46 +1743,20 @@ static void lib_override_resync_tagging_finalize_recurse(Main *bmain, * * NOTE: Related to `lib_override_resync_tagging_finalize` above. */ -static ID *lib_override_library_main_resync_find_root_recurse(ID *id, int *level) -{ - (*level)++; - ID *return_id = id; - - switch (GS(id->name)) { - case ID_GR: { - /* Find the highest valid collection in the parenting hierarchy. - * Note that in practice, in any decent common case there is only one well defined root - * collection anyway. */ - int max_level = *level; - Collection *collection = (Collection *)id; - LISTBASE_FOREACH (CollectionParent *, collection_parent_iter, &collection->parents) { - Collection *collection_parent = collection_parent_iter->collection; - if (ID_IS_OVERRIDE_LIBRARY_REAL(collection_parent) && - collection_parent->id.lib == id->lib) { - int tmp_level = *level; - ID *tmp_id = lib_override_library_main_resync_find_root_recurse(&collection_parent->id, - &tmp_level); - if (tmp_level > max_level) { - max_level = tmp_level; - return_id = tmp_id; - } - } - } - break; - } - case ID_OB: { - Object *object = (Object *)id; - if (object->parent != NULL && ID_IS_OVERRIDE_LIBRARY_REAL(object->parent) && - object->parent->id.lib == id->lib) { - return_id = lib_override_library_main_resync_find_root_recurse(&object->parent->id, level); - } - break; +static ID *lib_override_library_main_resync_root_get(Main *bmain, ID *id) +{ + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { + const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id); + if (id_type->owner_get != NULL) { + id = id_type->owner_get(bmain, id); } - default: - break; + BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id)); } - return return_id; + ID *hierarchy_root_id = id->override_library->hierarchy_root; + BLI_assert(hierarchy_root_id != NULL); + BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(hierarchy_root_id)); + return hierarchy_root_id; } /* Ensure resync of all overrides at one level of indirect usage. @@ -2092,14 +1898,13 @@ static void lib_override_library_main_resync_on_library_indirect_level( Library *library = id->lib; - int level = 0; /* In complex non-supported cases, with several different override hierarchies sharing * relations between each-other, we may end up not actually updating/replacing the given * root id (see e.g. pro/shots/110_rextoria/110_0150_A/110_0150_A.anim.blend of sprites * project repository, r2687). * This can lead to infinite loop here, at least avoid this. */ id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; - id = lib_override_library_main_resync_find_root_recurse(id, &level); + id = lib_override_library_main_resync_root_get(bmain, id); id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id)); BLI_assert(id->lib == library); @@ -2257,6 +2062,7 @@ void BKE_lib_override_library_delete(Main *bmain, ID *id_root) LibOverrideGroupTagData data = {.bmain = bmain, .scene = NULL, .id_root = id_root, + .hierarchy_root_id = id_root->override_library->hierarchy_root, .tag = LIB_TAG_DOIT, .missing_tag = LIB_TAG_MISSING, .is_override = true, -- cgit v1.2.3 From de718605558f31fd67d8f135c8e25d9fb9b6ac67 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 8 Feb 2022 12:12:49 +0100 Subject: Fix T95570: missing task isolation when computing normals --- source/blender/blenkernel/intern/mesh_normals.cc | 58 ++++++++++++++---------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 08a17060549..1b3c7e01be8 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -43,6 +43,7 @@ #include "BLI_span.hh" #include "BLI_stack.h" #include "BLI_task.h" +#include "BLI_task.hh" #include "BLI_utildefines.h" #include "BKE_customdata.h" @@ -373,22 +374,28 @@ const float (*BKE_mesh_vertex_normals_ensure(const Mesh *mesh))[3] return (const float(*)[3])CustomData_get_layer(&mesh->vdata, CD_NORMAL); } - Mesh &mesh_mutable = *const_cast(mesh); + float(*vert_normals)[3]; + float(*poly_normals)[3]; - float(*vert_normals)[3] = BKE_mesh_vertex_normals_for_write(&mesh_mutable); - float(*poly_normals)[3] = BKE_mesh_poly_normals_for_write(&mesh_mutable); + /* Isolate task because a mutex is locked and computing normals is multi-threaded. */ + blender::threading::isolate_task([&]() { + Mesh &mesh_mutable = *const_cast(mesh); - mesh_calc_normals_poly_and_vertex(mesh_mutable.mvert, - mesh_mutable.totvert, - mesh_mutable.mloop, - mesh_mutable.totloop, - mesh_mutable.mpoly, - mesh_mutable.totpoly, - poly_normals, - vert_normals); + vert_normals = BKE_mesh_vertex_normals_for_write(&mesh_mutable); + poly_normals = BKE_mesh_poly_normals_for_write(&mesh_mutable); - BKE_mesh_vertex_normals_clear_dirty(&mesh_mutable); - BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + mesh_calc_normals_poly_and_vertex(mesh_mutable.mvert, + mesh_mutable.totvert, + mesh_mutable.mloop, + mesh_mutable.totloop, + mesh_mutable.mpoly, + mesh_mutable.totpoly, + poly_normals, + vert_normals); + + BKE_mesh_vertex_normals_clear_dirty(&mesh_mutable); + BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + }); BLI_mutex_unlock(normals_mutex); return vert_normals; @@ -413,19 +420,24 @@ const float (*BKE_mesh_poly_normals_ensure(const Mesh *mesh))[3] return (const float(*)[3])CustomData_get_layer(&mesh->pdata, CD_NORMAL); } - Mesh &mesh_mutable = *const_cast(mesh); + float(*poly_normals)[3]; + + /* Isolate task because a mutex is locked and computing normals is multi-threaded. */ + blender::threading::isolate_task([&]() { + Mesh &mesh_mutable = *const_cast(mesh); - float(*poly_normals)[3] = BKE_mesh_poly_normals_for_write(&mesh_mutable); + poly_normals = BKE_mesh_poly_normals_for_write(&mesh_mutable); - BKE_mesh_calc_normals_poly(mesh_mutable.mvert, - mesh_mutable.totvert, - mesh_mutable.mloop, - mesh_mutable.totloop, - mesh_mutable.mpoly, - mesh_mutable.totpoly, - poly_normals); + BKE_mesh_calc_normals_poly(mesh_mutable.mvert, + mesh_mutable.totvert, + mesh_mutable.mloop, + mesh_mutable.totloop, + mesh_mutable.mpoly, + mesh_mutable.totpoly, + poly_normals); - BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + BKE_mesh_poly_normals_clear_dirty(&mesh_mutable); + }); BLI_mutex_unlock(normals_mutex); return poly_normals; -- cgit v1.2.3 From 3267c91b4d5caab7da8aef071a446dd2e86f86a9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2022 22:16:51 +1100 Subject: Fix T91253: Slow pose bone selection with many bones Viewport cull bones during selection to avoid depth-picking reading the depth buffer for bones that aren't in the viewport. Files with thousands of bones could hang blender for seconds while selecting. The issue could still happen with overlapping bones or when zoomed out so all bones are under the cursor, however in practice this rarely happens. Now files with many bones select quickly. Related changes include: - Split `BKE_pchan_minmax` out of `BKE_pose_minmax`. - Add `mat3_to_size_max_axis` to return the length of the largest axis (used for scaling the radius). Reviewed By: sybren Maniphest Tasks: T91253 Ref D13990 --- source/blender/blenkernel/BKE_armature.h | 24 ++++ source/blender/blenkernel/intern/armature.c | 54 ++++---- source/blender/blenlib/BLI_math_matrix.h | 14 ++ source/blender/blenlib/intern/math_matrix.c | 10 ++ .../draw/engines/overlay/overlay_armature.c | 146 ++++++++++++++++++++- 5 files changed, 218 insertions(+), 30 deletions(-) diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 12d8135ba55..ede300b19dd 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -163,6 +163,30 @@ void BKE_armature_transform(struct bArmature *arm, const float mat[4][4], bool d /* Bounding box. */ struct BoundBox *BKE_armature_boundbox_get(struct Object *ob); +/** + * Calculate the axis-aligned bounds of `pchan` in world-space, + * taking into account custom transform when set. + * + * `r_min` and `r_max` are expanded to fit `pchan` so the caller must initialize them + * (typically using #INIT_MINMAX). + * + * \note The bounds are calculated based on the head & tail of the bone + * or the custom object's bounds (if the bone uses a custom object). + * Visual elements such as the envelopes radius & bendy-bone spline segments are *not* included, + * making this not so useful for viewport culling. + */ +void BKE_pchan_minmax(const struct Object *ob, + const struct bPoseChannel *pchan, + float r_min[3], + float r_max[3]); +/** + * Calculate the axis aligned bounds of the pose of `ob` in world-space. + + * `r_min` and `r_max` are expanded to fit `ob->pose` so the caller must initialize them + * (typically using #INIT_MINMAX). + * + * \note This uses #BKE_pchan_minmax, see its documentation for details on bounds calculation. + */ bool BKE_pose_minmax( struct Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 7feb9d08915..1a9f0a9130d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2679,6 +2679,35 @@ BoundBox *BKE_armature_boundbox_get(Object *ob) return ob->runtime.bb; } +void BKE_pchan_minmax(const Object *ob, const bPoseChannel *pchan, float r_min[3], float r_max[3]) +{ + const bArmature *arm = ob->data; + const bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan; + const BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ? + BKE_object_boundbox_get(pchan->custom) : + NULL; + if (bb_custom) { + float mat[4][4], smat[4][4], rmat[4][4], tmp[4][4]; + scale_m4_fl(smat, PCHAN_CUSTOM_BONE_LENGTH(pchan)); + rescale_m4(smat, pchan->custom_scale_xyz); + eulO_to_mat4(rmat, pchan->custom_rotation_euler, ROT_MODE_XYZ); + copy_m4_m4(tmp, pchan_tx->pose_mat); + translate_m4(tmp, + pchan->custom_translation[0], + pchan->custom_translation[1], + pchan->custom_translation[2]); + mul_m4_series(mat, ob->obmat, tmp, rmat, smat); + BKE_boundbox_minmax(bb_custom, mat, r_min, r_max); + } + else { + float vec[3]; + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); + minmax_v3v3_v3(r_min, r_max, vec); + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); + minmax_v3v3_v3(r_min, r_max, vec); + } +} + bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select) { bool changed = false; @@ -2692,31 +2721,8 @@ bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden * (editarmature.c:2592)... Skip in this case too! */ if (pchan->bone && (!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) && !((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0)))) { - bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan; - BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ? - BKE_object_boundbox_get(pchan->custom) : - NULL; - if (bb_custom) { - float mat[4][4], smat[4][4], rmat[4][4], tmp[4][4]; - scale_m4_fl(smat, PCHAN_CUSTOM_BONE_LENGTH(pchan)); - rescale_m4(smat, pchan->custom_scale_xyz); - eulO_to_mat4(rmat, pchan->custom_rotation_euler, ROT_MODE_XYZ); - copy_m4_m4(tmp, pchan_tx->pose_mat); - translate_m4(tmp, - pchan->custom_translation[0], - pchan->custom_translation[1], - pchan->custom_translation[2]); - mul_m4_series(mat, ob->obmat, tmp, rmat, smat); - BKE_boundbox_minmax(bb_custom, mat, r_min, r_max); - } - else { - float vec[3]; - mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); - minmax_v3v3_v3(r_min, r_max, vec); - mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); - minmax_v3v3_v3(r_min, r_max, vec); - } + BKE_pchan_minmax(ob, pchan, r_min, r_max); changed = true; } } diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 03b6ff25a4f..1dcc1c1df49 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -430,6 +430,20 @@ void size_to_mat4(float R[4][4], const float size[3]); void mat3_to_size(float size[3], const float M[3][3]); void mat4_to_size(float size[3], const float M[4][4]); +/** + * Return the largest scale on any axis, the equivalent of calling: + * \code{.c} + * mat3_to_size(size_v3, mat); + * size = size_v3[max_axis_v3(size_v3)]; + * \endcode + * .. without 2x unnecessary `sqrtf` calls. + */ +float mat3_to_size_max_axis(const float M[3][3]); +/** + * Only the first 3 axes are used. + */ +float mat4_to_size_max_axis(const float M[4][4]); + /** * Extract scale factors from the matrix, with correction to ensure * exact volume in case of a sheared matrix. diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index f307672361b..9c719b12756 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -2144,6 +2144,16 @@ void mat4_to_size(float size[3], const float M[4][4]) size[2] = len_v3(M[2]); } +float mat3_to_size_max_axis(const float M[3][3]) +{ + return sqrtf(max_fff(len_squared_v3(M[0]), len_squared_v3(M[1]), len_squared_v3(M[2]))); +} + +float mat4_to_size_max_axis(const float M[4][4]) +{ + return sqrtf(max_fff(len_squared_v3(M[0]), len_squared_v3(M[1]), len_squared_v3(M[2]))); +} + void mat4_to_size_fix_shear(float size[3], const float M[4][4]) { mat4_to_size(size, M); diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index ccf8f9e0c36..5abebe2f32b 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -2037,6 +2037,126 @@ static void draw_bone_name(ArmatureDrawContext *ctx, /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Pose Bone Culling + * + * Used for selection since drawing many bones can be slow, see: T91253. + * + * Bounding spheres are used with margins added to ensure bones are included. + * An added margin is needed because #BKE_pchan_minmax only returns the bounds + * of the bones head & tail which doesn't account for parts of the bone users may select + * (octahedral spheres or envelope radius for example). + * \{ */ + +static void pchan_culling_calc_bsphere(const Object *ob, + const bPoseChannel *pchan, + BoundSphere *r_bsphere) +{ + float min[3], max[3]; + INIT_MINMAX(min, max); + BKE_pchan_minmax(ob, pchan, min, max); + mid_v3_v3v3(r_bsphere->center, min, max); + r_bsphere->radius = len_v3v3(min, r_bsphere->center); +} + +/** + * \return true when bounding sphere from `pchan` intersect the view. + * (same for other "test" functions defined here). + */ +static bool pchan_culling_test_simple(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + BoundSphere bsphere; + pchan_culling_calc_bsphere(ob, pchan, &bsphere); + return DRW_culling_sphere_test(view, &bsphere); +} + +static bool pchan_culling_test_with_radius_scale(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan, + const float scale) +{ + BoundSphere bsphere; + pchan_culling_calc_bsphere(ob, pchan, &bsphere); + bsphere.radius *= scale; + return DRW_culling_sphere_test(view, &bsphere); +} + +static bool pchan_culling_test_custom(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + /* For more aggressive culling the bounding box of the custom-object could be used. */ + return pchan_culling_test_simple(view, ob, pchan); +} + +static bool pchan_culling_test_wire(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + BLI_assert(((const bArmature *)ob->data)->drawtype == ARM_WIRE); + return pchan_culling_test_simple(view, ob, pchan); +} + +static bool pchan_culling_test_line(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + BLI_assert(((const bArmature *)ob->data)->drawtype == ARM_LINE); + /* Account for the end-points, as the line end-points size is in pixels, this is a rough value. + * Since the end-points are small the difference between having any margin or not is unlikely + * to be noticeable. */ + const float scale = 1.1f; + return pchan_culling_test_with_radius_scale(view, ob, pchan, scale); +} + +static bool pchan_culling_test_envelope(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + const bArmature *arm = ob->data; + BLI_assert(arm->drawtype == ARM_ENVELOPE); + BoundSphere bsphere; + pchan_culling_calc_bsphere(ob, pchan, &bsphere); + bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * + mat4_to_size_max_axis(ob->obmat) * mat4_to_size_max_axis(pchan->disp_mat); + return DRW_culling_sphere_test(view, &bsphere); +} + +static bool pchan_culling_test_bbone(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + const bArmature *arm = ob->data; + BLI_assert(arm->drawtype == ARM_B_BONE); + const float ob_scale = mat4_to_size_max_axis(ob->obmat); + const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; + for (int i = pchan->bone->segments; i--; bbones_mat++) { + BoundSphere bsphere; + float size[3]; + mat4_to_size(size, bbones_mat->mat); + copy_v3_v3(bsphere.center, bbones_mat->mat[3]); + bsphere.radius = len_v3(size) * ob_scale; + if (DRW_culling_sphere_test(view, &bsphere)) { + return true; + } + } + return false; +} + +static bool pchan_culling_test_octohedral(const DRWView *view, + const Object *ob, + const bPoseChannel *pchan) +{ + /* No type assertion as this is a fallback (files from the future will end up here). */ + /* Account for spheres on the end-points. */ + const float scale = 1.2f; + return pchan_culling_test_with_radius_scale(view, ob, pchan, scale); +} + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Main Draw Loops * \{ */ @@ -2185,6 +2305,8 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) } } + const DRWView *view = is_pose_select ? DRW_view_default_get() : NULL; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, index += 0x10000) { Bone *bone = pchan->bone; const bool bone_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0; @@ -2225,27 +2347,39 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { draw_bone_update_disp_matrix_custom(pchan); - draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_custom(view, ob, pchan)) { + draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_ENVELOPE) { draw_bone_update_disp_matrix_default(NULL, pchan); - draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_envelope(view, ob, pchan)) { + draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_LINE) { draw_bone_update_disp_matrix_default(NULL, pchan); - draw_bone_line(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_line(view, ob, pchan)) { + draw_bone_line(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_WIRE) { draw_bone_update_disp_matrix_bbone(NULL, pchan); - draw_bone_wire(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_wire(view, ob, pchan)) { + draw_bone_wire(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else if (arm->drawtype == ARM_B_BONE) { draw_bone_update_disp_matrix_bbone(NULL, pchan); - draw_bone_box(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_bbone(view, ob, pchan)) { + draw_bone_box(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } else { draw_bone_update_disp_matrix_default(NULL, pchan); - draw_bone_octahedral(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + if (!is_pose_select || pchan_culling_test_octohedral(view, ob, pchan)) { + draw_bone_octahedral(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + } } /* These aren't included in the selection. */ -- cgit v1.2.3 From 460d1a4cb36a6ae222721a9721c627292fdd77ec Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 8 Feb 2022 14:12:30 +0300 Subject: Eevee: support the no-op Bump node optimization like in Cycles. A Bump node without a Height input is meaningless and does nothing. As such, it is available as an old workaround that allows making Node Group inputs that default to normal when not connected, by routing via a no-op Bump node before doing math. Cycles specifically recognizes this use case and either bypasses the node, or converts it into a Geometry Normal node, but Eevee was still evaluating it as usual. That incurred performance cost, and also normalized the vector unlike Cycles. This implements the same bypass logic for Eevee. Since I'm not sure if it's possible to totally remove the node at this stage, it emits a no-op function call to copy the input vector. Differential Revision: https://developer.blender.org/D14045 --- .../gpu/shaders/material/gpu_shader_material_math_util.glsl | 5 +++++ source/blender/nodes/shader/nodes/node_shader_bump.cc | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl index c6203bc36ab..2a98d9fadd0 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl @@ -109,6 +109,11 @@ void vector_normalize(vec3 normal, out vec3 outnormal) outnormal = normalize(normal); } +void vector_copy(vec3 normal, out vec3 outnormal) +{ + outnormal = normal; +} + /* Matirx Math */ mat3 euler_to_mat3(vec3 euler) diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.cc b/source/blender/nodes/shader/nodes/node_shader_bump.cc index 252abd02ad7..690eacf30ff 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bump.cc @@ -60,6 +60,17 @@ static int gpu_shader_bump(GPUMaterial *mat, GPUNodeStack *in, GPUNodeStack *out) { + /* If there is no Height input, the node becomes a no-op. */ + if (!in[2].link) { + if (!in[5].link) { + return GPU_link(mat, "world_normals_get", &out[0].link); + } + else { + /* Actually running the bump code would normalize, but Cycles handles it as total no-op. */ + return GPU_link(mat, "vector_copy", in[5].link, &out[0].link); + } + } + if (!in[5].link) { GPU_link(mat, "world_normals_get", &in[5].link); } -- cgit v1.2.3 From 5d9d2565d2e493d3dd3e6a759297458e4d8dd263 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2022 12:06:37 +1100 Subject: Cleanup: simplify DNA genfile casting Avoid using the uint64_t as an intermediate cast since it complicates behavior for signed types (which first need to be cast to an int64_t). Assign both old_value_i & old_value_f from the original value to avoid the need for different handling of signed/unsigned types. Reviewed By: JacquesLucke Ref D14039 --- source/blender/makesdna/intern/dna_genfile.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 9a71e516389..0edc9b8fd9f 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -734,8 +734,7 @@ static void cast_primitive_type(const eSDNA_Type old_type, double old_value_f = 0.0; /* Intentionally overflow signed values into an unsigned type. - * Casting back to a signed value preserves the sign (when the new value is signed). - * It's also important to cast to `int64_t` when setting `old_value_f` from a signed value. */ + * Casting back to a signed value preserves the sign (when the new value is signed). */ uint64_t old_value_i = 0; for (int a = 0; a < array_len; a++) { @@ -743,61 +742,63 @@ static void cast_primitive_type(const eSDNA_Type old_type, case SDNA_TYPE_CHAR: { const char value = *old_data; old_value_i = value; - old_value_f = (double)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_UCHAR: { const uchar value = *((uchar *)old_data); old_value_i = value; - old_value_f = (double)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_SHORT: { const short value = *((short *)old_data); old_value_i = value; - old_value_f = (double)(int64_t)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_USHORT: { const ushort value = *((unsigned short *)old_data); old_value_i = value; - old_value_f = (double)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_INT: { const int value = *((int *)old_data); old_value_i = value; - old_value_f = (double)(int64_t)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_FLOAT: { const float value = *((float *)old_data); + /* `int64_t` range stored in a `uint64_t`. */ + old_value_i = (uint64_t)(int64_t)value; old_value_f = value; - old_value_i = (uint64_t)(int64_t)old_value_f; break; } case SDNA_TYPE_DOUBLE: { const double value = *((double *)old_data); + /* `int64_t` range stored in a `uint64_t`. */ + old_value_i = (uint64_t)(int64_t)value; old_value_f = value; - old_value_i = (uint64_t)(int64_t)old_value_f; break; } case SDNA_TYPE_INT64: { const int64_t value = *((int64_t *)old_data); old_value_i = (uint64_t)value; - old_value_f = (double)(int64_t)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_UINT64: { const uint64_t value = *((uint64_t *)old_data); old_value_i = value; - old_value_f = (double)old_value_i; + old_value_f = (double)value; break; } case SDNA_TYPE_INT8: { const int8_t value = *((int8_t *)old_data); old_value_i = (uint64_t)value; - old_value_f = (double)(int64_t)old_value_i; + old_value_f = (double)value; } } -- cgit v1.2.3 From 55c90df316c7f5106b4ff97f1a6d6bcac3b195a3 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 8 Feb 2022 08:43:01 -0800 Subject: BLF: Enable Filtering of woff and woff2 Fonts Add files with extension ".woff" and ".woff2" to FILE_TYPE_FTFONT file type. Allows selecting and using these types of font files. See D13822 for more details. Differential Revision: https://developer.blender.org/D13822 Reviewed by Campbell Barton --- source/blender/blenfont/intern/blf_font.c | 6 ++++++ source/blender/editors/space_file/filelist.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index c1410447de6..3ac9fdc7f41 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1238,6 +1238,12 @@ FontBLF *blf_font_new(const char *name, const char *filename) font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new"); err = FT_New_Face(ft_lib, filename, 0, &font->face); if (err) { + if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) { + printf("Format of this font file is not supported\n"); + } + else { + printf("Error encountered while opening font file\n"); + } MEM_freeN(font); return NULL; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 044d7aba88f..6be17bbd355 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2783,7 +2783,8 @@ int ED_path_extension_type(const char *path) NULL)) { return FILE_TYPE_TEXT; } - if (BLI_path_extension_check_n(path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", NULL)) { + if (BLI_path_extension_check_n( + path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", NULL)) { return FILE_TYPE_FTFONT; } if (BLI_path_extension_check(path, ".btx")) { -- cgit v1.2.3 From 452a7f673190e5161c96ec8a53631a1c89d127b9 Mon Sep 17 00:00:00 2001 From: Paolo Acampora Date: Tue, 8 Feb 2022 18:08:12 +0100 Subject: Fix T91871: Symmetrize Armature on custom bone shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Symmetrize Armature now also symmetrizes the transform of custom bone shapes. Adds a new property to `bpy.ops.armature.symmetrize`: //Parameters//: - **direction **(enum in ['NEGATIVE_X', 'POSITIVE_X'], (optional)) – **Direction**, Which sides to copy from and to (when both are selected) - **custom_shape **(enum in ['SYMMETRIZE_SAME', 'SYMMETRIZE_ALL', 'SYMMETRIZE_NONE'], (optional)) – **Custom Shapes**, Wether to symmetrize non symmetric custom bone shapes, all custom shapes, or none at all //Rationale//: Reviewed By: #animation_rigging, Mets, sybren Maniphest Tasks: T91871 Differential Revision: https://developer.blender.org/D13416 --- source/blender/editors/armature/armature_add.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 4a327904ddd..b8a4351357d 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -859,14 +859,28 @@ static void updateDuplicateCustomBoneShapes(bContext *C, EditBone *dup_bone, Obj Main *bmain = CTX_data_main(C); char name_flip[MAX_ID_NAME - 2]; + /* Invert the X location */ + pchan->custom_translation[0] *= -1; + /* Invert the Y rotation */ + pchan->custom_rotation_euler[1] *= -1; + /* Invert the Z rotation */ + pchan->custom_rotation_euler[2] *= -1; + /* Skip the first two chars in the object name as those are used to store object type */ BLI_string_flip_side_name(name_flip, pchan->custom->id.name + 2, false, sizeof(name_flip)); Object *shape_ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); + /* If name_flip doesn't exist, BKE_libblock_find_name() returns pchan->custom (best match) */ + shape_ob = shape_ob == pchan->custom ? NULL : shape_ob; + if (shape_ob != NULL) { /* A flipped shape object exists, use it! */ pchan->custom = shape_ob; } + else { + /* Flip shape */ + pchan->custom_scale_xyz[0] *= -1; + } } } -- cgit v1.2.3 From f021d467526af3f3fc839c0ca48acc61dd781d56 Mon Sep 17 00:00:00 2001 From: Shrey Aggarwal Date: Tue, 8 Feb 2022 17:40:48 -0700 Subject: Cleanup: GHOST_ISystem::toggleConsole API GHOST_ISystem::toggleConsole had a somewhat misleading name it could be fed 4 different values, so it was not as much a toggle as a set console window state. This change renames `toggleConsole` to a more appropriately named `setConsoleWindowState` and replaces the integer it had to an enum so it's easy to tell what is being asked of it at the call site. Reviewed By: LazyDodo Differential Revision: https://developer.blender.org/D14020 --- intern/ghost/GHOST_C-api.h | 11 +++-------- intern/ghost/GHOST_ISystem.h | 11 +++-------- intern/ghost/GHOST_Types.h | 7 +++++++ intern/ghost/intern/GHOST_C-api.cpp | 4 ++-- intern/ghost/intern/GHOST_SystemCocoa.h | 2 +- intern/ghost/intern/GHOST_SystemNULL.h | 2 +- intern/ghost/intern/GHOST_SystemSDL.h | 2 +- intern/ghost/intern/GHOST_SystemWayland.cpp | 2 +- intern/ghost/intern/GHOST_SystemWayland.h | 2 +- intern/ghost/intern/GHOST_SystemWin32.cpp | 13 ++++++------- intern/ghost/intern/GHOST_SystemWin32.h | 11 +++-------- intern/ghost/intern/GHOST_SystemX11.h | 2 +- source/blender/windowmanager/intern/wm_init_exit.c | 4 ++-- source/blender/windowmanager/intern/wm_operators.c | 2 +- 14 files changed, 33 insertions(+), 42 deletions(-) diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 98094cc0669..38adf81f877 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -889,16 +889,11 @@ extern char *GHOST_getClipboard(bool selection); extern void GHOST_putClipboard(const char *buffer, bool selection); /** - * Toggles console - * \param action: - * - 0: Hides - * - 1: Shows - * - 2: Toggles - * - 3: Hides if it runs not from command line - * - *: Does nothing + * Set the Console State + * \param action: console state * \return current status (1 -visible, 0 - hidden) */ -extern int GHOST_toggleConsole(int action); +extern int setConsoleWindowState(GHOST_TConsoleWindowState action); /** * Use native pixel size (MacBook pro 'retina'), if supported. diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 05c6c9d907f..3edc7605d41 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -411,16 +411,11 @@ class GHOST_ISystem { #endif /** - * Toggles console - * \param action: - * - 0: Hides. - * - 1: Shows - * - 2: Toggles - * - 3: Hides if it runs not from command line - * - *: Does nothing + * Set the Console State + * \param action: console state * \return current status (1 -visible, 0 - hidden) */ - virtual int toggleConsole(int action) = 0; + virtual int setConsoleWindowState(GHOST_TConsoleWindowState action) = 0; /*************************************************************************************** * Access to clipboard. diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 7fe9300ec3f..4e190d09234 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -140,6 +140,13 @@ typedef enum { // GHOST_kWindowStateUnModified, } GHOST_TWindowState; +typedef enum { + GHOST_kConsoleWindowStateHide = 0, + GHOST_kConsoleWindowStateShow, + GHOST_kConsoleWindowStateToggle, + GHOST_kConsoleWindowStateHideForNonConsoleLaunch +} GHOST_TConsoleWindowState; + typedef enum { GHOST_kWindowOrderTop = 0, GHOST_kWindowOrderBottom } GHOST_TWindowOrder; typedef enum { diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index a21c3a90c06..a2d1c143316 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -809,10 +809,10 @@ void GHOST_putClipboard(const char *buffer, bool selection) system->putClipboard(buffer, selection); } -int GHOST_toggleConsole(int action) +int setConsoleWindowState(GHOST_TConsoleWindowState action) { GHOST_ISystem *system = GHOST_ISystem::getSystem(); - return system->toggleConsole(action); + return system->setConsoleWindowState(action); } int GHOST_UseNativePixels(void) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 5950da6813d..02216f9d1f8 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -244,7 +244,7 @@ class GHOST_SystemCocoa : public GHOST_System { /** * \see GHOST_ISystem */ - int toggleConsole(int action) + int setConsoleWindowState(GHOST_TConsoleWindowState action) { return 0; } diff --git a/intern/ghost/intern/GHOST_SystemNULL.h b/intern/ghost/intern/GHOST_SystemNULL.h index 5dbc42b53a2..53cd97e8e57 100644 --- a/intern/ghost/intern/GHOST_SystemNULL.h +++ b/intern/ghost/intern/GHOST_SystemNULL.h @@ -40,7 +40,7 @@ class GHOST_SystemNULL : public GHOST_System { { return false; } - int toggleConsole(int action) + int setConsoleWindowState(GHOST_TConsoleWindowState action) { return 0; } diff --git a/intern/ghost/intern/GHOST_SystemSDL.h b/intern/ghost/intern/GHOST_SystemSDL.h index 051bb6777b1..8706dd0daa7 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.h +++ b/intern/ghost/intern/GHOST_SystemSDL.h @@ -47,7 +47,7 @@ class GHOST_SystemSDL : public GHOST_System { bool processEvents(bool waitForEvent); - int toggleConsole(int action) + int setConsoleWindowState(GHOST_TConsoleWindowState action) { return 0; } diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 38700845405..27b37d0d326 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -1473,7 +1473,7 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent) return fired || (getEventManager()->getNumEvents() > 0); } -int GHOST_SystemWayland::toggleConsole(int /*action*/) +int GHOST_SystemWayland::setConsoleWindowState(GHOST_TConsoleWindowState /*action*/) { return 0; } diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h index 9f02afb9d5a..b11c243aca8 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.h +++ b/intern/ghost/intern/GHOST_SystemWayland.h @@ -53,7 +53,7 @@ class GHOST_SystemWayland : public GHOST_System { bool processEvents(bool waitForEvent) override; - int toggleConsole(int action) override; + int setConsoleWindowState(GHOST_TConsoleWindowState action) override; GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override; diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 923453d6c6f..2f5395fc8d0 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -170,7 +170,7 @@ GHOST_SystemWin32::~GHOST_SystemWin32() OleUninitialize(); if (isStartedFromCommandPrompt()) { - toggleConsole(1); + setConsoleWindowState(GHOST_kConsoleWindowStateShow); } } @@ -2221,31 +2221,30 @@ static bool isStartedFromCommandPrompt() return false; } -int GHOST_SystemWin32::toggleConsole(int action) +int GHOST_SystemWin32::setConsoleWindowState(GHOST_TConsoleWindowState action) { HWND wnd = GetConsoleWindow(); switch (action) { - case 3: // startup: hide if not started from command prompt - { + case GHOST_kConsoleWindowStateHideForNonConsoleLaunch: { if (!isStartedFromCommandPrompt()) { ShowWindow(wnd, SW_HIDE); m_consoleStatus = 0; } break; } - case 0: // hide + case GHOST_kConsoleWindowStateHide: ShowWindow(wnd, SW_HIDE); m_consoleStatus = 0; break; - case 1: // show + case GHOST_kConsoleWindowStateShow: ShowWindow(wnd, SW_SHOW); if (!isStartedFromCommandPrompt()) { DeleteMenu(GetSystemMenu(wnd, FALSE), SC_CLOSE, MF_BYCOMMAND); } m_consoleStatus = 1; break; - case 2: // toggle + case GHOST_kConsoleWindowStateToggle: ShowWindow(wnd, m_consoleStatus ? SW_HIDE : SW_SHOW); m_consoleStatus = !m_consoleStatus; if (m_consoleStatus && !isStartedFromCommandPrompt()) { diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 4794982dc65..4f0fd6e6801 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -436,16 +436,11 @@ class GHOST_SystemWin32 : public GHOST_System { static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); /** - * Toggles console - * \param action: - * - 0 - Hides - * - 1 - Shows - * - 2 - Toggles - * - 3 - Hides if it runs not from command line - * - * - Does nothing + * Set the Console State + * \param action: console state * \return current status (1 -visible, 0 - hidden) */ - int toggleConsole(int action); + int setConsoleWindowState(GHOST_TConsoleWindowState action); /** The current state of the modifier keys. */ GHOST_ModifierKeys m_modifierKeys; diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index d4803f88fbb..76011d3522b 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -269,7 +269,7 @@ class GHOST_SystemX11 : public GHOST_System { /** * \see GHOST_ISystem */ - int toggleConsole(int /*action*/) + int setConsoleWindowState(GHOST_TConsoleWindowState /*action*/) { return 0; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 1d26c58bcf9..cff4287a2d0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -356,10 +356,10 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { if (wm_start_with_console) { - GHOST_toggleConsole(1); + setConsoleWindowState(GHOST_kConsoleWindowStateShow); } else { - GHOST_toggleConsole(3); + setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6c9b0af5186..2c82d8f5b6b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2046,7 +2046,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot) static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { - GHOST_toggleConsole(2); + setConsoleWindowState(GHOST_kConsoleWindowStateToggle); return OPERATOR_FINISHED; } -- cgit v1.2.3 From 59a7095f79ff686e439b6db0f065d7e806b44e93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 16:00:03 +1100 Subject: Cleanup: use consistent copyright location, move descriptions Order copyright immediately after the license block, this was done almost everywhere with a few exceptions. Remove authors from a few files (we had already removed "Contributors" section however with old patches being applied this gets added back in). Also move descriptive text into the doxygen comment block under \file. In some cases remove the text as it was accidentally copied. --- intern/quadriflow/quadriflow_capi.cpp | 34 +++++++------- intern/quadriflow/quadriflow_capi.hpp | 34 +++++++------- intern/sky/source/sky_model.cpp | 54 +++++++++++----------- intern/sky/source/sky_model_data.h | 54 +++++++++++----------- intern/sky/source/sky_nishita.cpp | 4 +- release/scripts/modules/console/__init__.py | 4 +- .../scripts/modules/console/complete_calltip.py | 4 +- release/scripts/modules/console/complete_import.py | 4 +- .../scripts/modules/console/complete_namespace.py | 4 +- release/scripts/modules/console/intellisense.py | 4 +- .../scripts/startup/bl_operators/object_align.py | 1 - release/scripts/startup/bl_ui/properties_output.py | 1 - release/scripts/startup/bl_ui/properties_render.py | 1 - source/blender/blenkernel/intern/armature_pose.cc | 2 - source/blender/blenkernel/intern/armature_update.c | 2 - source/blender/blenkernel/intern/attribute.c | 5 +- source/blender/blenkernel/intern/cdderivedmesh.c | 3 +- source/blender/blenkernel/intern/customdata.cc | 6 +-- source/blender/blenkernel/intern/idtype.c | 3 -- source/blender/blenkernel/intern/mball.c | 9 ++-- source/blender/blenkernel/intern/modifier.c | 5 +- source/blender/blenkernel/intern/ocean.c | 6 +-- .../blender/blenkernel/intern/vfontdata_freetype.c | 8 ++-- .../compositor/nodes/COM_AntiAliasingNode.cc | 4 +- .../compositor/nodes/COM_AntiAliasingNode.h | 4 +- .../compositor/operations/COM_SMAAOperation.cc | 4 +- .../compositor/operations/COM_SMAAOperation.h | 4 +- 27 files changed, 122 insertions(+), 146 deletions(-) diff --git a/intern/quadriflow/quadriflow_capi.cpp b/intern/quadriflow/quadriflow_capi.cpp index 086d5f7d296..e5e7bd3d947 100644 --- a/intern/quadriflow/quadriflow_capi.cpp +++ b/intern/quadriflow/quadriflow_capi.cpp @@ -1,20 +1,20 @@ -// Copyright 2019 Blender Foundation. All rights reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Author: Sebastian Parborg, Pablo Dobarro +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2019 Blender Foundation. All rights reserved. + */ #include diff --git a/intern/quadriflow/quadriflow_capi.hpp b/intern/quadriflow/quadriflow_capi.hpp index 59af2826e15..927cc7c22a7 100644 --- a/intern/quadriflow/quadriflow_capi.hpp +++ b/intern/quadriflow/quadriflow_capi.hpp @@ -1,20 +1,20 @@ -// Copyright 2019 Blender Foundation. All rights reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// Author: Sebastian Parborg, Pablo Dobarro +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2019 Blender Foundation. All rights reserved. + */ #ifndef QUADRIFLOW_CAPI_HPP #define QUADRIFLOW_CAPI_HPP diff --git a/intern/sky/source/sky_model.cpp b/intern/sky/source/sky_model.cpp index b5bf415da26..135d5527e7f 100644 --- a/intern/sky/source/sky_model.cpp +++ b/intern/sky/source/sky_model.cpp @@ -1,32 +1,30 @@ /* -This source is published under the following 3-clause BSD license. - -Copyright (c) 2012 - 2013, Lukas Hosek and Alexander Wilkie -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * None of the names of the contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * None of the names of the contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright (c) 2012 - 2013, Lukas Hosek and Alexander Wilkie + * All rights reserved. + */ /* ============================================================================ diff --git a/intern/sky/source/sky_model_data.h b/intern/sky/source/sky_model_data.h index 4f7bcb7cc48..2308f7827b2 100644 --- a/intern/sky/source/sky_model_data.h +++ b/intern/sky/source/sky_model_data.h @@ -1,32 +1,30 @@ /* -This source is published under the following 3-clause BSD license. - -Copyright (c) 2012 - 2013, Lukas Hosek and Alexander Wilkie -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * None of the names of the contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * None of the names of the contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright (c) 2012 - 2013, Lukas Hosek and Alexander Wilkie + * All rights reserved. + */ /* ============================================================================ diff --git a/intern/sky/source/sky_nishita.cpp b/intern/sky/source/sky_nishita.cpp index 615755390c7..236c965fb27 100644 --- a/intern/sky/source/sky_nishita.cpp +++ b/intern/sky/source/sky_nishita.cpp @@ -1,6 +1,4 @@ /* - * Copyright 2011-2020 Blender Foundation - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,6 +10,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Copyright 2011-2020 Blender Foundation */ /** \file diff --git a/release/scripts/modules/console/__init__.py b/release/scripts/modules/console/__init__.py index 97cb14822c4..731f5715818 100644 --- a/release/scripts/modules/console/__init__.py +++ b/release/scripts/modules/console/__init__.py @@ -1,5 +1,3 @@ -# Copyright (c) 2009 www.stani.be (GPL license) - # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or @@ -18,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# Copyright (c) 2009 www.stani.be + # """Package for console specific modules.""" diff --git a/release/scripts/modules/console/complete_calltip.py b/release/scripts/modules/console/complete_calltip.py index 60daa1d2045..c8aeaf2c98f 100644 --- a/release/scripts/modules/console/complete_calltip.py +++ b/release/scripts/modules/console/complete_calltip.py @@ -1,5 +1,3 @@ -# Copyright (c) 2009 www.stani.be (GPL license) - # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or @@ -18,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# Copyright (c) 2009 www.stani.be + # import inspect diff --git a/release/scripts/modules/console/complete_import.py b/release/scripts/modules/console/complete_import.py index 4bdd4eb188a..524989b3455 100644 --- a/release/scripts/modules/console/complete_import.py +++ b/release/scripts/modules/console/complete_import.py @@ -1,5 +1,3 @@ -# Copyright (c) 2009 Fernando Perez, www.stani.be (GPL license) - # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or @@ -18,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# Copyright (c) 2009 Fernando Perez, www.stani.be + # Original copyright (see docstring): # **************************************************************************** # Copyright (C) 2001-2006 Fernando Perez diff --git a/release/scripts/modules/console/complete_namespace.py b/release/scripts/modules/console/complete_namespace.py index fa6323dcc66..68c06e641dc 100644 --- a/release/scripts/modules/console/complete_namespace.py +++ b/release/scripts/modules/console/complete_namespace.py @@ -1,5 +1,3 @@ -# Copyright (c) 2009 www.stani.be (GPL license) - # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or @@ -18,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# Copyright (c) 2009 www.stani.be + # """Autocomplete with the standard library""" diff --git a/release/scripts/modules/console/intellisense.py b/release/scripts/modules/console/intellisense.py index 7e293ee0082..68ddb5ed12b 100644 --- a/release/scripts/modules/console/intellisense.py +++ b/release/scripts/modules/console/intellisense.py @@ -1,5 +1,3 @@ -# Copyright (c) 2009 www.stani.be (GPL license) - # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or @@ -18,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# Copyright (c) 2009 www.stani.be + # """This module provides intellisense features such as: diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index 4a7700b03bb..9c7fdf495ee 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -1,5 +1,4 @@ # ##### BEGIN GPL LICENSE BLOCK ##### - # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/release/scripts/startup/bl_ui/properties_output.py b/release/scripts/startup/bl_ui/properties_output.py index d96a53f6ab8..ff98cbbaa75 100644 --- a/release/scripts/startup/bl_ui/properties_output.py +++ b/release/scripts/startup/bl_ui/properties_output.py @@ -1,5 +1,4 @@ # ##### BEGIN GPL LICENSE BLOCK ##### - # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 3abaa490d02..7f76431cc9a 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -1,5 +1,4 @@ # ##### BEGIN GPL LICENSE BLOCK ##### - # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/source/blender/blenkernel/intern/armature_pose.cc b/source/blender/blenkernel/intern/armature_pose.cc index a62a32d9633..de26b997e76 100644 --- a/source/blender/blenkernel/intern/armature_pose.cc +++ b/source/blender/blenkernel/intern/armature_pose.cc @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2015 Blender Foundation. * All rights reserved. - * - * Defines and code for core node types */ /** \file diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index 73a396b2cdd..f19065f039b 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2015 Blender Foundation. * All rights reserved. - * - * Defines and code for core node types */ /** \file diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c index 74eb95add51..fdd84f3dfd4 100644 --- a/source/blender/blenkernel/intern/attribute.c +++ b/source/blender/blenkernel/intern/attribute.c @@ -15,13 +15,12 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * - * Implementation of generic geometry attributes management. This is built - * on top of CustomData, which manages individual domains. */ /** \file * \ingroup bke + * Implementation of generic geometry attributes management. This is built + * on top of CustomData, which manages individual domains. */ #include diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 275500ba2f6..18bd6ec2281 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -16,12 +16,11 @@ * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. * Implementation of CDDerivedMesh. - * - * BKE_cdderivedmesh.h contains the function prototypes for this file. */ /** \file * \ingroup bke + * BKE_cdderivedmesh.h contains the function prototypes for this file. */ #include "atomic_ops.h" diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index c5cc077c8ae..6db5ae7567f 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -15,13 +15,13 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Implementation of CustomData. - * - * BKE_customdata.h contains the function prototypes for this file. */ /** \file * \ingroup bke + * Implementation of CustomData. + * + * BKE_customdata.h contains the function prototypes for this file. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index e9c8df76351..98bbd920615 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -15,9 +15,6 @@ * * The Original Code is Copyright (C) 2005 by the Blender Foundation. * All rights reserved. - * Modifier stack implementation. - * - * BKE_modifier.h contains the function prototypes for this file. */ /** \file diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index ac6b0a04def..3c5cdb1ba78 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -15,6 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. + */ + +/** \file + * \ingroup bke + * * MetaBalls are created from a single Object (with a name without number in it), * here the DispList and BoundBox also is located. * All objects with the same name (but with a number in it) are added to this. @@ -22,10 +27,6 @@ * texture coordinates are patched within the displist */ -/** \file - * \ingroup bke - */ - #include #include #include diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 829ef08a8fb..4cedaff7c00 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -15,13 +15,12 @@ * * The Original Code is Copyright (C) 2005 by the Blender Foundation. * All rights reserved. - * Modifier stack implementation. - * - * BKE_modifier.h contains the function prototypes for this file. */ /** \file * \ingroup bke + * Modifier stack implementation. + * BKE_modifier.h contains the function prototypes for this file. */ /* Allow using deprecated functionality for .blend file I/O. */ diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 97326c24a61..dacc24c32da 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -15,13 +15,13 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Based on original code by Drew Whitehouse / Houdini Ocean Toolkit - * OpenMP hints by Christian Schnellhammer */ /** \file * \ingroup bke + * + * Based on original code by Drew Whitehouse / Houdini Ocean Toolkit + * OpenMP hints by Christian Schnellhammer */ #include diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c index 9b79d5635d1..60b7e4e5c8b 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.c +++ b/source/blender/blenkernel/intern/vfontdata_freetype.c @@ -15,6 +15,10 @@ * * The Original Code is written by Rob Haarsma (phase) * All rights reserved. + */ + +/** \file + * \ingroup bke * * This code parses the Freetype font outline data to chains of Blender's bezier-triples. * Additional information can be found at the bottom of this file. @@ -22,10 +26,6 @@ * Code that uses exotic character maps is present but commented out. */ -/** \file - * \ingroup bke - */ - #include #include FT_FREETYPE_H /* not needed yet */ diff --git a/source/blender/compositor/nodes/COM_AntiAliasingNode.cc b/source/blender/compositor/nodes/COM_AntiAliasingNode.cc index b11c57041d9..d1b2e69d7ff 100644 --- a/source/blender/compositor/nodes/COM_AntiAliasingNode.cc +++ b/source/blender/compositor/nodes/COM_AntiAliasingNode.cc @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #include "COM_AntiAliasingNode.h" diff --git a/source/blender/compositor/nodes/COM_AntiAliasingNode.h b/source/blender/compositor/nodes/COM_AntiAliasingNode.h index 05c51d5856a..bcae235b434 100644 --- a/source/blender/compositor/nodes/COM_AntiAliasingNode.h +++ b/source/blender/compositor/nodes/COM_AntiAliasingNode.h @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #pragma once diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 20e85c69ac8..c466338b61c 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #include "COM_SMAAOperation.h" diff --git a/source/blender/compositor/operations/COM_SMAAOperation.h b/source/blender/compositor/operations/COM_SMAAOperation.h index ec04594e0aa..bac33f0a2b4 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.h +++ b/source/blender/compositor/operations/COM_SMAAOperation.h @@ -1,6 +1,4 @@ /* - * Copyright 2017, Blender Foundation. - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -15,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: IRIE Shinsuke + * Copyright 2017, Blender Foundation. */ #pragma once -- cgit v1.2.3 From 68a21697bed854f5e1fcae2b7375b809a3cf2b8c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 16:00:05 +1100 Subject: Cleanup: remove "The Original Code is: ..." from code comments This is almost always meaningless as most code has changed since the comment was added. Besides this, version control can be used to check if/when a file was modified. Some cases of this were kept when they contain details about the original copyright holder. --- intern/ghost/intern/GHOST_ImeWin32.cpp | 2 -- intern/ghost/intern/GHOST_ImeWin32.h | 2 -- source/blender/blenlib/BLI_math.h | 2 -- source/blender/blenlib/BLI_math_base.h | 2 -- source/blender/blenlib/BLI_math_color.h | 2 -- source/blender/blenlib/BLI_math_color_blend.h | 2 -- source/blender/blenlib/BLI_math_geom.h | 2 -- source/blender/blenlib/BLI_math_inline.h | 2 -- source/blender/blenlib/BLI_math_matrix.h | 2 -- source/blender/blenlib/BLI_math_rotation.h | 2 -- source/blender/blenlib/BLI_math_vector.h | 2 -- source/blender/blenlib/intern/bitmap_draw_2d.c | 2 -- source/blender/blenlib/intern/math_base.c | 2 -- source/blender/blenlib/intern/math_base_inline.c | 2 -- source/blender/blenlib/intern/math_color.c | 2 -- source/blender/blenlib/intern/math_color_blend_inline.c | 2 -- source/blender/blenlib/intern/math_color_inline.c | 2 -- source/blender/blenlib/intern/math_geom.c | 2 -- source/blender/blenlib/intern/math_geom_inline.c | 2 -- source/blender/blenlib/intern/math_matrix.c | 2 -- source/blender/blenlib/intern/math_rotation.c | 2 -- source/blender/blenlib/intern/math_vector.c | 2 -- source/blender/blenlib/intern/math_vector_inline.c | 2 -- source/blender/nodes/composite/nodes/node_composite_antialiasing.cc | 2 -- source/blender/nodes/composite/nodes/node_composite_denoise.cc | 2 -- 25 files changed, 50 deletions(-) diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp index 2a1bfb633b3..4531d64fb29 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.cpp +++ b/intern/ghost/intern/GHOST_ImeWin32.cpp @@ -15,8 +15,6 @@ * * The Original Code is Copyright (c) 2010 The Chromium Authors. All rights reserved. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/intern/ghost/intern/GHOST_ImeWin32.h b/intern/ghost/intern/GHOST_ImeWin32.h index d17a6d79503..62378371250 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.h +++ b/intern/ghost/intern/GHOST_ImeWin32.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (c) 2010 The Chromium Authors. All rights reserved. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/BLI_math.h b/source/blender/blenlib/BLI_math.h index 5768b098d2f..b3ce6c0747a 100644 --- a/source/blender/blenlib/BLI_math.h +++ b/source/blender/blenlib/BLI_math.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index f6462233106..69abe49c207 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 0798acbb790..e1956d2bc2b 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_color_blend.h b/source/blender/blenlib/BLI_math_color_blend.h index 2aff629def8..df70da0eec3 100644 --- a/source/blender/blenlib/BLI_math_color_blend.h +++ b/source/blender/blenlib/BLI_math_color_blend.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 6d7159f73c6..2556aae6aa4 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h index 70f56d15164..35e08898385 100644 --- a/source/blender/blenlib/BLI_math_inline.h +++ b/source/blender/blenlib/BLI_math_inline.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 1dcc1c1df49..ac9364fc254 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index c27cf71ce5f..907dc5601fe 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 1ed8d4fc005..04b7ac5db62 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ #pragma once diff --git a/source/blender/blenlib/intern/bitmap_draw_2d.c b/source/blender/blenlib/intern/bitmap_draw_2d.c index 670ea75e9ea..31b8939753e 100644 --- a/source/blender/blenlib/intern/bitmap_draw_2d.c +++ b/source/blender/blenlib/intern/bitmap_draw_2d.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c index be70acf622a..f2e7f411524 100644 --- a/source/blender/blenlib/intern/math_base.c +++ b/source/blender/blenlib/intern/math_base.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index cfcc54b1136..a7729d83726 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 5e52873649e..60931f0c474 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c index 73ecb2cf798..7d1003a05ba 100644 --- a/source/blender/blenlib/intern/math_color_blend_inline.c +++ b/source/blender/blenlib/intern/math_color_blend_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index a7f229e7147..27cad310aa5 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d61c6c015f6..afbaf0733b6 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 09028a1eb9a..17580d84c38 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 9c719b12756..73e64c2bee7 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index dbcf3a6500c..9de9e3d2045 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index a0afab8a179..fb23018b0e0 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 3022dbbe4ff..3e932572038 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc index fcc04a85b38..d889130c2fa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc +++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2017 Blender Foundation. * All rights reserved. - * - * The Original Code is: all of this file. */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index d407bcbde63..8b9ccfe47e0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -15,8 +15,6 @@ * * The Original Code is Copyright (C) 2019 Blender Foundation. * All rights reserved. - * - * The Original Code is: all of this file. */ /** \file -- cgit v1.2.3 From 2c7f2a0ba42898e248920ecd3a03e49c0d9f99a8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 16:21:21 +1100 Subject: Cleanup: simplify copyright headers for sequence & imbuf --- source/blender/editors/space_sequencer/sequencer_scopes.c | 2 +- source/blender/imbuf/intern/indexer.c | 2 +- source/blender/sequencer/intern/clipboard.c | 8 +++----- source/blender/sequencer/intern/effects.c | 8 +++----- source/blender/sequencer/intern/iterator.c | 8 +++----- source/blender/sequencer/intern/multiview.c | 8 +++----- source/blender/sequencer/intern/proxy.c | 8 +++----- source/blender/sequencer/intern/proxy_job.c | 8 +++----- source/blender/sequencer/intern/render.c | 8 +++----- source/blender/sequencer/intern/sequencer.c | 8 +++----- source/blender/sequencer/intern/sound.c | 8 +++----- source/blender/sequencer/intern/strip_add.c | 8 +++----- source/blender/sequencer/intern/strip_edit.c | 8 +++----- source/blender/sequencer/intern/strip_relations.c | 8 +++----- source/blender/sequencer/intern/strip_select.c | 8 +++----- source/blender/sequencer/intern/strip_time.c | 8 +++----- source/blender/sequencer/intern/strip_transform.c | 8 +++----- source/blender/sequencer/intern/utils.c | 8 +++----- 18 files changed, 50 insertions(+), 82 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 5d857f62b47..fd341fc9c0d 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Author: Peter Schlaile < peter [at] schlaile [dot] de > + * Copyright 2006-2008 Peter Schlaile < peter [at] schlaile [dot] de > */ /** \file diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 00e96e7840b..2aa61a3b5ee 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Peter Schlaile 2011 + * Copyright 2011 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/clipboard.c b/source/blender/sequencer/intern/clipboard.c index 886ee89595b..82599a5fb69 100644 --- a/source/blender/sequencer/intern/clipboard.c +++ b/source/blender/sequencer/intern/clipboard.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index a35e83a8632..909954b99f1 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c index 6cd53f08b3a..42a5f5df787 100644 --- a/source/blender/sequencer/intern/iterator.c +++ b/source/blender/sequencer/intern/iterator.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/multiview.c b/source/blender/sequencer/intern/multiview.c index 68d2a33fd5c..2658846209f 100644 --- a/source/blender/sequencer/intern/multiview.c +++ b/source/blender/sequencer/intern/multiview.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index 5982f89a287..906474f301d 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/proxy_job.c b/source/blender/sequencer/intern/proxy_job.c index afdac04d998..8989d7959c9 100644 --- a/source/blender/sequencer/intern/proxy_job.c +++ b/source/blender/sequencer/intern/proxy_job.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index a6c627e5ce7..08c81096b14 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c index 8e824f59dda..387b65648a4 100644 --- a/source/blender/sequencer/intern/sequencer.c +++ b/source/blender/sequencer/intern/sequencer.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/sound.c b/source/blender/sequencer/intern/sound.c index 0788003fb12..141b07cebbe 100644 --- a/source/blender/sequencer/intern/sound.c +++ b/source/blender/sequencer/intern/sound.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index dd8966acfd8..eb34d287dcc 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index 0479d3012fa..0d6a94a806d 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c index 7e7fc9e6bf7..a716bd6fed8 100644 --- a/source/blender/sequencer/intern/strip_relations.c +++ b/source/blender/sequencer/intern/strip_relations.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/strip_select.c b/source/blender/sequencer/intern/strip_select.c index 8927e092864..c73e7d3a420 100644 --- a/source/blender/sequencer/intern/strip_select.c +++ b/source/blender/sequencer/intern/strip_select.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c index 31ee20cb6ca..2d36ab0654b 100644 --- a/source/blender/sequencer/intern/strip_time.c +++ b/source/blender/sequencer/intern/strip_time.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index 432fc1c166f..f4f492708eb 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index 140aa2d67c5..fa34f0d6c79 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - Blender Foundation, 2003-2009 - * - Peter Schlaile 2005/2006 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2003-2009 Blender Foundation. + * 2005-2006 Peter Schlaile */ /** \file -- cgit v1.2.3 From 19100aa57d847699d17527b76c2fab1f4ab88885 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 18:09:08 +1100 Subject: Cleanup: move file descriptions into doxygen file section Also other minor corrections & reformat particle system copyright. --- intern/ghost/intern/GHOST_ImeWin32.cpp | 1 - intern/ghost/intern/GHOST_ImeWin32.h | 1 - source/blender/blenkernel/BKE_particle.h | 7 ++----- source/blender/blenkernel/intern/particle_system.c | 7 ++----- source/blender/blenloader/intern/readfile.h | 2 +- source/blender/editors/armature/pose_edit.c | 2 +- source/blender/editors/armature/pose_group.c | 2 +- source/blender/editors/gpencil/gpencil_convert.c | 2 +- source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/gpencil/gpencil_edit_curve.c | 2 +- source/blender/editors/gpencil/gpencil_interpolate.c | 2 +- source/blender/editors/gpencil/gpencil_merge.c | 2 +- source/blender/editors/gpencil/gpencil_mesh.c | 2 +- source/blender/editors/gpencil/gpencil_ops_versioning.c | 2 +- source/blender/editors/gpencil/gpencil_primitive.c | 2 +- source/blender/editors/gpencil/gpencil_sculpt_paint.c | 2 +- source/blender/editors/gpencil/gpencil_vertex_ops.c | 2 +- source/blender/editors/gpencil/gpencil_vertex_paint.c | 2 +- source/blender/editors/gpencil/gpencil_weight_paint.c | 2 +- source/blender/editors/sculpt_paint/paint_image.c | 2 -- source/blender/editors/sculpt_paint/paint_image_proj.c | 2 -- source/blender/imbuf/intern/dds/FlipDXT.cpp | 7 +++++-- 22 files changed, 24 insertions(+), 33 deletions(-) diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp index 4531d64fb29..8366cbba869 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.cpp +++ b/intern/ghost/intern/GHOST_ImeWin32.cpp @@ -14,7 +14,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (c) 2010 The Chromium Authors. All rights reserved. - * All rights reserved. */ /** \file diff --git a/intern/ghost/intern/GHOST_ImeWin32.h b/intern/ghost/intern/GHOST_ImeWin32.h index 62378371250..d17740c42d3 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.h +++ b/intern/ghost/intern/GHOST_ImeWin32.h @@ -14,7 +14,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (c) 2010 The Chromium Authors. All rights reserved. - * All rights reserved. */ /** \file diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 804331a3412..b5e60da540e 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -13,11 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2007 by Janne Karhu. - * All rights reserved. - * Adaptive time step - * Classical SPH - * Copyright 2011-2012 AutoCRC + * Copyright 2007 Janne Karhu. All rights reserved. + * 2011-2012 AutoCRC (adaptive time step, Classical SPH). */ #pragma once diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e489f9e2bac..6953ecf38c3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -13,11 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2007 by Janne Karhu. - * All rights reserved. - * Adaptive time step - * Classical SPH - * Copyright 2011-2012 AutoCRC + * Copyright 2007 Janne Karhu. All rights reserved. + * 2011-2012 AutoCRC (adaptive time step, Classical SPH). */ /** \file diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 44045cf99dd..d75aab9ba9c 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * blenloader readfile private function prototypes */ /** \file * \ingroup blenloader + * blenloader readfile private function prototypes. */ #pragma once diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index cc99027c470..5db4a4b6eaa 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Pose Mode API's and Operators for Pose Mode armatures */ /** \file * \ingroup edarmature + * Pose Mode API's and Operators for Pose Mode armatures. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index 466c423c27c..10ffa3fcae2 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation * All rights reserved. - * Implementation of Bone Groups operators and editing API's */ /** \file * \ingroup edarmature + * Implementation of Bone Groups operators and editing API's. */ #include diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index bf414851aed..8e7a0083ded 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operator for converting Grease Pencil data to geometry */ /** \file * \ingroup edgpencil + * Operator for converting Grease Pencil data to geometry. */ #include diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c910162415d..dda36cf78d9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Operators for editing Grease Pencil strokes. */ #include diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index 2d7497357f2..5002623fbb1 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Operators for editing Grease Pencil strokes. */ #include diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 2023ae5fe27..2d88461fb15 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2016, Blender Foundation * This is a new part of Blender - * Operators for interpolating new Grease Pencil frames from existing strokes */ /** \file * \ingroup edgpencil + * Operators for interpolating new Grease Pencil frames from existing strokes. */ #include diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index 925c2e1cd7f..884167d7496 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2019, Blender Foundation. * This is a new part of Blender - * Operators for merge Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Operators for merge Grease Pencil strokes. */ #include diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c index efe29e852f2..adf76e79c2a 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.c +++ b/source/blender/editors/gpencil/gpencil_mesh.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2008, Blender Foundation * This is a new part of Blender - * Operator for converting Grease Pencil data to geometry */ /** \file * \ingroup edgpencil + * Operator for converting Grease Pencil data to geometry. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil/gpencil_ops_versioning.c index 45842c28dff..d9706c281ca 100644 --- a/source/blender/editors/gpencil/gpencil_ops_versioning.c +++ b/source/blender/editors/gpencil/gpencil_ops_versioning.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2018, Blender Foundation, * This is a new part of Blender - * Use deprecated data to convert old 2.7x files */ /** \file * \ingroup edgpencil + * Use deprecated data to convert old 2.7x files. */ /* Allow using deprecated functionality. */ diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 2715491414a..fa31dfffbc1 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2017, Blender Foundation * This is a new part of Blender - * Operators for creating new Grease Pencil primitives (boxes, circles, ...) */ /** \file * \ingroup edgpencil + * Operators for creating new Grease Pencil primitives (boxes, circles, ...). */ #include diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 50c7202599a..0cd4efb10d6 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c b/source/blender/editors/gpencil/gpencil_vertex_ops.c index 891bd3ca5ec..d9f4cc87afc 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_ops.c +++ b/source/blender/editors/gpencil/gpencil_vertex_ops.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c index 05304f9914f..2c16894354e 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c index 15f99d83f6d..fe4ab648581 100644 --- a/source/blender/editors/gpencil/gpencil_weight_paint.c +++ b/source/blender/editors/gpencil/gpencil_weight_paint.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2015, Blender Foundation * This is a new part of Blender - * Brush based operators for editing Grease Pencil strokes */ /** \file * \ingroup edgpencil + * Brush based operators for editing Grease Pencil strokes. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a912bb5cf3b..d5aa7647603 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -14,8 +14,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index f05cd4c3d5f..4d23119dd5f 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -14,8 +14,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: some of this file. */ /** \file diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp index 6686d56e9d1..a3cd8056290 100644 --- a/source/blender/imbuf/intern/dds/FlipDXT.cpp +++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp @@ -31,8 +31,11 @@ * All rights reserved. */ -/* This file comes from the chromium project, adapted to Blender to add DDS - * flipping to OpenGL convention for Blender */ +/** \file + * \ingroup imbdds + * This file comes from the chromium project, adapted to Blender to add DDS + * flipping to OpenGL convention for Blender. + */ #include "IMB_imbuf_types.h" -- cgit v1.2.3 From 81da638c44b450d9cd1a208924eace40420666ff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 18:31:42 +1100 Subject: Cleanup: move file descriptions into doxygen file section Continuation of 19100aa57d847699d17527b76c2fab1f4ab88885. --- intern/ghost/intern/GHOST_DisplayManagerX11.cpp | 8 +++----- intern/ghost/intern/GHOST_SystemX11.cpp | 7 +++---- intern/iksolver/extern/IK_solver.h | 1 - intern/iksolver/intern/IK_Math.h | 1 - intern/iksolver/intern/IK_QSegment.h | 1 - intern/iksolver/intern/IK_QTask.h | 1 - source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 4 ++-- source/blender/blenlib/intern/BLI_dynstr.c | 2 +- source/blender/blenlib/intern/BLI_linklist.c | 1 - source/blender/blenlib/intern/path_util.c | 2 +- source/blender/blenlib/intern/winstuff.c | 2 +- source/blender/blenloader/BLO_undofile.h | 4 +++- source/blender/editors/armature/armature_add.c | 2 +- source/blender/editors/armature/armature_edit.c | 2 +- source/blender/editors/armature/armature_naming.c | 2 +- source/blender/editors/armature/armature_relations.c | 2 +- source/blender/editors/armature/armature_select.c | 2 +- source/blender/editors/armature/armature_skinning.c | 4 ++-- source/blender/editors/include/UI_view2d.h | 4 ++-- source/blender/editors/screen/screendump.c | 2 +- source/blender/editors/sculpt_paint/paint_hide.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 2 +- source/blender/editors/sculpt_paint/sculpt_brush_types.c | 2 +- source/blender/editors/sculpt_paint/sculpt_ops.c | 2 +- source/blender/editors/sculpt_paint/sculpt_undo.c | 2 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- source/blender/ikplugin/BIK_api.h | 1 - source/blender/ikplugin/intern/ikplugin_api.c | 1 - source/blender/ikplugin/intern/ikplugin_api.h | 1 - source/blender/ikplugin/intern/iksolver_plugin.c | 1 - source/blender/ikplugin/intern/iksolver_plugin.h | 1 - source/blender/ikplugin/intern/itasc_plugin.cpp | 1 - source/blender/ikplugin/intern/itasc_plugin.h | 1 - source/blender/imbuf/intern/divers.c | 1 - source/blender/imbuf/intern/filter.c | 1 - source/blender/imbuf/intern/readimage.c | 1 - source/blender/imbuf/intern/rectop.c | 1 - source/blender/imbuf/intern/rotate.c | 1 - source/blender/imbuf/intern/scaling.c | 1 - source/blender/imbuf/intern/util.c | 1 - source/blender/imbuf/intern/util_gpu.c | 1 - source/blender/imbuf/intern/writeimage.c | 1 - source/blender/makesdna/DNA_constraint_types.h | 2 +- source/blender/makesdna/intern/dna_genfile.c | 2 +- source/blender/makesdna/intern/dna_rename_defs.h | 1 - source/blender/nodes/composite/nodes/node_composite_blur.cc | 1 - source/blender/nodes/composite/nodes/node_composite_bokehblur.cc | 1 - source/blender/nodes/composite/nodes/node_composite_common.cc | 1 - source/blender/nodes/composite/nodes/node_composite_switchview.cc | 1 - source/blender/nodes/shader/nodes/node_shader_common.cc | 1 - source/blender/nodes/texture/nodes/node_texture_common.c | 1 - 52 files changed, 33 insertions(+), 62 deletions(-) diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp index 2ebdf8b3f2a..b86ef53ee84 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp @@ -13,11 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * Video mode switching - * Copyright (C) 1997-2001 Id Software, Inc. - * Ported from Quake 2 by Alex Fraser + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 1997-2001 Id Software, Inc. Video mode switching. + Ported from Quake 2 by Alex Fraser . */ /** \file diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 85504bd94fb..8536cb4346a 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -13,10 +13,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * Part of this code has been taken from Qt, under LGPL license - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2009 Nokia Corporation and/or its subsidiary(-ies). + Part of this code has been taken from Qt, under LGPL license. */ /** \file diff --git a/intern/iksolver/extern/IK_solver.h b/intern/iksolver/extern/IK_solver.h index 8e7ea11bc18..302ed1545b4 100644 --- a/intern/iksolver/extern/IK_solver.h +++ b/intern/iksolver/extern/IK_solver.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Laurence */ /** \file diff --git a/intern/iksolver/intern/IK_Math.h b/intern/iksolver/intern/IK_Math.h index be115364fb7..6a284df51f4 100644 --- a/intern/iksolver/intern/IK_Math.h +++ b/intern/iksolver/intern/IK_Math.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Laurence */ /** \file diff --git a/intern/iksolver/intern/IK_QSegment.h b/intern/iksolver/intern/IK_QSegment.h index 17b56b1cfb3..4abb94ec4f7 100644 --- a/intern/iksolver/intern/IK_QSegment.h +++ b/intern/iksolver/intern/IK_QSegment.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Laurence */ /** \file diff --git a/intern/iksolver/intern/IK_QTask.h b/intern/iksolver/intern/IK_QTask.h index faca6e2a036..c0f1672ef80 100644 --- a/intern/iksolver/intern/IK_QTask.h +++ b/intern/iksolver/intern/IK_QTask.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Laurence */ /** \file diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 18bd6ec2281..d8ad4dd89e4 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Implementation of CDDerivedMesh. */ /** \file * \ingroup bke + * Implementation of #CDDerivedMesh. * BKE_cdderivedmesh.h contains the function prototypes for this file. */ diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index a4f20f980b4..93c8c550663 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Functions for writing avi-format files. - * Added interface for generic movie support (ton) */ /** \file + * Functions for writing avi-format files. + * Added interface for generic movie support (ton) * \ingroup bke */ diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c index 262d112d914..bc61282fa20 100644 --- a/source/blender/blenlib/intern/BLI_dynstr.c +++ b/source/blender/blenlib/intern/BLI_dynstr.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Dynamically sized string ADT */ /** \file * \ingroup bli + * Dynamically sized string ADT. */ #include diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index 765d2f0be55..f34179b2fa6 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Support for linked lists. */ /** \file diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index f39797c980c..3b9b7ed6ddb 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * various string, file, list operations. */ /** \file * \ingroup bli + * Various string, file, list operations. */ #include diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 11345fc7242..57f3b740a03 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Windows-posix compatibility layer, windows-specific functions. */ /** \file * \ingroup bli + * Windows-posix compatibility layer, windows-specific functions. */ #ifdef WIN32 diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h index 0e2c22d7e4d..772abebeb26 100644 --- a/source/blender/blenloader/BLO_undofile.h +++ b/source/blender/blenloader/BLO_undofile.h @@ -15,13 +15,13 @@ * * The Original Code is Copyright (C) 2004 Blender Foundation. * All rights reserved. - * external writefile function prototypes */ #pragma once /** \file * \ingroup blenloader + * External writefile function prototypes. */ #include "BLI_filereader.h" @@ -91,6 +91,8 @@ void BLO_memfile_chunk_add(MemFileWriteData *mem_data, const char *buf, size_t s /** * Not memfile itself. */ +/* **************** support for memory-write, for undo buffers *************** */ + extern void BLO_memfile_free(MemFile *memfile); /** * Result is that 'first' is being freed. diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index b8a4351357d..e1d4b5fec73 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Operators and API's for creating bones */ /** \file * \ingroup edarmature + * Operators and API's for creating bones. */ #include "DNA_anim_types.h" diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index b709980cabe..0094783e50f 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Armature EditMode tools - transforms, chain based editing, and other settings */ /** \file * \ingroup edarmature + * Armature EditMode tools - transforms, chain based editing, and other settings. */ #include "DNA_armature_types.h" diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 750c64d74a7..c45c6297d86 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Operators and API's for renaming bones both in and out of Edit Mode */ /** \file * \ingroup edarmature + * Operators and API's for renaming bones both in and out of Edit Mode. * * This file contains functions/API's for renaming bones and/or working with them. */ diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index eebe8a447f7..17d25aec198 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Operators for relations between bones and for transferring bones between armature objects */ /** \file * \ingroup edarmature + * Operators for relations between bones and for transferring bones between armature objects. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index f9b52eb53ed..111989f1d86 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * API's and Operators for selecting armature bones in EditMode */ /** \file * \ingroup edarmature + * API's and Operators for selecting armature bones in EditMode. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index ec5c665402b..9ef198f442c 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -15,12 +15,12 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * API's for creating vertex groups from bones - * - Interfaces with heat weighting in meshlaplacian */ /** \file * \ingroup edarmature + * API's for creating vertex groups from bones + * - Interfaces with heat weighting in meshlaplacian. */ #include "DNA_armature_types.h" diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index a3f39e1286e..0a28b1cafe1 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -15,12 +15,12 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * Generic 2d view with should allow drawing grids, - * panning, zooming, scrolling, .. */ /** \file * \ingroup editorui + * Generic 2D view with should allow drawing grids, + * panning, zooming, scrolling, .. etc. */ #pragma once diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 4bc9f1e2565..2b16b70d1ef 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Making screendumps. */ /** \file * \ingroup edscr + * Making screenshots of the entire window or sub-regions. */ #include diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index da627c6b7db..805d2221f6f 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2010 by Nicholas Bishop * All rights reserved. - * Implements the PBVH node hiding operator */ /** \file * \ingroup edsculpt + * Implements the PBVH node hiding operator. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 07e26a3d931..ea3d694542c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.c b/source/blender/editors/sculpt_paint/sculpt_brush_types.c index c2acc361a79..0d2c5641183 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.c +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index 119d246a770..f50775f8a32 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 8819496c168..0b64d1f8a35 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2006 by Nicholas Bishop * All rights reserved. - * Implements the Sculpt Mode tools */ /** \file * \ingroup edsculpt + * Implements the Sculpt Mode tools. */ #include diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index e5ca5e4defd..3e05b8d7a7f 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) Blender Foundation, 2002-2009 * All rights reserved. - * UV Sculpt tools */ /** \file * \ingroup edsculpt + * UV Sculpt tools. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h index 674b384adf2..7ce0feb3989 100644 --- a/source/blender/ikplugin/BIK_api.h +++ b/source/blender/ikplugin/BIK_api.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/ikplugin_api.c b/source/blender/ikplugin/intern/ikplugin_api.c index 233150a77aa..8bbab832b66 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.c +++ b/source/blender/ikplugin/intern/ikplugin_api.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/ikplugin_api.h b/source/blender/ikplugin/intern/ikplugin_api.h index f61ba7e3a63..9d54cbec80c 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.h +++ b/source/blender/ikplugin/intern/ikplugin_api.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 0ee8b3057d2..5daad507efe 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/iksolver_plugin.h b/source/blender/ikplugin/intern/iksolver_plugin.h index 28356b4fc9c..3cb6ac171d9 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.h +++ b/source/blender/ikplugin/intern/iksolver_plugin.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 4a4e22ed884..102ad46a5f2 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/ikplugin/intern/itasc_plugin.h b/source/blender/ikplugin/intern/itasc_plugin.h index 89342295b35..cd4e210966e 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.h +++ b/source/blender/ikplugin/intern/itasc_plugin.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Original author: Benoit Bolsee */ /** \file diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index f23748e59a2..37ed993f3f6 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 324bc9806c1..c6f33664f8b 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * filter.c */ /** \file diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index c75bdfa375c..ef0d547055d 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 1d81ee768e9..d368504dab0 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index f02f3e37d6a..84161167ebc 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * rotate.c */ /** \file diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index a18ba6748de..a745555eec7 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * allocimbuf.c */ /** \file diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 18ed4710e78..10de80c1330 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * util.c */ /** \file diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index cc6fef634d5..4775d5154a3 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * util.c */ /** \file diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index f21d274f8fd..c2c87375363 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * writeimage.c */ /** \file diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 53b1a60e53e..b7ba05f5879 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * Constraint DNA data */ /** \file * \ingroup DNA + * Constraint DNA data. */ #pragma once diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 0edc9b8fd9f..634aa91cf95 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * DNA handling */ /** \file * \ingroup DNA + * \brief DNA handling * * Lowest-level functions for decoding the parts of a saved .blend * file, including interpretation of its SDNA block and conversion of diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index cb8052856a7..b666a5dce56 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * DNA handling */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc index dd0a6db74c1..96dbf0def4a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc index 282328b5e10..b7ab28f3465 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_common.cc b/source/blender/nodes/composite/nodes/node_composite_common.cc index d5f7279398e..a3fa940460b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.cc +++ b/source/blender/nodes/composite/nodes/node_composite_common.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.cc b/source/blender/nodes/composite/nodes/node_composite_switchview.cc index 678d7fe1a9b..606eaa8ed99 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switchview.cc +++ b/source/blender/nodes/composite/nodes/node_composite_switchview.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Dalai Felinto */ /** \file diff --git a/source/blender/nodes/shader/nodes/node_shader_common.cc b/source/blender/nodes/shader/nodes/node_shader_common.cc index 3f0fff34533..f7a17f0722c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.cc +++ b/source/blender/nodes/shader/nodes/node_shader_common.cc @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index d68cfe78b44..9bd16a318c9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2006 Blender Foundation. * All rights reserved. - * Juho Vepsäläinen */ /** \file -- cgit v1.2.3 From 6f01758b47c5cde0f8bf70d67e6240a092c04e27 Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Wed, 9 Feb 2022 10:27:35 +0100 Subject: Added a "Sharpen Less" kernel for the Filter Compositor node Added a new "Sharpen Less" kernel to the filter compositor node. The intent here is to provide a much less aggressive sharpening filter that can't simply be solved by toning down the factor on the existing sharpen filter. The existing "Sharpen" filter uses a "box" kernel: ``` -1 -1 -1 -1 9 -1 -1 -1 -1 ``` The new "Sharpen Less" filter uses a "diamond" kernel: ``` 0 -1 0 -1 5 -1 0 -1 0 ``` The difference between the two is clear to see in the following side-by-side: {F12847431} Below shows the difference between the filtering kernels as applied to a B&W render of Suzanne with the UV grid as a texture. The left side of the render using the existing "Sharpen" filter, and the right side showing the new "Sharpen Less" filter. Notice that the left side is more aggressive in accentuating localized contrasts across the image. This can lead to what appears to be aliasing or striations in the resulting image: {F12847429} https://developer.blender.org/T95275 https://blender.community/c/rightclickselect/57Kq/?sorting=hot {F12847428} Reviewed By: #compositing, jbakker Differential Revision: https://developer.blender.org/D14019 --- source/blender/blenkernel/BKE_node.h | 3 ++- source/blender/compositor/nodes/COM_FilterNode.cc | 6 +++++- source/blender/makesrna/intern/rna_nodetree.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 7ffa180b523..359a5662a13 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1303,12 +1303,13 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i /* filter types */ #define CMP_FILT_SOFT 0 -#define CMP_FILT_SHARP 1 +#define CMP_FILT_SHARP_BOX 1 #define CMP_FILT_LAPLACE 2 #define CMP_FILT_SOBEL 3 #define CMP_FILT_PREWITT 4 #define CMP_FILT_KIRSCH 5 #define CMP_FILT_SHADOW 6 +#define CMP_FILT_SHARP_DIAMOND 7 /* scale node type, in custom1 */ #define CMP_SCALE_RELATIVE 0 diff --git a/source/blender/compositor/nodes/COM_FilterNode.cc b/source/blender/compositor/nodes/COM_FilterNode.cc index 2108e68cbec..4eca1492fe9 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.cc +++ b/source/blender/compositor/nodes/COM_FilterNode.cc @@ -48,7 +48,7 @@ void FilterNode::convert_to_operations(NodeConverter &converter, 2 / 16.0f, 1 / 16.0f); break; - case CMP_FILT_SHARP: + case CMP_FILT_SHARP_BOX: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1); break; @@ -80,6 +80,10 @@ void FilterNode::convert_to_operations(NodeConverter &converter, operation = new ConvolutionFilterOperation(); operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1); break; + case CMP_FILT_SHARP_DIAMOND: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(0, -1, 0, -1, 5, -1, 0, -1, 0); + break; default: operation = new ConvolutionFilterOperation(); operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 13c8444de1d..bd74f86c79a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -465,7 +465,8 @@ static const EnumPropertyItem rna_enum_node_tex_dimensions_items[] = { const EnumPropertyItem rna_enum_node_filter_items[] = { {0, "SOFTEN", 0, "Soften", ""}, - {1, "SHARPEN", 0, "Sharpen", ""}, + {1, "SHARPEN", 0, "Box Sharpen", "An aggressive sharpening filter"}, + {7, "SHARPEN_DIAMOND", 0, "Diamond Sharpen", "A moderate sharpening filter"}, {2, "LAPLACE", 0, "Laplace", ""}, {3, "SOBEL", 0, "Sobel", ""}, {4, "PREWITT", 0, "Prewitt", ""}, -- cgit v1.2.3 From 06ac5992618a75c453e495e06af7c5faf30499a7 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 9 Feb 2022 11:19:11 +0100 Subject: Fix T91840: do not create invalid links when inserting a node Differential Revision: https://developer.blender.org/D14050 --- .../editors/space_node/node_relationships.cc | 79 ++++++++++++++-------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index bc79925b51d..2a197e93f42 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2428,54 +2428,73 @@ void ED_node_link_insert(Main *bmain, ScrArea *area) { using namespace blender::ed::space_node; - bNode *select; + bNode *node_to_insert; SpaceNode *snode; - if (!ed_node_link_conditions(area, true, &snode, &select)) { + if (!ed_node_link_conditions(area, true, &snode, &node_to_insert)) { return; } - /* get the link */ - bNodeLink *link; - for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) { + /* Find link to insert on. */ + bNodeTree &ntree = *snode->edittree; + bNodeLink *old_link = nullptr; + LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) { if (link->flag & NODE_LINKFLAG_HILITE) { + old_link = link; break; } } + if (old_link == nullptr) { + return; + } - if (link) { - bNodeSocket *best_input = get_main_socket(*snode->edittree, *select, SOCK_IN); - bNodeSocket *best_output = get_main_socket(*snode->edittree, *select, SOCK_OUT); + old_link->flag &= ~NODE_LINKFLAG_HILITE; - if (best_input && best_output) { - bNode *node = link->tonode; - bNodeSocket *sockto = link->tosock; + bNodeSocket *best_input = get_main_socket(ntree, *node_to_insert, SOCK_IN); + bNodeSocket *best_output = get_main_socket(ntree, *node_to_insert, SOCK_OUT); - link->tonode = select; - link->tosock = best_input; - node_remove_extra_links(*snode, *link); - link->flag &= ~NODE_LINKFLAG_HILITE; + /* Ignore main sockets when the types don't match. */ + if (best_input != nullptr && + !ntree.typeinfo->validate_link(static_cast(old_link->fromsock->type), + static_cast(best_input->type))) { + best_input = nullptr; + } + if (best_output != nullptr && + !ntree.typeinfo->validate_link(static_cast(best_output->type), + static_cast(old_link->tosock->type))) { + best_output = nullptr; + } - bNodeLink *new_link = nodeAddLink(snode->edittree, select, best_output, node, sockto); + bNode *from_node = old_link->fromnode; + bNodeSocket *from_socket = old_link->fromsock; + bNode *to_node = old_link->tonode; - /* Copy the socket index for the new link, and reset it for the old link. This way the - * relative order of links is preserved, and the links get drawn in the right place. */ - new_link->multi_input_socket_index = link->multi_input_socket_index; - link->multi_input_socket_index = 0; + if (best_output != nullptr) { + /* Relink the "start" of the existing link to the newly inserted node. */ + old_link->fromnode = node_to_insert; + old_link->fromsock = best_output; + BKE_ntree_update_tag_link_changed(&ntree); + } + else { + nodeRemLink(&ntree, old_link); + } - /* set up insert offset data, it needs stuff from here */ - if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { - NodeInsertOfsData *iofsd = MEM_cnew(__func__); + if (best_input != nullptr) { + /* Add a new link that connects the node on the left to the newly inserted node. */ + nodeAddLink(&ntree, from_node, from_socket, node_to_insert, best_input); + } - iofsd->insert = select; - iofsd->prev = link->fromnode; - iofsd->next = node; + /* Set up insert offset data, it needs stuff from here. */ + if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { + NodeInsertOfsData *iofsd = MEM_cnew(__func__); - snode->runtime->iofsd = iofsd; - } + iofsd->insert = node_to_insert; + iofsd->prev = from_node; + iofsd->next = to_node; - ED_node_tree_propagate_change(nullptr, bmain, snode->edittree); - } + snode->runtime->iofsd = iofsd; } + + ED_node_tree_propagate_change(nullptr, bmain, snode->edittree); } /** \} */ -- cgit v1.2.3 From d3d9e2abbf820cfcf7bbee08fc0c5d721a612ba1 Mon Sep 17 00:00:00 2001 From: Alaska Date: Wed, 9 Feb 2022 11:25:57 +0100 Subject: Fix small grammatical mistake in Refraction Depth tooltip Reviewed By: jbakker Differential Revision: https://developer.blender.org/D13850 --- source/blender/makesrna/intern/rna_material.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 22a75c0d992..9cbe12d8e1a 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -819,7 +819,7 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Refraction Depth", "Approximate the thickness of the object to compute two refraction " - "event (0 is disabled)"); + "events (0 is disabled)"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); /* For Preview Render */ -- cgit v1.2.3 From fd6506626b519e08d593d4e553590f95edfd0c6a Mon Sep 17 00:00:00 2001 From: Alaska Date: Wed, 9 Feb 2022 11:28:27 +0100 Subject: Adjust "Show Backface" tool tip to be more accurate Reviewed By: fclem Differential Revision: https://developer.blender.org/D13849 --- source/blender/makesrna/intern/rna_material.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 9cbe12d8e1a..8c6d51b1bfa 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -791,8 +791,8 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "blend_flag", MA_BL_HIDE_BACKFACE); RNA_def_property_ui_text(prop, "Show Backface", - "Limit transparency to a single layer " - "(avoids transparency sorting problems)"); + "Render multiple transparent layers " + "(may introduce transparency sorting problems)"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3 From 312c8fdaf927421e697da0185360240bafd64a4b Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 9 Feb 2022 11:44:14 +0100 Subject: Cleanup: Better naming in lib_remap. Renames is_never_null to violates_never_null. --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- source/blender/blenkernel/intern/lib_remap.c | 18 +++++++++--------- source/tools | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index 05005841745..2d12637a69d 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 050058417452bfba0cc9ae8692173eb02ac1ef3a +Subproject commit 2d12637a69df7643484a8a3655b7eeb6faa170a7 diff --git a/release/scripts/addons b/release/scripts/addons index faa9fc7f98e..e1d44bf3750 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit faa9fc7f98e19be54a715c24061185b04dff5b6c +Subproject commit e1d44bf37501eb19a057777bd0b0ba4484773531 diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index a9de5b4a189..8e375ff16b5 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -97,14 +97,14 @@ static void foreach_libblock_remap_callback_skip(const ID *UNUSED(id_owner), const int cb_flag, const bool is_indirect, const bool is_reference, - const bool is_never_null, + const bool violates_never_null, const bool UNUSED(is_obj), const bool is_obj_editmode) { if (is_indirect) { id_remap_data->skipped_indirect++; } - else if (is_never_null || is_obj_editmode || is_reference) { + else if (violates_never_null || is_obj_editmode || is_reference) { id_remap_data->skipped_direct++; } else { @@ -127,10 +127,10 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner, IDRemap *id_remap_data, const int cb_flag, const bool is_indirect, - const bool is_never_null, + const bool violates_never_null, const bool force_user_refcount) { - if (!is_never_null) { + if (!violates_never_null) { *id_ptr = new_id; DEG_id_tag_update_ex(id_remap_data->bmain, id_self, @@ -210,8 +210,8 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) * remapped in this situation. */ const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id_owner) && (id_remap_data->flag & ID_REMAP_FORCE_OBDATA_IN_EDITMODE) == 0); - const bool is_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) && - (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0); + const bool violates_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) && + (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; @@ -239,7 +239,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) /* Special hack in case it's Object->data and we are in edit mode, and new_id is not NULL * (otherwise, we follow common NEVER_NULL flags). * (skipped_indirect too). */ - if ((is_never_null && skip_never_null) || + if ((violates_never_null && skip_never_null) || (is_obj_editmode && (((Object *)id_owner)->data == *id_p) && new_id != NULL) || (skip_indirect && is_indirect) || (is_reference && skip_reference)) { foreach_libblock_remap_callback_skip(id_owner, @@ -248,7 +248,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) cb_flag, is_indirect, is_reference, - is_never_null, + violates_never_null, is_obj, is_obj_editmode); } @@ -261,7 +261,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) id_remap_data, cb_flag, is_indirect, - is_never_null, + violates_never_null, force_user_refcount); } diff --git a/source/tools b/source/tools index 7fd2ed908b4..515e67c1932 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 7fd2ed908b4f50140670caf6786e5ed245b79137 +Subproject commit 515e67c1932bc06f24cb50b621265c2a6e8a25a9 -- cgit v1.2.3 From d82384f7e1a0ae6fd3b27bb261a4cd671c9939ac Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 9 Feb 2022 12:36:20 +0100 Subject: Fix T95640: missing null check in previous commit --- source/blender/editors/space_node/node_relationships.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 2a197e93f42..d92f86c2cfc 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2453,12 +2453,12 @@ void ED_node_link_insert(Main *bmain, ScrArea *area) bNodeSocket *best_output = get_main_socket(ntree, *node_to_insert, SOCK_OUT); /* Ignore main sockets when the types don't match. */ - if (best_input != nullptr && + if (best_input != nullptr && ntree.typeinfo->validate_link != nullptr && !ntree.typeinfo->validate_link(static_cast(old_link->fromsock->type), static_cast(best_input->type))) { best_input = nullptr; } - if (best_output != nullptr && + if (best_output != nullptr && ntree.typeinfo->validate_link != nullptr && !ntree.typeinfo->validate_link(static_cast(best_output->type), static_cast(old_link->tosock->type))) { best_output = nullptr; -- cgit v1.2.3 From 7c10e364b2358f08fa49ce35fc98d4de1431e615 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 9 Feb 2022 13:08:04 +0100 Subject: BLI: wrap parallel_invoke from tbb --- source/blender/blenlib/BLI_task.hh | 14 ++++++++++++++ source/blender/blenlib/tests/BLI_task_test.cc | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh index 84d5cd39bb4..8f75aa19cfe 100644 --- a/source/blender/blenlib/BLI_task.hh +++ b/source/blender/blenlib/BLI_task.hh @@ -31,6 +31,7 @@ # include # include # include +# include # include # include # ifdef WIN32 @@ -103,6 +104,19 @@ Value parallel_reduce(IndexRange range, #endif } +/** + * Execute all of the provided functions. The functions might be executed in parallel or in serial + * or some combination of both. + */ +template void parallel_invoke(Functions &&...functions) +{ +#ifdef WITH_TBB + tbb::parallel_invoke(std::forward(functions)...); +#else + (functions(), ...); +#endif +} + /** See #BLI_task_isolate for a description of what isolating a task means. */ template void isolate_task(const Function &function) { diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc index 3bb6f6f753c..1ed732c1f18 100644 --- a/source/blender/blenlib/tests/BLI_task_test.cc +++ b/source/blender/blenlib/tests/BLI_task_test.cc @@ -1,6 +1,7 @@ /* Apache License, Version 2.0 */ #include "testing/testing.h" +#include #include #include "atomic_ops.h" @@ -12,6 +13,7 @@ #include "BLI_listbase.h" #include "BLI_mempool.h" #include "BLI_task.h" +#include "BLI_task.hh" #define NUM_ITEMS 10000 @@ -280,3 +282,15 @@ TEST(task, ListBaseIter) MEM_freeN(items_buffer); BLI_threadapi_exit(); } + +TEST(task, ParallelInvoke) +{ + std::atomic counter = 0; + blender::threading::parallel_invoke([&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }, + [&]() { counter++; }); + EXPECT_EQ(counter, 6); +} -- cgit v1.2.3 From b4700a13c6aba992539af9d31c5f2c23d95b23fb Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Wed, 9 Feb 2022 13:42:58 +0100 Subject: VSE: Use float for transformation offset When image position is animated, float makes movement look smoother. --- source/blender/makesdna/DNA_sequence_types.h | 4 ++-- source/blender/makesrna/intern/rna_sequencer.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 70f0dc3f5de..622175a8429 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -73,8 +73,8 @@ typedef struct StripCrop { } StripCrop; typedef struct StripTransform { - int xofs; - int yofs; + float xofs; + float yofs; float scale_x; float scale_y; float rotation; diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 9fee54ef38d..15b3a2fe998 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1485,16 +1485,16 @@ static void rna_def_strip_transform(BlenderRNA *brna) RNA_def_property_float_default(prop, 1.0f); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update"); - prop = RNA_def_property(srna, "offset_x", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "xofs"); + prop = RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_float_sdna(prop, NULL, "xofs"); RNA_def_property_ui_text(prop, "Translate X", "Move along X axis"); - RNA_def_property_ui_range(prop, INT_MIN, INT_MAX, 1, 6); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, 3); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update"); - prop = RNA_def_property(srna, "offset_y", PROP_INT, PROP_PIXEL); - RNA_def_property_int_sdna(prop, NULL, "yofs"); + prop = RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_PIXEL); + RNA_def_property_float_sdna(prop, NULL, "yofs"); RNA_def_property_ui_text(prop, "Translate Y", "Move along Y axis"); - RNA_def_property_ui_range(prop, INT_MIN, INT_MAX, 1, 6); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, 3); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceTransform_update"); prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); -- cgit v1.2.3 From 312d6925c45fbd8bc15fd4a5207e70c1f27bfc62 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 23:25:53 +1100 Subject: Cleanup: make file headers more consistent Also some descriptive text into doc-strings. --- intern/ghost/intern/GHOST_DisplayManagerX11.cpp | 2 +- intern/ghost/intern/GHOST_SystemX11.cpp | 2 +- intern/sky/source/sky_model.cpp | 2 +- intern/sky/source/sky_model_data.h | 2 +- release/scripts/startup/bl_operators/vertexpaint_dirt.py | 5 ++--- source/blender/blenkernel/BKE_mesh_fair.h | 5 ++--- source/blender/blenkernel/intern/mesh_fair.cc | 5 ++--- source/blender/blenkernel/intern/object_update.c | 2 +- source/blender/blenlib/intern/scanfill.c | 1 - source/blender/blenlib/intern/winstuff_dir.c | 1 - source/blender/blenloader/intern/readblenentry.c | 2 +- source/blender/blenloader/intern/undofile.c | 1 - source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h | 2 +- source/blender/editors/armature/meshlaplacian.c | 2 +- source/blender/editors/armature/meshlaplacian.h | 3 +-- source/blender/geometry/CMakeLists.txt | 2 +- source/blender/makesdna/intern/dna_defaults.c | 2 -- source/blender/makesrna/intern/rna_particle.c | 4 ++-- source/blender/python/intern/bpy_interface.c | 2 -- source/blender/windowmanager/intern/wm_window.c | 3 +-- tests/python/collada/animation/test_animation_simple.py | 10 ++++++---- tests/python/collada/mesh/test_mesh_simple.py | 10 ++++++---- tests/python/modules/global_report.py | 2 +- tests/python/modules/render_report.py | 8 +++++--- 24 files changed, 37 insertions(+), 43 deletions(-) diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp index b86ef53ee84..59abf9e51e4 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp @@ -15,7 +15,7 @@ * * Copyright 2001-2002 NaN Holding BV. All rights reserved. * 1997-2001 Id Software, Inc. Video mode switching. - Ported from Quake 2 by Alex Fraser . + * Ported from Quake 2 by Alex Fraser . */ /** \file diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 8536cb4346a..941642978c0 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -15,7 +15,7 @@ * * Copyright 2001-2002 NaN Holding BV. All rights reserved. * 2009 Nokia Corporation and/or its subsidiary(-ies). - Part of this code has been taken from Qt, under LGPL license. + * Part of this code has been taken from Qt, under LGPL license. */ /** \file diff --git a/intern/sky/source/sky_model.cpp b/intern/sky/source/sky_model.cpp index 135d5527e7f..946c230781f 100644 --- a/intern/sky/source/sky_model.cpp +++ b/intern/sky/source/sky_model.cpp @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Copyright (c) 2012 - 2013, Lukas Hosek and Alexander Wilkie + * Copyright (c) 2012-2013, Lukas Hosek and Alexander Wilkie * All rights reserved. */ diff --git a/intern/sky/source/sky_model_data.h b/intern/sky/source/sky_model_data.h index 2308f7827b2..4626a819d90 100644 --- a/intern/sky/source/sky_model_data.h +++ b/intern/sky/source/sky_model_data.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Copyright (c) 2012 - 2013, Lukas Hosek and Alexander Wilkie + * Copyright (c) 2012-2013, Lukas Hosek and Alexander Wilkie * All rights reserved. */ diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index 3f43571fee5..8b2a8b541be 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -1,7 +1,5 @@ # ***** BEGIN GPL LICENSE BLOCK ***** # -# Script copyright (C) Campbell J Barton -# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 @@ -17,7 +15,8 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ***** END GPL LICENSE BLOCK ***** -# -------------------------------------------------------------------------- +# +# Copyright Campbell Barton # diff --git a/source/blender/blenkernel/BKE_mesh_fair.h b/source/blender/blenkernel/BKE_mesh_fair.h index c4c1af054f0..2884de6d5c1 100644 --- a/source/blender/blenkernel/BKE_mesh_fair.h +++ b/source/blender/blenkernel/BKE_mesh_fair.h @@ -12,15 +12,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": - * https://github.com/fedackb/mesh-fairing. */ #pragma once /** \file * \ingroup bke + * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": + * https://github.com/fedackb/mesh-fairing. */ #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/mesh_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc index 50db1bc1564..d0a57310fcf 100644 --- a/source/blender/blenkernel/intern/mesh_fair.cc +++ b/source/blender/blenkernel/intern/mesh_fair.cc @@ -12,13 +12,12 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": - * https://github.com/fedackb/mesh-fairing. */ /** \file * \ingroup bke + * Mesh Fairing algorithm designed by Brett Fedack, used in the addon "Mesh Fairing": + * https://github.com/fedackb/mesh-fairing. */ #include "BLI_map.hh" diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 803dde50d96..12ae57af2c3 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 20014 by Blender Foundation. + * The Original Code is Copyright (C) 2014 by Blender Foundation. * All rights reserved. */ diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 9fe82069d2c..4fd6670507a 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * (uit traces) maart 95 */ /** \file diff --git a/source/blender/blenlib/intern/winstuff_dir.c b/source/blender/blenlib/intern/winstuff_dir.c index 6f99ea075bb..f8ab3dc8403 100644 --- a/source/blender/blenlib/intern/winstuff_dir.c +++ b/source/blender/blenlib/intern/winstuff_dir.c @@ -12,7 +12,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * Windows-posix compatibility layer for opendir/readdir/closedir */ /** \file diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index a334d70819d..f01d6afb22d 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -15,11 +15,11 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * .blend file reading entry point */ /** \file * \ingroup blenloader + * `.blend` file reading entry point. */ #include diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index dfa6135dac9..638e6a13b01 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -15,7 +15,6 @@ * * The Original Code is Copyright (C) 2004 Blender Foundation * All rights reserved. - * .blend file reading entry point */ /** \file diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h index bc023766a46..728f631f789 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 20137Blender Foundation. + * The Original Code is Copyright (C) 2017 Blender Foundation. * All rights reserved. */ diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 14f47a84286..b3b6c37cf61 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -12,11 +12,11 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * meshlaplacian.c: Algorithms using the mesh laplacian. */ /** \file * \ingroup edarmature + * Algorithms using the mesh laplacian. */ #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 7e7b64c7510..f024b17f1cc 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -12,12 +12,11 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * BIF_meshlaplacian.h: Algorithms using the mesh laplacian. */ /** \file * \ingroup edarmature + * BIF_meshlaplacian.h: Algorithms using the mesh laplacian. */ #pragma once diff --git a/source/blender/geometry/CMakeLists.txt b/source/blender/geometry/CMakeLists.txt index f7ddd393b4d..110092e4f5f 100644 --- a/source/blender/geometry/CMakeLists.txt +++ b/source/blender/geometry/CMakeLists.txt @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# The Original Code is Copyright (C) 2006, Blender Foundation +# The Original Code is Copyright (C) 2006 Blender Foundation # All rights reserved. set(INC diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index fd23c5c618f..93d8051d6c4 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -12,8 +12,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * DNA default value access. */ /** \file diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 23ec5148f00..df6c12ffb27 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -12,8 +12,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * Adaptive time step - * Copyright 2011 AutoCRC + * + * Copyright 2011 AutoCRC (adaptive time step) */ /** \file diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index faa668df775..cbbf2a3cb43 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -12,8 +12,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Chris Keith, Chris Want, Ken Hughes, Campbell Barton */ /** \file diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index a7b5b9bddda..1d9535e5102 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -14,8 +14,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2007 Blender Foundation but based - * on ghostwinlay.c (C) 2001-2002 by NaN Holding BV - * All rights reserved. + * on ghostwinlay.c (C) 2001-2002 by NaN Holding BV. All rights reserved. */ /** \file diff --git a/tests/python/collada/animation/test_animation_simple.py b/tests/python/collada/animation/test_animation_simple.py index 6b18313c3cd..95c20cbcf31 100644 --- a/tests/python/collada/animation/test_animation_simple.py +++ b/tests/python/collada/animation/test_animation_simple.py @@ -16,10 +16,12 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### -# -# Call as follows: -# python collada_mesh_simple.py --blender PATH_TO_BLENDER_EXE --testdir PATH_TO_SVN/lib/tests/collada/mesh -# + +""" +Call as follows: +python collada_mesh_simple.py --blender PATH_TO_BLENDER_EXE --testdir PATH_TO_SVN/lib/tests/collada/mesh +""" + import sys import bpy import argparse diff --git a/tests/python/collada/mesh/test_mesh_simple.py b/tests/python/collada/mesh/test_mesh_simple.py index 5899d986a14..e48ddcd4477 100644 --- a/tests/python/collada/mesh/test_mesh_simple.py +++ b/tests/python/collada/mesh/test_mesh_simple.py @@ -16,10 +16,12 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### -# -# Call as follows: -# python collada_mesh_simple.py --blender PATH_TO_BLENDER_EXE --testdir PATH_TO_SVN/lib/tests/collada/mesh -# + +""" +Call as follows: +python collada_mesh_simple.py --blender PATH_TO_BLENDER_EXE --testdir PATH_TO_SVN/lib/tests/collada/mesh +""" + import sys import bpy import argparse diff --git a/tests/python/modules/global_report.py b/tests/python/modules/global_report.py index 636ec61d471..89715e526fa 100755 --- a/tests/python/modules/global_report.py +++ b/tests/python/modules/global_report.py @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# + # Generate a HTML page that links to all test reports. import glob diff --git a/tests/python/modules/render_report.py b/tests/python/modules/render_report.py index 90f16dc80fb..d7b198b3203 100755 --- a/tests/python/modules/render_report.py +++ b/tests/python/modules/render_report.py @@ -1,7 +1,9 @@ # Apache License, Version 2.0 -# -# Compare renders or screenshots against reference versions and generate -# a HTML report showing the differences, for regression testing. + +""" +Compare renders or screenshots against reference versions and generate +a HTML report showing the differences, for regression testing. +""" import glob import os -- cgit v1.2.3 From 6345032a49505a853d5f1c83bddddac670314804 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2022 23:54:39 +1100 Subject: Cleanup: non-standard license formatting, minor changes --- build_files/cmake/clang_array_check.py | 9 +-------- source/blender/editors/include/ED_keyframing.h | 1 - source/blender/imbuf/intern/cineon/dpxlib.c | 2 +- source/blender/imbuf/intern/cineon/dpxlib.h | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/build_files/cmake/clang_array_check.py b/build_files/cmake/clang_array_check.py index 63f86b5aab7..a3a0ea63347 100644 --- a/build_files/cmake/clang_array_check.py +++ b/build_files/cmake/clang_array_check.py @@ -1,11 +1,4 @@ -# --- -# * Licensed under the Apache License, Version 2.0 (the "License"); -# * you may not use this file except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# --- -# by Campbell Barton +# Apache License, Version 2.0 """ Invocation: diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 8d89555c732..22a6bdb27ba 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -14,7 +14,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2008, Blender Foundation - * This is a new part of Blender (with some old code) */ /** \file diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index 4580bfd2cbf..79374f87cc1 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999 - 2002 David Hodson + * Copyright 1999-2002 David Hodson */ /** \file diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h index 1228ac4ee66..59fc6344737 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.h +++ b/source/blender/imbuf/intern/cineon/dpxlib.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999 - 2002 David Hodson + * Copyright 1999-2002 David Hodson */ /** \file -- cgit v1.2.3 From 3577ccc9c00c11864c7c77ab1022a7a2f2cc4931 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 9 Feb 2022 14:08:39 +0100 Subject: Cleanup: Add newline in error message. Increases readability during debugging. --- source/blender/blenloader/intern/writefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index aa3eef4b475..4eda63d0817 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -999,7 +999,7 @@ static void write_libraries(WriteData *wd, Main *main) if (!BKE_idtype_idcode_is_linkable(GS(id->name))) { printf( "ERROR: write file: data-block '%s' from lib '%s' is not linkable " - "but is flagged as directly linked", + "but is flagged as directly linked\n", id->name, main->curlib->filepath_abs); BLI_assert(0); -- cgit v1.2.3 From d74bb7be1916744ae56347b49333eac22ebb7339 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 Feb 2022 11:17:13 +0100 Subject: Fix size_t -> int -> size_t round trip in Cycles There are two things achieved by this change: - No possible downcast of size_t to int when calculating motion steps. - Disambiguate call to min() which was for some reason considered ambiguous on 32bit platforms `min(int, unsigned int)`. On an implementation side the `min()` is defined for a fixed width integer type to disambiguate uint from size_t on 32bit platforms, and yet be able to use it for 32bit operands on 64bit platforms without upcast. Fixes 32bit platforms (such as i386) in Debian package build system. Differential Revision: https://developer.blender.org/D13992 --- intern/cycles/bvh/embree.cpp | 6 +++--- intern/cycles/scene/hair.cpp | 8 ++++---- intern/cycles/scene/mesh.cpp | 2 +- intern/cycles/scene/pointcloud.cpp | 2 +- intern/cycles/util/math.h | 7 ++++++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index 616b6273e6a..731fef52063 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -471,7 +471,7 @@ void BVHEmbree::add_instance(Object *ob, int i) assert(instance_bvh != NULL); const size_t num_object_motion_steps = ob->use_motion() ? ob->get_motion().size() : 1; - const size_t num_motion_steps = min(num_object_motion_steps, RTC_MAX_TIME_STEP_COUNT); + const size_t num_motion_steps = min(num_object_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); assert(num_object_motion_steps <= RTC_MAX_TIME_STEP_COUNT); RTCGeometry geom_id = rtcNewGeometry(rtc_device, RTC_GEOMETRY_TYPE_INSTANCE); @@ -522,7 +522,7 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); const size_t num_triangles = mesh->num_triangles(); @@ -775,7 +775,7 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); const size_t num_curves = hair->num_curves(); size_t num_segments = 0; diff --git a/intern/cycles/scene/hair.cpp b/intern/cycles/scene/hair.cpp index 2951a609ae9..0fd9c70cc26 100644 --- a/intern/cycles/scene/hair.cpp +++ b/intern/cycles/scene/hair.cpp @@ -119,7 +119,7 @@ void Hair::Curve::motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = std::min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[2]; @@ -147,7 +147,7 @@ void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[4]; @@ -192,7 +192,7 @@ void Hair::Curve::keys_for_step(const float3 *curve_keys, float4 r_keys[2]) const { k0 = max(k0, 0); - k1 = min(k1, num_keys - 1); + k1 = min(k1, (size_t)(num_keys - 1)); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ @@ -238,7 +238,7 @@ void Hair::Curve::cardinal_keys_for_step(const float3 *curve_keys, float4 r_keys[4]) const { k0 = max(k0, 0); - k3 = min(k3, num_keys - 1); + k3 = min(k3, (size_t)(num_keys - 1)); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp index c381d7a54ff..f53dca88ee0 100644 --- a/intern/cycles/scene/mesh.cpp +++ b/intern/cycles/scene/mesh.cpp @@ -53,7 +53,7 @@ void Mesh::Triangle::motion_verts(const float3 *verts, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float3 curr_verts[3]; diff --git a/intern/cycles/scene/pointcloud.cpp b/intern/cycles/scene/pointcloud.cpp index 4f88fe9db3d..6356a5030f3 100644 --- a/intern/cycles/scene/pointcloud.cpp +++ b/intern/cycles/scene/pointcloud.cpp @@ -55,7 +55,7 @@ float4 PointCloud::Point::motion_key(const float3 *points, /* Figure out which steps we need to fetch and their * interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ const float4 curr_key = point_for_step( diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h index 605a19aaef0..a580a21c28b 100644 --- a/intern/cycles/util/math.h +++ b/intern/cycles/util/math.h @@ -124,7 +124,12 @@ ccl_device_inline int min(int a, int b) return (a < b) ? a : b; } -ccl_device_inline uint min(uint a, uint b) +ccl_device_inline uint32_t min(uint32_t a, uint32_t b) +{ + return (a < b) ? a : b; +} + +ccl_device_inline uint64_t min(uint64_t a, uint64_t b) { return (a < b) ? a : b; } -- cgit v1.2.3 From 7313a84c5acb401817f1c44cfd8bf22428f34424 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 9 Feb 2022 15:50:03 +0100 Subject: Fix T95612: only overwrite existing attributes with matching domain and type Also fixes T95611 and T95610. Differential Revision: https://developer.blender.org/D14051 --- source/blender/modifiers/intern/MOD_nodes.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 7e65774b86e..c5ee4b9fb52 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -996,7 +996,11 @@ static void store_computed_output_attributes( { for (const OutputAttributeToStore &store : attributes_to_store) { GeometryComponent &component = geometry.get_component_for_write(store.component_type); - if (component.attribute_exists(store.name)) { + const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(store.data.type()); + const std::optional meta_data = component.attribute_get_meta_data( + store.name); + if (meta_data.has_value() && meta_data->domain == store.domain && + meta_data->data_type == data_type) { /* Copy the data into an existing attribute. */ blender::bke::WriteAttributeLookup write_attribute = component.attribute_try_get_for_write( store.name); @@ -1010,6 +1014,10 @@ static void store_computed_output_attributes( MEM_freeN(store.data.data()); } else { + /* Replace the existing attribute with the new data. */ + if (meta_data.has_value()) { + component.attribute_try_delete(store.name); + } component.attribute_try_create(store.name, store.domain, blender::bke::cpp_type_to_custom_data_type(store.data.type()), -- cgit v1.2.3 From 3e67831d3fc87629a45908ebb9fec575dadab1d6 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Wed, 9 Feb 2022 16:04:35 +0100 Subject: VSE: Fix sound strip not aligned with movie strip Strip aligning wasn't done when length of 2 strip is equal, but since these strips are aligned according to position in stream this can produce offset. --- source/blender/editors/space_sequencer/sequencer_add.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index aef6b30986d..439a37631e0 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -632,7 +632,7 @@ static void sequencer_add_movie_clamp_sound_strip_length(Scene *scene, Sequence *seq_movie, Sequence *seq_sound) { - if (ELEM(NULL, seq_movie, seq_sound) || seq_sound->len <= seq_movie->len) { + if (ELEM(NULL, seq_movie, seq_sound)) { return; } -- cgit v1.2.3 From c69ee218d786e6ae24804b00e7a7856c7638f7b0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 9 Feb 2022 16:15:56 +0100 Subject: Revert "Fix size_t -> int -> size_t round trip in Cycles" This reverts commit d74bb7be1916744ae56347b49333eac22ebb7339. Need to re-iterate to have a proper support of all platforms. --- intern/cycles/bvh/embree.cpp | 6 +++--- intern/cycles/scene/hair.cpp | 8 ++++---- intern/cycles/scene/mesh.cpp | 2 +- intern/cycles/scene/pointcloud.cpp | 2 +- intern/cycles/util/math.h | 7 +------ 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index 731fef52063..616b6273e6a 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -471,7 +471,7 @@ void BVHEmbree::add_instance(Object *ob, int i) assert(instance_bvh != NULL); const size_t num_object_motion_steps = ob->use_motion() ? ob->get_motion().size() : 1; - const size_t num_motion_steps = min(num_object_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); + const size_t num_motion_steps = min(num_object_motion_steps, RTC_MAX_TIME_STEP_COUNT); assert(num_object_motion_steps <= RTC_MAX_TIME_STEP_COUNT); RTCGeometry geom_id = rtcNewGeometry(rtc_device, RTC_GEOMETRY_TYPE_INSTANCE); @@ -522,7 +522,7 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); const size_t num_triangles = mesh->num_triangles(); @@ -775,7 +775,7 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); const size_t num_curves = hair->num_curves(); size_t num_segments = 0; diff --git a/intern/cycles/scene/hair.cpp b/intern/cycles/scene/hair.cpp index 0fd9c70cc26..2951a609ae9 100644 --- a/intern/cycles/scene/hair.cpp +++ b/intern/cycles/scene/hair.cpp @@ -119,7 +119,7 @@ void Hair::Curve::motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = std::min((size_t)(time * max_step), max_step - 1); + const size_t step = min((int)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[2]; @@ -147,7 +147,7 @@ void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((size_t)(time * max_step), max_step - 1); + const size_t step = min((int)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[4]; @@ -192,7 +192,7 @@ void Hair::Curve::keys_for_step(const float3 *curve_keys, float4 r_keys[2]) const { k0 = max(k0, 0); - k1 = min(k1, (size_t)(num_keys - 1)); + k1 = min(k1, num_keys - 1); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ @@ -238,7 +238,7 @@ void Hair::Curve::cardinal_keys_for_step(const float3 *curve_keys, float4 r_keys[4]) const { k0 = max(k0, 0); - k3 = min(k3, (size_t)(num_keys - 1)); + k3 = min(k3, num_keys - 1); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp index f53dca88ee0..c381d7a54ff 100644 --- a/intern/cycles/scene/mesh.cpp +++ b/intern/cycles/scene/mesh.cpp @@ -53,7 +53,7 @@ void Mesh::Triangle::motion_verts(const float3 *verts, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((size_t)(time * max_step), max_step - 1); + const size_t step = min((int)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float3 curr_verts[3]; diff --git a/intern/cycles/scene/pointcloud.cpp b/intern/cycles/scene/pointcloud.cpp index 6356a5030f3..4f88fe9db3d 100644 --- a/intern/cycles/scene/pointcloud.cpp +++ b/intern/cycles/scene/pointcloud.cpp @@ -55,7 +55,7 @@ float4 PointCloud::Point::motion_key(const float3 *points, /* Figure out which steps we need to fetch and their * interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((size_t)(time * max_step), max_step - 1); + const size_t step = min((int)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ const float4 curr_key = point_for_step( diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h index a580a21c28b..605a19aaef0 100644 --- a/intern/cycles/util/math.h +++ b/intern/cycles/util/math.h @@ -124,12 +124,7 @@ ccl_device_inline int min(int a, int b) return (a < b) ? a : b; } -ccl_device_inline uint32_t min(uint32_t a, uint32_t b) -{ - return (a < b) ? a : b; -} - -ccl_device_inline uint64_t min(uint64_t a, uint64_t b) +ccl_device_inline uint min(uint a, uint b) { return (a < b) ? a : b; } -- cgit v1.2.3 From d1202bd641ca2652fac9620bc06dad757584b1e0 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 9 Feb 2022 11:06:10 -0600 Subject: Fix T95620: Crash When Entering Edit Mode on a Curve Under some circumstances, simply adding a curve object and going to edit mode would cause a crash. This is because the evaluated `CurveEval` was accessed but also freed by the dependency graph. The fix reverts the part of b76918717dbfd8363f that uses the `CurveEval` for the curve object bounds. While this isn't ideal, it was the previous behavior, and some unexpected behavior with object bounds is much better than a crash. Plus, given the plans of using the new "Curves" data-block for evaluated curves, this situation will change relatively soon anyway. --- source/blender/blenkernel/intern/curve.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index f83a672b2ee..c611e280793 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -5072,16 +5072,6 @@ void BKE_curve_nurb_vert_active_validate(Curve *cu) bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3]) { - if (cu->curve_eval != nullptr) { - float3 eval_min(FLT_MAX); - float3 eval_max(-FLT_MAX); - if (cu->curve_eval->bounds_min_max(eval_min, eval_max, false)) { - copy_v3_v3(min, eval_min); - copy_v3_v3(max, eval_max); - return true; - } - } - ListBase *nurb_lb = BKE_curve_nurbs_get(cu); ListBase temp_nurb_lb = {nullptr, nullptr}; const bool is_font = (BLI_listbase_is_empty(nurb_lb)) && (cu->len != 0); -- cgit v1.2.3 From 7b0174ef819fbe8020c8766457a2e971b1593f8e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2022 09:02:29 +1100 Subject: Cleanup: remove overly detailed contact info, correct md5 copyright Also remove copyright text with no assignment. --- intern/ghost/intern/GHOST_DisplayManagerCocoa.mm | 5 ++--- source/blender/blenlib/intern/hash_md5.c | 2 +- source/blender/freestyle/intern/geometry/matrix_util.cpp | 9 +-------- source/blender/freestyle/intern/geometry/matrix_util.h | 9 +-------- source/blender/freestyle/intern/geometry/normal_cycle.cpp | 9 +-------- source/blender/freestyle/intern/geometry/normal_cycle.h | 9 +-------- source/blender/freestyle/intern/winged_edge/Curvature.cpp | 8 +------- source/blender/freestyle/intern/winged_edge/Curvature.h | 10 ++-------- source/blender/imbuf/intern/radiance_hdr.c | 7 ------- 9 files changed, 10 insertions(+), 58 deletions(-) diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm index 96898a15f62..35ea4c12818 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm @@ -13,9 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - Damien Plisson 10/2009 + * Copyright 2001-2002 NaN Holding BV. All rights reserved. + * 2009 Damien Plisson */ #include diff --git a/source/blender/blenlib/intern/hash_md5.c b/source/blender/blenlib/intern/hash_md5.c index 6a0ca8bb33f..a2cc1a0fc12 100644 --- a/source/blender/blenlib/intern/hash_md5.c +++ b/source/blender/blenlib/intern/hash_md5.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * Copyright (C) 1995 Software Foundation, Inc. + * Copyright (C) 1995 Free Software Foundation, Inc. * * Written by Ulrich Drepper . */ diff --git a/source/blender/freestyle/intern/geometry/matrix_util.cpp b/source/blender/freestyle/intern/geometry/matrix_util.cpp index 95a24d85677..c917e9c87fd 100644 --- a/source/blender/freestyle/intern/geometry/matrix_util.cpp +++ b/source/blender/freestyle/intern/geometry/matrix_util.cpp @@ -15,14 +15,7 @@ * * The Original Code is: * GXML/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy */ /** \file diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h index 8c2eb799d13..147e25e9608 100644 --- a/source/blender/freestyle/intern/geometry/matrix_util.h +++ b/source/blender/freestyle/intern/geometry/matrix_util.h @@ -15,14 +15,7 @@ * * The Original Code is: * GXML/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy */ #pragma once diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.cpp b/source/blender/freestyle/intern/geometry/normal_cycle.cpp index 77a80e63b77..fbcbeb220df 100644 --- a/source/blender/freestyle/intern/geometry/normal_cycle.cpp +++ b/source/blender/freestyle/intern/geometry/normal_cycle.cpp @@ -15,14 +15,7 @@ * * The Original Code is: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy */ /** \file diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.h b/source/blender/freestyle/intern/geometry/normal_cycle.h index 949675e9d8d..1fb59bcad19 100644 --- a/source/blender/freestyle/intern/geometry/normal_cycle.h +++ b/source/blender/freestyle/intern/geometry/normal_cycle.h @@ -15,14 +15,7 @@ * * The Original Code is: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000 Bruno Levy - * Contact: Bruno Levy - * - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000 Bruno Levy */ #pragma once diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp index ec07a124808..571f21ac309 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp +++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp @@ -18,13 +18,7 @@ * Copyright (C) 1999 Stephane Popinet * and: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000-2003 Bruno Levy - * Contact: Bruno Levy - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright 2000-2003 Bruno Levy */ /** \file diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.h b/source/blender/freestyle/intern/winged_edge/Curvature.h index acbe4e8daf6..c87134a0c14 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.h +++ b/source/blender/freestyle/intern/winged_edge/Curvature.h @@ -15,16 +15,10 @@ * * The Original Code is: * GTS - Library for the manipulation of triangulated surfaces - * Copyright (C) 1999 Stephane Popinet + * Copyright 1999 Stephane Popinet * and: * OGF/Graphite: Geometry and Graphics Programming Library + Utilities - * Copyright (C) 2000-2003 Bruno Levy - * Contact: Bruno Levy - * ISA Project - * LORIA, INRIA Lorraine, - * Campus Scientifique, BP 239 - * 54506 VANDOEUVRE LES NANCY CEDEX - * FRANCE + * Copyright (C) 2000-2003 Bruno Levy */ #pragma once diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 925ef0a8502..616f4d1421c 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -12,21 +12,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright - * All rights reserved. */ /** \file * \ingroup imbuf - */ - -/* ---------------------------------------------------------------------- * Radiance High Dynamic Range image file IO * For description and code for reading/writing of radiance hdr files * by Greg Ward, refer to: * http://radsite.lbl.gov/radiance/refer/Notes/picture_format.html - * ---------------------------------------------------------------------- */ #include "MEM_guardedalloc.h" -- cgit v1.2.3 From 58761eb11a681abbde1809a01ab8dde75aa8f46e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2022 09:20:34 +1100 Subject: GNUmakefile: move editor settings to .editorconfig Remove inline vim/emacs editor configuration, add makefile to editorconfig instead. --- .editorconfig | 9 +++++++++ GNUmakefile | 3 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 691643adebe..41ec3a1dc3d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -42,3 +42,12 @@ insert_final_newline = true indent_style = space indent_size = 3 max_line_length = 120 + +# Makefile +[{Makefile,GNUmakefile}] +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = tab +indent_size = 4 +max_line_length = 120 \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index e4703973384..feca1236e72 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,3 @@ -# -*- mode: gnumakefile; tab-width: 4; indent-tabs-mode: t; -*- -# vim: tabstop=4 -# # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or -- cgit v1.2.3 From fe80ff446f9736eccd685e8a2c40b4143a88b999 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2022 09:56:54 +1100 Subject: Cleanup: copyright in headers, spelling in comments - Order year consistently. - Minor consistency (case, double-spacing). - Correct typos. --- source/blender/blenkernel/intern/lib_override.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 2 +- source/blender/blenlib/BLI_fnmatch.h | 5 ++--- source/blender/blenlib/intern/string_utils.c | 2 +- source/blender/editors/animation/anim_intern.h | 2 +- source/blender/editors/gpencil/annotate_paint.c | 2 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- source/blender/editors/space_api/spacetypes.c | 2 +- source/blender/editors/space_file/fsmenu.c | 2 +- source/blender/imbuf/intern/cineon/cineonlib.c | 2 +- source/blender/imbuf/intern/cineon/cineonlib.h | 2 +- source/blender/imbuf/intern/cineon/logImageCore.c | 2 +- source/blender/imbuf/intern/cineon/logImageCore.h | 2 +- source/blender/io/usd/intern/usd_reader_mesh.cc | 6 ++---- source/blender/io/usd/intern/usd_reader_mesh.h | 2 +- source/blender/sequencer/intern/image_cache.c | 2 +- source/blender/windowmanager/intern/wm_window.c | 4 ++-- 17 files changed, 20 insertions(+), 23 deletions(-) diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 7158b71d7f1..fd8b4721500 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -1133,7 +1133,7 @@ static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID return; } - /* Hierarchy root already set, and not matching currently propsed one, try to find which is + /* Hierarchy root already set, and not matching currently proposed one, try to find which is * best. */ if (id->override_library->hierarchy_root != NULL) { /* Check if given `id_from` matches with the hierarchy of the linked reference ID, in which diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 93c8c550663..138c75acd7b 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -18,7 +18,7 @@ */ /** \file - * Functions for writing avi-format files. + * Functions for writing AVI-format files. * Added interface for generic movie support (ton) * \ingroup bke */ diff --git a/source/blender/blenlib/BLI_fnmatch.h b/source/blender/blenlib/BLI_fnmatch.h index 1df5b6f814a..d3a5d5fb53e 100644 --- a/source/blender/blenlib/BLI_fnmatch.h +++ b/source/blender/blenlib/BLI_fnmatch.h @@ -14,15 +14,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. - * - * NOTE: The canonical source of this file is maintained with the GNU C Library. - * Bugs can be reported to . */ #pragma once /** \file * \ingroup bli + * \note The canonical source of this file is maintained with the GNU C Library. + * Bugs can be reported to . */ #ifdef __cplusplus diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c index 21162904dbd..d785d3d17f8 100644 --- a/source/blender/blenlib/intern/string_utils.c +++ b/source/blender/blenlib/intern/string_utils.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2017 by the Blender FOundation. + * The Original Code is Copyright (C) 2017 by the Blender Foundation. * All rights reserved. */ diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index fb7b6b8983a..9029c451290 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung + * The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung. * This is a new part of Blender (with some old code) */ diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index e75e9314659..042fe5d3806 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2008/2018, Blender Foundation + * The Original Code is Copyright (C) 2008-2018, Blender Foundation * This is a new part of Blender */ diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 3e05b8d7a7f..35ad582d4ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) Blender Foundation, 2002-2009 + * The Original Code is Copyright (C) 2002-2009, Blender Foundation * All rights reserved. */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index f8adba30547..b786cada908 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) Blender Foundation, 2008 + * The Original Code is Copyright (C) 2008, Blender Foundation */ /** \file diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0a69d0f9b39..e95e3bef8a8 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -790,7 +790,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) } /* Get mounted volumes better method OSX 10.6 and higher, see: - * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html + * https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html */ /* We get all volumes sorted including network and do not relay diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index 758b21f8cda..aa10d8949fe 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson + * Copyright 1999-2001 David Hodson */ /** \file diff --git a/source/blender/imbuf/intern/cineon/cineonlib.h b/source/blender/imbuf/intern/cineon/cineonlib.h index d1225027b4c..d71b6da9bc6 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.h +++ b/source/blender/imbuf/intern/cineon/cineonlib.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson + * Copyright 1999-2001 David Hodson */ /** \file diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c index 73bcb8d7ebc..2852e8c6f73 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson + * Copyright 1999-2001 David Hodson */ /** \file diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h index c2704a086b6..3e98780016e 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.h +++ b/source/blender/imbuf/intern/cineon/logImageCore.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright 1999,2000,2001 David Hodson + * Copyright 1999-2001 David Hodson */ /** \file diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 95b73c85da6..10de47da0e3 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -14,10 +14,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Adapted from the Blender Alembic importer implementation. - * - * Modifications Copyright (C) 2021 Tangent Animation and - * NVIDIA Corporation. All rights reserved. - */ + * Modifications Copyright 2021 Tangent Animation and + * NVIDIA Corporation. All rights reserved. */ #include "usd_reader_mesh.h" #include "usd_reader_material.h" diff --git a/source/blender/io/usd/intern/usd_reader_mesh.h b/source/blender/io/usd/intern/usd_reader_mesh.h index c5869fcbd32..0a1ab9a5fbe 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.h +++ b/source/blender/io/usd/intern/usd_reader_mesh.h @@ -16,7 +16,7 @@ * Adapted from the Blender Alembic importer implementation. * * Modifications Copyright (C) 2021 Tangent Animation and - * NVIDIA Corporation. All rights reserved. + * NVIDIA Corporation. All rights reserved. */ #pragma once diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 51e4613f088..3caf965a608 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Peter Schlaile 2010 + * Copyright 2010 Peter Schlaile */ /** \file diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 1d9535e5102..7e4acf709b7 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -13,8 +13,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2007 Blender Foundation but based - * on ghostwinlay.c (C) 2001-2002 by NaN Holding BV. All rights reserved. + * Copyright 2001-2002 by NaN Holding BV. All rights reserved. + * 2007 Blender Foundation */ /** \file -- cgit v1.2.3 From 2887df119c3b4e30d77d63cc4bffb28070dec850 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 9 Feb 2022 17:56:19 -0600 Subject: Fix: Complete curves renaming missed in previous commit This made cycles not render curves. Missed in fe1816f67fbc6aaf383ec7 --- intern/cycles/blender/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt index fe7d0b89bb0..1c6016261f0 100644 --- a/intern/cycles/blender/CMakeLists.txt +++ b/intern/cycles/blender/CMakeLists.txt @@ -140,7 +140,7 @@ if(WITH_OPENIMAGEDENOISE) endif() if(WITH_EXPERIMENTAL_FEATURES) - add_definitions(-DWITH_HAIR_NODES) + add_definitions(-DWITH_NEW_CURVES_TYPE) endif() blender_add_lib(bf_intern_cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") -- cgit v1.2.3 From c824c06f3881bbaf11eb0d89b5c6df56dad2cecf Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 9 Feb 2022 23:07:48 -0600 Subject: Cleanup: Clang tidy, unused variabel warnings --- source/blender/blenkernel/BKE_object.h | 2 +- source/blender/blenkernel/intern/object_update.c | 1 - source/blender/draw/engines/overlay/overlay_armature.c | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 96ed7942067..e8ff0903b04 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -432,7 +432,7 @@ void BKE_object_eval_constraints(struct Depsgraph *depsgraph, struct Object *ob); void BKE_object_eval_transform_final(struct Depsgraph *depsgraph, struct Object *ob); -void BKE_object_eval_uber_transform(struct Depsgraph *depsgraph, struct Object *ob); +void BKE_object_eval_uber_transform(struct Depsgraph *depsgraph, struct Object *object); void BKE_object_eval_uber_data(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 12ae57af2c3..6352fd19239 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -304,7 +304,6 @@ void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object) void BKE_object_eval_uber_transform(Depsgraph *UNUSED(depsgraph), Object *UNUSED(object)) { - return; } void BKE_object_data_batch_cache_dirty_tag(ID *object_data) diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index 5abebe2f32b..f9694b329aa 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -2117,6 +2117,7 @@ static bool pchan_culling_test_envelope(const DRWView *view, { const bArmature *arm = ob->data; BLI_assert(arm->drawtype == ARM_ENVELOPE); + UNUSED_VARS_NDEBUG(arm); BoundSphere bsphere; pchan_culling_calc_bsphere(ob, pchan, &bsphere); bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * @@ -2130,6 +2131,7 @@ static bool pchan_culling_test_bbone(const DRWView *view, { const bArmature *arm = ob->data; BLI_assert(arm->drawtype == ARM_B_BONE); + UNUSED_VARS_NDEBUG(arm); const float ob_scale = mat4_to_size_max_axis(ob->obmat); const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; for (int i = pchan->bone->segments; i--; bbones_mat++) { -- cgit v1.2.3 From e6ad11f06dd7875c66b1c0a2bfabd2cd3eb1d8c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2022 16:45:16 +1100 Subject: Cleanup: quiet warnings including RE_pipeline.h directly --- source/blender/render/RE_pipeline.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/render/RE_pipeline.h b/source/blender/render/RE_pipeline.h index c1392b24023..6374b70ae1f 100644 --- a/source/blender/render/RE_pipeline.h +++ b/source/blender/render/RE_pipeline.h @@ -31,6 +31,7 @@ struct Image; struct ImageFormatData; struct Main; struct Object; +struct ImBuf; struct RenderData; struct RenderResult; struct ReportList; @@ -209,7 +210,7 @@ void RE_FreeAllPersistentData(void); /** * Free persistent render data, optionally only for the given scene. */ -void RE_FreePersistentData(const Scene *scene); +void RE_FreePersistentData(const struct Scene *scene); /** * Get results and statistics. -- cgit v1.2.3 From 507a4deef1492b1f44af89783e64401727be6f33 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Feb 2022 10:42:25 +0100 Subject: Fix invalid creation of partial image updater --- source/blender/draw/engines/image/image_partial_updater.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/draw/engines/image/image_partial_updater.hh b/source/blender/draw/engines/image/image_partial_updater.hh index f0c1db2331a..e74c31e9e8a 100644 --- a/source/blender/draw/engines/image/image_partial_updater.hh +++ b/source/blender/draw/engines/image/image_partial_updater.hh @@ -32,11 +32,11 @@ struct PartialImageUpdater { /** * \brief Ensure that there is a partial update user for the given image. */ - void ensure_image(const Image *image) + void ensure_image(const Image *new_image) { - if (!is_valid(image)) { + if (!is_valid(new_image)) { free(); - create(image); + create(new_image); } } @@ -60,11 +60,11 @@ struct PartialImageUpdater { return user != nullptr; } - void create(const Image *image) + void create(const Image *new_image) { BLI_assert(user == nullptr); - user = BKE_image_partial_update_create(image); - image = image; + user = BKE_image_partial_update_create(new_image); + image = new_image; } void free() -- cgit v1.2.3 From 5312cf50a1f71f9baa63d516f1e5eef728339efb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Feb 2022 10:46:06 +0100 Subject: Fix strict warning initializing texture result in compositor From a strict language point of view the code required a braces around `trgba` initialization. But it is easier to rely on the fact that fields which are not specified are zero-initialized. --- source/blender/compositor/operations/COM_TextureOperation.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/compositor/operations/COM_TextureOperation.cc b/source/blender/compositor/operations/COM_TextureOperation.cc index 069d00b5e66..f0e661818f8 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cc +++ b/source/blender/compositor/operations/COM_TextureOperation.cc @@ -102,7 +102,7 @@ void TextureBaseOperation::execute_pixel_sampled(float output[4], float y, PixelSampler sampler) { - TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, nullptr}; + TexResult texres = {0.0f}; float texture_size[4]; float texture_offset[4]; float vec[3]; -- cgit v1.2.3 From 9e9355190c0c7ae61a752602274637f91c4d8bf3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Feb 2022 10:55:50 +0100 Subject: Fix compilation with strict Clang flags There is no `-Wformat-truncation` warning in Clang, so tweak checks around diagnostics pragma accordingly. --- source/blender/io/wavefront_obj/exporter/obj_export_io.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh index 7d8427a8980..7e5fe1ca526 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh @@ -129,7 +129,7 @@ constexpr bool is_type_string_related = (... && std::is_constructible_v Date: Thu, 10 Feb 2022 11:01:47 +0100 Subject: Fix T84486: NLA, disable "Sync Length" after split Turn off "Sync Length" when splitting an NLA strip. The NLA Strip-Action Clip has a setting called "Sync Length" that is on by default and helps to update the length of the clip to the current actions keyframes so the strip shows the entire actions stored animation. When you split one of these strip-action clips in the NLA to trim it shorter or to move it somewhere else in the NLA tracks to blend or work with, the "Sync Length" setting stays checked on. You can have many strips in the NLA that all look to the same action, if you split one strip , you now have two strips showing or linked to the same action. To see or edit keyframes on a strip, you enter tweak mode. When you exit tweak mode, if "Sync Length" is active on the strip-action clip settings, the strip length is changed/reset to match the action keys. When you have many clips, this causes all of them to evaluate and update no matter where they are in the NLA. This destroys/undoes all the user work to trim down and place the clips in the NLA. **Description of the proposed solution:** This patch/change would turn off, the "Sync Length" setting when the split tool was used on a strip/action clip to help protect the users choice to trim and keep the clip that length. It doesn't change the ability to turn the setting back on or off, it just makes sure that the user doesn't accidentally or unknowingly loose work. The same process happens when an action is created that has a "manual range" set that is different than the length of the actions start-end keyframes. It makes sense to do the same thing for the split tool. **Alternative solutions:** While the user could know this and turn off this setting by hand, it is easy to forget and or the user might think that it only happened to the one clip they were editing and not realize it happened to all the trimmed versions, changing the users choice without the user knowing it happened. **Limitations of the proposed solution:** It only fixes the split tool, if another tool was created and some how impacted the clip length we would need to have that tool also take the sync length into account. Reviewed By: sybren Maniphest Tasks: T84486 Differential Revision: https://developer.blender.org/D10168 --- source/blender/editors/space_nla/nla_edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 1376dade659..28041c0389f 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1397,8 +1397,11 @@ static void nlaedit_split_strip_actclip( nstrip->actstart = splitaframe; } - /* clear the active flag from the copy */ - nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE; + /* Make sure Sync Length is off. With that setting on, entering and exiting tweak mode would + * effectively undo the split, because both the old and the new strip will be at the length of + * the Action again. */ + strip->flag &= ~NLASTRIP_FLAG_SYNC_LENGTH; + nstrip->flag &= ~(NLASTRIP_FLAG_SYNC_LENGTH | NLASTRIP_FLAG_ACTIVE); /* auto-name the new strip */ BKE_nlastrip_validate_name(adt, nstrip); -- cgit v1.2.3 From 84f30ac3a2e8b3017ef7dda34643e573a1f476b7 Mon Sep 17 00:00:00 2001 From: Peter Kim Date: Thu, 10 Feb 2022 19:10:47 +0900 Subject: Deps: upgrade OpenXR 1.0.17 -> 1.0.22 Simple upgrade of OpenXR to 1.0.22, following the steps from https://wiki.blender.org/wiki/Source/OpenXR_SDK_Dependency and rBb69ab42982a1. No changes to Blender code were necessary, only a version bump. The primary motivation for this upgrade is to utilize the `XR_HTCX_vive_tracker_interaction` extension introduced in ver. 1.0.20. However, the latest release (1.0.22) also adds a number of potentially useful extensions such as: - `XR_FB_render_model` - `XR_HTC_facial_expression` - `XR_HTC_vive_focus3_controller_interaction` Ref T95206 Reviewed By: LazyDodo, sybren, mont29 Maniphest Tasks: T95206 Differential Revision: https://developer.blender.org/D13950 --- build_files/build_environment/cmake/versions.cmake | 4 ++-- build_files/build_environment/install_deps.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 28a27023818..8669acb6275 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -458,9 +458,9 @@ set(NASM_HASH aded8b796c996a486a56e0515c83e414116decc3b184d88043480b32eb0a8589) set(NASM_HASH_TYPE SHA256) set(NASM_FILE nasm-${NASM_VERSION}.tar.gz) -set(XR_OPENXR_SDK_VERSION 1.0.17) +set(XR_OPENXR_SDK_VERSION 1.0.22) set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz) -set(XR_OPENXR_SDK_HASH bf0fd8828837edff01047474e90013e1) +set(XR_OPENXR_SDK_HASH a2623ebab3d0b340bc16311b14f02075) set(XR_OPENXR_SDK_HASH_TYPE MD5) set(XR_OPENXR_SDK_FILE OpenXR-SDK-${XR_OPENXR_SDK_VERSION}.tar.gz) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 75c0b3c0009..27f8d586c13 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -579,7 +579,7 @@ FFMPEG_FORCE_REBUILD=false FFMPEG_SKIP=false _ffmpeg_list_sep=";" -XR_OPENXR_VERSION="1.0.17" +XR_OPENXR_VERSION="1.0.22" XR_OPENXR_VERSION_SHORT="1.0" XR_OPENXR_VERSION_MIN="1.0.8" XR_OPENXR_VERSION_MEX="2.0" @@ -1116,7 +1116,7 @@ FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" ) XR_OPENXR_USE_REPO=false XR_OPENXR_SOURCE=("https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_VERSION}.tar.gz") XR_OPENXR_SOURCE_REPO=("https://github.com/KhronosGroup/OpenXR-SDK.git") -XR_OPENXR_REPO_UID="bf21ccb1007bb531b45d9978919a56ea5059c245" +XR_OPENXR_REPO_UID="458984d7f59d1ae6dc1b597d94b02e4f7132eaba" XR_OPENXR_REPO_BRANCH="master" # C++11 is required now -- cgit v1.2.3 From e2befa425a84c9e4ec715442e85624a5d3669a4f Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 10 Feb 2022 11:34:12 +0100 Subject: GPencil: Update-on-write using update cache This implements the update cache described in T95401. The cache is currently only used for drawing strokes and sculpting (using the push brush). **Note: Making use of the cache throughout grease pencil will have to be done incrementally in other patches. ** The update cache stores what elements have changed in the original data-block since the last time the eval object was updated. Additionally, the update cache can store multiple updates to the data and minimizes the number of elements that need to be copied. Elements can be tagged using `BKE_gpencil_tag_full_update` and `BKE_gpencil_tag_light_update`. A full update means that the element itself will be copied but also all of the content inside. E.g. when a layer is tagged for a full update, the layer, all the frames inside the layer and all the strokes inside the frames will be copied. A light update means that only the properties of the element are copied without any of the content. E.g. if a layer is tagged with a light update, it will copy the layer name, opacity, transform, etc. When the update cache is in use (e.g. elements have been tagged) then the depsgraph will not trigger a copy-on-write, but an update-on-write. This means that the update cache will be used to determine what elements have changed and then only those elements will be copied over to the eval object. If the update cache is empty or the data block was tagged with a full update, we always fall back to a copy-on-write. Currently, the update cache is only used by the active depsgraph. This is because we need to free the update cache after an update-on-write so it's reset and we need to make sure it is not freed or read by other depsgraphs. Co-authored-by: @yann-lty This patch was contributed by The SPA Studios. Reviewed By: sergey, antoniov, #dependency_graph, pepeland, mendio Maniphest Tasks: T95401 Differential Revision: https://developer.blender.org/D13984 --- source/blender/blenkernel/BKE_gpencil.h | 34 +++ .../blender/blenkernel/BKE_gpencil_update_cache.h | 152 +++++++++++ source/blender/blenkernel/CMakeLists.txt | 2 + source/blender/blenkernel/intern/gpencil.c | 292 +++++++++++++++++++-- .../blenkernel/intern/gpencil_update_cache.c | 274 +++++++++++++++++++ source/blender/blenlib/BLI_dlrbTree.h | 8 +- source/blender/blenlib/BLI_listbase.h | 6 + source/blender/blenlib/intern/DLRB_tree.c | 28 +- source/blender/blenlib/intern/listbase.c | 15 ++ source/blender/blenlib/tests/BLI_listbase_test.cc | 8 + source/blender/depsgraph/CMakeLists.txt | 2 + .../intern/eval/deg_eval_copy_on_write.cc | 11 +- .../intern/eval/deg_eval_runtime_backup.cc | 7 +- .../intern/eval/deg_eval_runtime_backup.h | 2 + .../intern/eval/deg_eval_runtime_backup_gpencil.cc | 59 +++++ .../intern/eval/deg_eval_runtime_backup_gpencil.h | 45 ++++ source/blender/editors/gpencil/gpencil_paint.c | 13 +- .../blender/editors/gpencil/gpencil_sculpt_paint.c | 17 +- source/blender/makesdna/DNA_gpencil_types.h | 11 + source/blender/makesrna/intern/rna_gpencil.c | 7 + 20 files changed, 961 insertions(+), 32 deletions(-) create mode 100644 source/blender/blenkernel/BKE_gpencil_update_cache.h create mode 100644 source/blender/blenkernel/intern/gpencil_update_cache.c create mode 100644 source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc create mode 100644 source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 885d0c2fd90..fd8996993c0 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -48,6 +48,7 @@ struct bGPDlayer; struct bGPDlayer_Mask; struct bGPDstroke; struct bGPdata; +struct GPencilUpdateCache; #define GPENCIL_SIMPLIFY(scene) (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_ENABLE) #define GPENCIL_SIMPLIFY_ONPLAY(playing) \ @@ -175,10 +176,28 @@ struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src, b struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src, bool dup_frames, bool dup_strokes); + +/** + * Make a copy of a given gpencil data settings. + */ +void BKE_gpencil_data_copy_settings(const struct bGPdata *gpd_src, struct bGPdata *gpd_dst); + /** * Make a copy of a given gpencil layer settings. */ void BKE_gpencil_layer_copy_settings(const struct bGPDlayer *gpl_src, struct bGPDlayer *gpl_dst); + +/** + * Make a copy of a given gpencil frame settings. + */ +void BKE_gpencil_frame_copy_settings(const struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst); + +/** + * Make a copy of a given gpencil stroke settings. + */ +void BKE_gpencil_stroke_copy_settings(const struct bGPDstroke *gpf_src, + struct bGPDstroke *gpf_dst); + /** * Make a copy of strokes between gpencil frames. * \param gpf_src: Source grease pencil frame @@ -675,6 +694,9 @@ extern void (*BKE_gpencil_batch_cache_free_cb)(struct bGPdata *gpd); */ void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig, const struct bGPDframe *gpf_eval); + +void BKE_gpencil_layer_original_pointers_update(const struct bGPDlayer *gpl_orig, + const struct bGPDlayer *gpl_eval); /** * Update pointers of eval data to original data to keep references. * \param ob_orig: Original grease pencil object @@ -682,6 +704,14 @@ void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig */ void BKE_gpencil_update_orig_pointers(const struct Object *ob_orig, const struct Object *ob_eval); +/** + * Update pointers of eval data to original data to keep references. + * \param gpd_orig: Original grease pencil data + * \param gpd_eval: Evaluated grease pencil data + */ +void BKE_gpencil_data_update_orig_pointers(const struct bGPdata *gpd_orig, + const struct bGPdata *gpd_eval); + /** * Get parent matrix, including layer parenting. * \param depsgraph: Depsgraph @@ -711,6 +741,10 @@ int BKE_gpencil_material_find_index_by_name_prefix(struct Object *ob, const char void BKE_gpencil_blend_read_data(struct BlendDataReader *reader, struct bGPdata *gpd); +bool BKE_gpencil_can_avoid_full_copy_on_write(const struct Depsgraph *depsgraph, struct bGPdata *gpd); + +void BKE_gpencil_update_on_write(struct bGPdata *gpd_orig, struct bGPdata *gpd_eval); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_gpencil_update_cache.h b/source/blender/blenkernel/BKE_gpencil_update_cache.h new file mode 100644 index 00000000000..3ac78267922 --- /dev/null +++ b/source/blender/blenkernel/BKE_gpencil_update_cache.h @@ -0,0 +1,152 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022, Blender Foundation + * This is a new part of Blender + */ + +#pragma once + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "BLI_sys_types.h" /* for bool */ + +struct DLRBT_Tree; +struct bGPdata; +struct bGPDlayer; +struct bGPDframe; +struct bGPDstroke; +struct GPencilUpdateCache; + +/* GPencilUpdateCache.flag */ +typedef enum eGPUpdateCacheNodeFlag { + /* Node is a placeholder (e.g. when only an index is needed). */ + GP_UPDATE_NODE_NO_COPY = 0, + /* Copy only element, not the content. */ + GP_UPDATE_NODE_LIGHT_COPY = 1, + /* Copy the element as well as all of its content. */ + GP_UPDATE_NODE_FULL_COPY = 2, +} eGPUpdateCacheNodeFlag; + +/** + * Cache for what needs to be updated after bGPdata was modified. + * + * Every node holds information about one element that was changed: + * - the index of where that element is in the linked-list + * - the pointer to the original element in bGPdata + * Additionally, nodes also hold other nodes that are one "level" below them. + * E.g. a node that represents a change on a bGPDframe could contain a set of + * nodes that represent a change on bGPDstrokes. + * These nodes are stored in a red-black tree so that they are sorted by their + * index to make sure they can be processed in the correct order. + */ +typedef struct GPencilUpdateCache { + /* Mapping from index to a GPencilUpdateCache struct. */ + struct DLRBT_Tree *children; + /* eGPUpdateCacheNodeFlag */ + int flag; + /* Index of the element in the linked-list. */ + int index; + /* Pointer to one of bGPdata, bGPDLayer, bGPDFrame, bGPDStroke. */ + void *data; +} GPencilUpdateCache; + +/* Node structure in the DLRBT_Tree for GPencilUpdateCache mapping. */ +typedef struct GPencilUpdateCacheNode { + /* DLRB tree capabilities. */ + struct GPencilUpdateCacheNode *next, *prev; + struct GPencilUpdateCacheNode *left, *right; + struct GPencilUpdateCacheNode *parent; + char tree_col; + + char _pad[7]; + /* Content of DLRB tree node. */ + GPencilUpdateCache *cache; +} GPencilUpdateCacheNode; + +/** + * Callback that is called in BKE_gpencil_traverse_update_cache at each level. If the callback + * returns true, then the children will not be iterated over and instead continue. + * \param cache: The cache at this level. + * \param user_data: Pointer to the user_data passed to BKE_gpencil_traverse_update_cache. + * \returns true, if iterating over the children of \a cache should be skipped, false if not. + */ +typedef bool (*GPencilUpdateCacheIter_Cb)(GPencilUpdateCache *cache, void *user_data); + +typedef struct GPencilUpdateCacheTraverseSettings { + /* Callbacks for the update cache traversal. Callback with index 0 is for layers, 1 for frames + * and 2 for strokes. */ + GPencilUpdateCacheIter_Cb update_cache_cb[3]; +} GPencilUpdateCacheTraverseSettings; + +/** + * Allocates a new GPencilUpdateCache and populates it. + * \param data: A data pointer to populate the initial cache with. + * \param full_copy: If true, will mark this update cache as a full copy + * (GP_UPDATE_NODE_FULL_COPY). If false, it will be marked as a struct copy + * (GP_UPDATE_NODE_LIGHT_COPY). + */ +GPencilUpdateCache *BKE_gpencil_create_update_cache(void *data, bool full_copy); + +/** + * Traverses an update cache and executes callbacks at each level. + * \param cache: The update cache to traverse. + * \param ts: The traversal settings. This stores the callbacks that are called at each level. + * \param user_data: Custom data passed to each callback. + */ +void BKE_gpencil_traverse_update_cache(GPencilUpdateCache *cache, + GPencilUpdateCacheTraverseSettings *ts, + void *user_data); + +/** + * Tags an element (bGPdata, bGPDlayer, bGPDframe, or bGPDstroke) and all of its containing data to + * be updated in the next update-on-write operation. + * + * The function assumes that when a parameter is NULL all of the following parameters are NULL too. + * E.g. in order to tag a layer (gpl), the parameters would *have* to be (gpd, gpl, NULL, NULL). + */ +void BKE_gpencil_tag_full_update(struct bGPdata *gpd, + struct bGPDlayer *gpl, + struct bGPDframe *gpf, + struct bGPDstroke *gps); + +/** + * Tags an element (bGPdata, bGPDlayer, bGPDframe, or bGPDstroke) to be updated in the next + * update-on-write operation. This function will not update any of the containing data, only the + * struct itself. + * + * The function assumes that when a parameter is NULL all of the following parameters are NULL too. + * E.g. in order to tag a layer (gpl), the parameters would *have* to be (gpd, gpl, NULL, NULL). + */ +void BKE_gpencil_tag_light_update(struct bGPdata *gpd, + struct bGPDlayer *gpl, + struct bGPDframe *gpf, + struct bGPDstroke *gps); + +/** + * Frees the GPencilUpdateCache on the gpd->runtime. This will not free the data that the cache + * node might point to. It assumes that the cache does not own the data. + */ +void BKE_gpencil_free_update_cache(struct bGPdata *gpd); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index efc9cd6e99f..1483466061f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -157,6 +157,7 @@ set(SRC intern/gpencil_curve.c intern/gpencil_geom.cc intern/gpencil_modifier.c + intern/gpencil_update_cache.c intern/icons.cc intern/icons_rasterize.c intern/idprop.c @@ -385,6 +386,7 @@ set(SRC BKE_gpencil_curve.h BKE_gpencil_geom.h BKE_gpencil_modifier.h + BKE_gpencil_update_cache.h BKE_icons.h BKE_idprop.h BKE_idprop.hh diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 13338f33bd6..6e39125b252 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -55,6 +55,7 @@ #include "BKE_deform.h" #include "BKE_gpencil.h" #include "BKE_gpencil_geom.h" +#include "BKE_gpencil_update_cache.h" #include "BKE_icons.h" #include "BKE_idtype.h" #include "BKE_image.h" @@ -158,6 +159,7 @@ static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id gpd->runtime.sbuffer_used = 0; gpd->runtime.sbuffer_size = 0; gpd->runtime.tot_cp_points = 0; + gpd->runtime.update_cache = NULL; /* write gpd data block to file */ BLO_write_id_struct(writer, bGPdata, id_address, &gpd->id); @@ -221,6 +223,7 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd) gpd->runtime.sbuffer_used = 0; gpd->runtime.sbuffer_size = 0; gpd->runtime.tot_cp_points = 0; + gpd->runtime.update_cache = NULL; /* Relink palettes (old palettes deprecated, only to convert old files). */ BLO_read_list(reader, &gpd->palettes); @@ -501,6 +504,8 @@ void BKE_gpencil_free_data(bGPdata *gpd, bool free_all) BLI_freelistN(&gpd->vertex_group_names); + BKE_gpencil_free_update_cache(gpd); + /* free all data */ if (free_all) { /* clear cache */ @@ -985,6 +990,43 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src, return gpl_dst; } +void BKE_gpencil_data_copy_settings(const bGPdata *gpd_src, bGPdata *gpd_dst) +{ + gpd_dst->flag = gpd_src->flag; + gpd_dst->curve_edit_resolution = gpd_src->curve_edit_resolution; + gpd_dst->curve_edit_threshold = gpd_src->curve_edit_threshold; + gpd_dst->curve_edit_corner_angle = gpd_src->curve_edit_corner_angle; + gpd_dst->pixfactor = gpd_src->pixfactor; + copy_v4_v4(gpd_dst->line_color, gpd_src->line_color); + + gpd_dst->onion_factor = gpd_src->onion_factor; + gpd_dst->onion_mode = gpd_src->onion_mode; + gpd_dst->onion_flag = gpd_src->onion_flag; + gpd_dst->gstep = gpd_src->gstep; + gpd_dst->gstep_next = gpd_src->gstep_next; + + copy_v3_v3(gpd_dst->gcolor_prev, gpd_src->gcolor_prev); + copy_v3_v3(gpd_dst->gcolor_next, gpd_src->gcolor_next); + + gpd_dst->zdepth_offset = gpd_src->zdepth_offset; + + gpd_dst->totlayer = gpd_src->totlayer; + gpd_dst->totframe = gpd_src->totframe; + gpd_dst->totstroke = gpd_src->totstroke; + gpd_dst->totpoint = gpd_src->totpoint; + + gpd_dst->draw_mode = gpd_src->draw_mode; + gpd_dst->onion_keytype = gpd_src->onion_keytype; + + gpd_dst->select_last_index = gpd_src->select_last_index; + gpd_dst->vertex_group_active_index = gpd_src->vertex_group_active_index; + + copy_v3_v3(gpd_dst->grid.color, gpd_src->grid.color); + copy_v2_v2(gpd_dst->grid.scale, gpd_src->grid.scale); + copy_v2_v2(gpd_dst->grid.offset, gpd_src->grid.offset); + gpd_dst->grid.lines = gpd_src->grid.lines; +} + void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_dst) { gpl_dst->line_change = gpl_src->line_change; @@ -1004,6 +1046,33 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds copy_m4_m4(gpl_dst->layer_invmat, gpl_src->layer_invmat); gpl_dst->blend_mode = gpl_src->blend_mode; gpl_dst->flag = gpl_src->flag; + gpl_dst->onion_flag = gpl_src->onion_flag; +} + +void BKE_gpencil_frame_copy_settings(const bGPDframe *gpf_src, bGPDframe *gpf_dst) +{ + gpf_dst->flag = gpf_src->flag; + gpf_dst->key_type = gpf_src->key_type; + gpf_dst->framenum = gpf_src->framenum; +} + +void BKE_gpencil_stroke_copy_settings(const bGPDstroke *gps_src, bGPDstroke *gps_dst) +{ + gps_dst->thickness = gps_src->thickness; + gps_dst->flag = gps_src->flag; + gps_dst->inittime = gps_src->inittime; + gps_dst->mat_nr = gps_src->mat_nr; + copy_v2_v2_short(gps_dst->caps, gps_src->caps); + gps_dst->hardeness = gps_src->hardeness; + copy_v2_v2(gps_dst->aspect_ratio, gps_src->aspect_ratio); + gps_dst->fill_opacity_fac = gps_dst->fill_opacity_fac; + copy_v3_v3(gps_dst->boundbox_min, gps_src->boundbox_min); + copy_v3_v3(gps_dst->boundbox_max, gps_src->boundbox_max); + gps_dst->uv_rotation = gps_src->uv_rotation; + copy_v2_v2(gps_dst->uv_translation, gps_src->uv_translation); + gps_dst->uv_scale = gps_src->uv_scale; + gps_dst->select_index = gps_src->select_index; + copy_v4_v4(gps_dst->vert_color_fill, gps_src->vert_color_fill); } bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool internal_copy) @@ -2579,36 +2648,53 @@ void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig } } -void BKE_gpencil_update_orig_pointers(const Object *ob_orig, const Object *ob_eval) +/** + * Update original pointers in evaluated layer. + * \param gpl_orig: Original grease-pencil layer. + * \param gpl_eval: Evaluated grease pencil layer. + */ +void BKE_gpencil_layer_original_pointers_update(const struct bGPDlayer *gpl_orig, + const struct bGPDlayer *gpl_eval) { - bGPdata *gpd_eval = (bGPdata *)ob_eval->data; - bGPdata *gpd_orig = (bGPdata *)ob_orig->data; + bGPDframe *gpf_eval = gpl_eval->frames.first; + LISTBASE_FOREACH (bGPDframe *, gpf_orig, &gpl_orig->frames) { + if (gpf_eval != NULL) { + /* Update frame reference pointers. */ + gpf_eval->runtime.gpf_orig = (bGPDframe *)gpf_orig; + BKE_gpencil_frame_original_pointers_update(gpf_orig, gpf_eval); + gpf_eval = gpf_eval->next; + } + } +} +void BKE_gpencil_data_update_orig_pointers(const bGPdata *gpd_orig, const bGPdata *gpd_eval) +{ /* Assign pointers to the original stroke and points to the evaluated data. This must * be done before applying any modifier because at this moment the structure is equals, * so we can assume the layer index is the same in both data-blocks. * This data will be used by operators. */ bGPDlayer *gpl_eval = gpd_eval->layers.first; - LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd_orig->layers) { + LISTBASE_FOREACH (bGPDlayer *, gpl_orig, &gpd_orig->layers) { if (gpl_eval != NULL) { /* Update layer reference pointers. */ - gpl_eval->runtime.gpl_orig = (bGPDlayer *)gpl; - - bGPDframe *gpf_eval = gpl_eval->frames.first; - LISTBASE_FOREACH (bGPDframe *, gpf_orig, &gpl->frames) { - if (gpf_eval != NULL) { - /* Update frame reference pointers. */ - gpf_eval->runtime.gpf_orig = (bGPDframe *)gpf_orig; - BKE_gpencil_frame_original_pointers_update(gpf_orig, gpf_eval); - gpf_eval = gpf_eval->next; - } - } + gpl_eval->runtime.gpl_orig = gpl_orig; + BKE_gpencil_layer_original_pointers_update(gpl_orig, gpl_eval); gpl_eval = gpl_eval->next; } } } +/** + * Update pointers of eval data to original data to keep references. + * \param ob_orig: Original grease pencil object + * \param ob_eval: Evaluated grease pencil object + */ +void BKE_gpencil_update_orig_pointers(const Object *ob_orig, const Object *ob_eval) +{ + BKE_gpencil_data_update_orig_pointers((bGPdata *)ob_orig->data, (bGPdata *)ob_eval->data); +} + void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, @@ -2751,4 +2837,180 @@ void BKE_gpencil_frame_selected_hash(bGPdata *gpd, struct GHash *r_list) } } +bool BKE_gpencil_can_avoid_full_copy_on_write(const Depsgraph *depsgraph, bGPdata *gpd) +{ + /* For now, we only use the update cache in the active depsgraph. Othwerwise we might access the + * cache while another depsgraph frees it. */ + if (!DEG_is_active(depsgraph)) { + return false; + } + + GPencilUpdateCache *update_cache = gpd->runtime.update_cache; + return update_cache != NULL && update_cache->flag != GP_UPDATE_NODE_FULL_COPY; +} + +typedef struct tGPencilUpdateOnWriteTraverseData { + bGPdata *gpd_eval; + bGPDlayer *gpl_eval; + bGPDframe *gpf_eval; + bGPDstroke *gps_eval; + int gpl_index; + int gpf_index; + int gps_index; +} tGPencilUpdateOnWriteTraverseData; + +static bool gpencil_update_on_write_layer_cb(GPencilUpdateCache *gpl_cache, void *user_data) +{ + tGPencilUpdateOnWriteTraverseData *td = (tGPencilUpdateOnWriteTraverseData *)user_data; + td->gpl_eval = BLI_findlinkfrom((Link *)td->gpl_eval, gpl_cache->index - td->gpl_index); + td->gpl_index = gpl_cache->index; + bGPDlayer *gpl = (bGPDlayer *)gpl_cache->data; + + if (gpl_cache->flag == GP_UPDATE_NODE_FULL_COPY) { + bGPDlayer *gpl_eval_next = td->gpl_eval->next; + BLI_assert(gpl != NULL); + + BKE_gpencil_layer_delete(td->gpd_eval, td->gpl_eval); + + td->gpl_eval = BKE_gpencil_layer_duplicate(gpl, true, true); + BLI_insertlinkbefore(&td->gpd_eval->layers, gpl_eval_next, td->gpl_eval); + + BKE_gpencil_layer_original_pointers_update(gpl, td->gpl_eval); + td->gpl_eval->runtime.gpl_orig = gpl; + return true; + } + else if (gpl_cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { + BLI_assert(gpl != NULL); + BKE_gpencil_layer_copy_settings(gpl, td->gpl_eval); + td->gpl_eval->runtime.gpl_orig = gpl; + } + + td->gpf_eval = td->gpl_eval->frames.first; + td->gpf_index = 0; + return false; +} + +static bool gpencil_update_on_write_frame_cb(GPencilUpdateCache *gpf_cache, void *user_data) +{ + tGPencilUpdateOnWriteTraverseData *td = (tGPencilUpdateOnWriteTraverseData *)user_data; + td->gpf_eval = BLI_findlinkfrom((Link *)td->gpf_eval, gpf_cache->index - td->gpf_index); + td->gpf_index = gpf_cache->index; + + bGPDframe *gpf = (bGPDframe *)gpf_cache->data; + + if (gpf_cache->flag == GP_UPDATE_NODE_FULL_COPY) { + /* Do a full copy of the frame. */ + bGPDframe *gpf_eval_next = td->gpf_eval->next; + BLI_assert(gpf != NULL); + + bool update_actframe = (td->gpl_eval->actframe == td->gpf_eval) ? true : false; + BKE_gpencil_free_strokes(td->gpf_eval); + BLI_freelinkN(&td->gpl_eval->frames, td->gpf_eval); + + td->gpf_eval = BKE_gpencil_frame_duplicate(gpf, true); + BLI_insertlinkbefore(&td->gpl_eval->frames, gpf_eval_next, td->gpf_eval); + + BKE_gpencil_frame_original_pointers_update(gpf, td->gpf_eval); + td->gpf_eval->runtime.gpf_orig = gpf; + + if (update_actframe) { + td->gpl_eval->actframe = td->gpf_eval; + } + + return true; + } + else if (gpf_cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { + BLI_assert(gpf != NULL); + BKE_gpencil_frame_copy_settings(gpf, td->gpf_eval); + td->gpf_eval->runtime.gpf_orig = gpf; + } + + td->gps_eval = td->gpf_eval->strokes.first; + td->gps_index = 0; + return false; +} + +static bool gpencil_update_on_write_stroke_cb(GPencilUpdateCache *gps_cache, void *user_data) +{ + tGPencilUpdateOnWriteTraverseData *td = (tGPencilUpdateOnWriteTraverseData *)user_data; + td->gps_eval = BLI_findlinkfrom((Link *)td->gps_eval, gps_cache->index - td->gps_index); + td->gps_index = gps_cache->index; + + bGPDstroke *gps = (bGPDstroke *)gps_cache->data; + + if (gps_cache->flag == GP_UPDATE_NODE_FULL_COPY) { + /* Do a full copy of the stroke. */ + bGPDstroke *gps_eval_next = td->gps_eval->next; + BLI_assert(gps != NULL); + + BLI_remlink(&td->gpf_eval->strokes, td->gps_eval); + BKE_gpencil_free_stroke(td->gps_eval); + + td->gps_eval = BKE_gpencil_stroke_duplicate(gps, true, true); + BLI_insertlinkbefore(&td->gpf_eval->strokes, gps_eval_next, td->gps_eval); + + td->gps_eval->runtime.gps_orig = gps; + + /* Assign original pt pointers. */ + for (int i = 0; i < gps->totpoints; i++) { + bGPDspoint *pt_orig = &gps->points[i]; + bGPDspoint *pt_eval = &td->gps_eval->points[i]; + pt_orig->runtime.pt_orig = NULL; + pt_orig->runtime.idx_orig = i; + pt_eval->runtime.pt_orig = pt_orig; + pt_eval->runtime.idx_orig = i; + } + } + else if (gps_cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { + BLI_assert(gps != NULL); + BKE_gpencil_stroke_copy_settings(gps, td->gps_eval); + td->gps_eval->runtime.gps_orig = gps; + } + + return false; +} + +/** + * Update the geometry of the evaluated bGPdata. + * This function will: + * 1) Copy the original data over to the evaluated object. + * 2) Update the original pointers in the runtime structs. + */ +void BKE_gpencil_update_on_write(bGPdata *gpd_orig, bGPdata *gpd_eval) +{ + GPencilUpdateCache *update_cache = gpd_orig->runtime.update_cache; + + /* We assume that a full copy is not needed and the update cache is populated. */ + if (update_cache == NULL || update_cache->flag == GP_UPDATE_NODE_FULL_COPY) { + return; + } + + if (update_cache->flag == GP_UPDATE_NODE_LIGHT_COPY) { + BKE_gpencil_data_copy_settings(gpd_orig, gpd_eval); + } + + GPencilUpdateCacheTraverseSettings ts = {{ + gpencil_update_on_write_layer_cb, + gpencil_update_on_write_frame_cb, + gpencil_update_on_write_stroke_cb, + }}; + + tGPencilUpdateOnWriteTraverseData data = { + .gpd_eval = gpd_eval, + .gpl_eval = gpd_eval->layers.first, + .gpf_eval = NULL, + .gps_eval = NULL, + .gpl_index = 0, + .gpf_index = 0, + .gps_index = 0, + }; + + BKE_gpencil_traverse_update_cache(update_cache, &ts, &data); + + gpd_eval->flag |= GP_DATA_CACHE_IS_DIRTY; + + /* TODO: This might cause issues when we have multiple depsgraphs? */ + BKE_gpencil_free_update_cache(gpd_orig); +} + /** \} */ diff --git a/source/blender/blenkernel/intern/gpencil_update_cache.c b/source/blender/blenkernel/intern/gpencil_update_cache.c new file mode 100644 index 00000000000..323c3a9f2a2 --- /dev/null +++ b/source/blender/blenkernel/intern/gpencil_update_cache.c @@ -0,0 +1,274 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022, Blender Foundation + * This is a new part of Blender + */ + +/** \file + * \ingroup bke + */ + +#include + +#include "BKE_gpencil_update_cache.h" + +#include "BLI_dlrbTree.h" +#include "BLI_listbase.h" + +#include "BKE_gpencil.h" + +#include "DNA_gpencil_types.h" +#include "DNA_userdef_types.h" + +#include "MEM_guardedalloc.h" + +static GPencilUpdateCache *update_cache_alloc(int index, int flag, void *data) +{ + GPencilUpdateCache *new_cache = MEM_callocN(sizeof(GPencilUpdateCache), __func__); + new_cache->children = BLI_dlrbTree_new(); + new_cache->flag = flag; + new_cache->index = index; + new_cache->data = data; + + return new_cache; +} + +static short cache_node_compare(void *node, void *data) +{ + int index_a = ((GPencilUpdateCacheNode *)node)->cache->index; + int index_b = ((GPencilUpdateCache *)data)->index; + if (index_a == index_b) { + return 0; + } + return index_a < index_b ? 1 : -1; +} + +static DLRBT_Node *cache_node_alloc(void *data) +{ + GPencilUpdateCacheNode *new_node = MEM_callocN(sizeof(GPencilUpdateCacheNode), __func__); + new_node->cache = ((GPencilUpdateCache *)data); + return (DLRBT_Node *)new_node; +} + +static void cache_node_free(void *node); + +static void update_cache_free(GPencilUpdateCache *cache) +{ + if (cache->children != NULL) { + BLI_dlrbTree_free(cache->children, cache_node_free); + MEM_freeN(cache->children); + } + MEM_freeN(cache); +} + +static void cache_node_free(void *node) +{ + GPencilUpdateCache *cache = ((GPencilUpdateCacheNode *)node)->cache; + if (cache != NULL) { + update_cache_free(cache); + } + MEM_freeN(node); +} + +static void cache_node_update(void *node, void *data) +{ + GPencilUpdateCache *update_cache = ((GPencilUpdateCacheNode *)node)->cache; + GPencilUpdateCache *new_update_cache = (GPencilUpdateCache *)data; + + /* If the new cache is already "covered" by the current cache, just free it and return. */ + if (new_update_cache->flag <= update_cache->flag) { + update_cache_free(new_update_cache); + return; + } + + update_cache->data = new_update_cache->data; + update_cache->flag = new_update_cache->flag; + + /* In case the new cache does a full update, remove its children since they will be all + * updated by this cache. */ + if (new_update_cache->flag == GP_UPDATE_NODE_FULL_COPY && update_cache->children != NULL) { + BLI_dlrbTree_free(update_cache->children, cache_node_free); + MEM_freeN(update_cache->children); + } + + update_cache_free(new_update_cache); +} + +static void update_cache_node_create_ex(GPencilUpdateCache *root_cache, + void *data, + int gpl_index, + int gpf_index, + int gps_index, + bool full_copy) +{ + if (root_cache->flag == GP_UPDATE_NODE_FULL_COPY) { + /* Entire data-block has to be recaculated, e.g. nothing else needs to be added to the cache. + */ + return; + } + + const int node_flag = full_copy ? GP_UPDATE_NODE_FULL_COPY : GP_UPDATE_NODE_LIGHT_COPY; + + if (gpl_index == -1) { + root_cache->data = (bGPdata *)data; + root_cache->flag = node_flag; + if (full_copy) { + /* Entire data-block has to be recaculated, remove all caches of "lower" elements. */ + BLI_dlrbTree_free(root_cache->children, cache_node_free); + } + return; + } + + const bool is_layer_update_node = (gpf_index == -1); + /* If the data pointer in GPencilUpdateCache is NULL, this element is not actually cached + * and does not need to be updated, but we do need the index to find elements that are in + * levels below. E.g. if a stroke needs to be updated, the frame it is in would not hold a + * pointer to it's data. */ + GPencilUpdateCache *gpl_cache = update_cache_alloc( + gpl_index, + is_layer_update_node ? node_flag : GP_UPDATE_NODE_NO_COPY, + is_layer_update_node ? (bGPDlayer *)data : NULL); + GPencilUpdateCacheNode *gpl_node = (GPencilUpdateCacheNode *)BLI_dlrbTree_add( + root_cache->children, cache_node_compare, cache_node_alloc, cache_node_update, gpl_cache); + + BLI_dlrbTree_linkedlist_sync(root_cache->children); + if (gpl_node->cache->flag == GP_UPDATE_NODE_FULL_COPY || is_layer_update_node) { + return; + } + + const bool is_frame_update_node = (gps_index == -1); + GPencilUpdateCache *gpf_cache = update_cache_alloc( + gpf_index, + is_frame_update_node ? node_flag : GP_UPDATE_NODE_NO_COPY, + is_frame_update_node ? (bGPDframe *)data : NULL); + GPencilUpdateCacheNode *gpf_node = (GPencilUpdateCacheNode *)BLI_dlrbTree_add( + gpl_node->cache->children, + cache_node_compare, + cache_node_alloc, + cache_node_update, + gpf_cache); + + BLI_dlrbTree_linkedlist_sync(gpl_node->cache->children); + if (gpf_node->cache->flag == GP_UPDATE_NODE_FULL_COPY || is_frame_update_node) { + return; + } + + GPencilUpdateCache *gps_cache = update_cache_alloc(gps_index, node_flag, (bGPDstroke *)data); + BLI_dlrbTree_add( + gpf_node->cache->children, cache_node_compare, cache_node_alloc, cache_node_update, gps_cache); + + BLI_dlrbTree_linkedlist_sync(gpf_node->cache->children); +} + +static void update_cache_node_create( + bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, bool full_copy) +{ + if (gpd == NULL) { + return; + } + + GPencilUpdateCache *root_cache = gpd->runtime.update_cache; + if (root_cache == NULL) { + gpd->runtime.update_cache = update_cache_alloc(0, GP_UPDATE_NODE_NO_COPY, NULL); + root_cache = gpd->runtime.update_cache; + } + + if (root_cache->flag == GP_UPDATE_NODE_FULL_COPY) { + /* Entire data-block has to be recaculated, e.g. nothing else needs to be added to the cache. + */ + return; + } + + const int gpl_index = (gpl != NULL) ? BLI_findindex(&gpd->layers, gpl) : -1; + const int gpf_index = (gpl != NULL && gpf != NULL) ? BLI_findindex(&gpl->frames, gpf) : -1; + const int gps_index = (gpf != NULL && gps != NULL) ? BLI_findindex(&gpf->strokes, gps) : -1; + + void *data = gps; + if (!data) { + data = gpf; + } + if (!data) { + data = gpl; + } + if (!data) { + data = gpd; + } + + update_cache_node_create_ex(root_cache, data, gpl_index, gpf_index, gps_index, full_copy); +} + +static void gpencil_traverse_update_cache_ex(GPencilUpdateCache *parent_cache, + GPencilUpdateCacheTraverseSettings *ts, + int depth, + void *user_data) +{ + if (BLI_listbase_is_empty((ListBase *)parent_cache->children)) { + return; + } + + LISTBASE_FOREACH (GPencilUpdateCacheNode *, cache_node, parent_cache->children) { + GPencilUpdateCache *cache = cache_node->cache; + + GPencilUpdateCacheIter_Cb cb = ts->update_cache_cb[depth]; + if (cb != NULL) { + bool skip = cb(cache, user_data); + if (skip) { + continue; + } + } + + gpencil_traverse_update_cache_ex(cache, ts, depth + 1, user_data); + } +} + +/* -------------------------------------------------------------------- */ +/** \name Update Cache API + * + * \{ */ + +GPencilUpdateCache *BKE_gpencil_create_update_cache(void *data, bool full_copy) +{ + return update_cache_alloc( + 0, full_copy ? GP_UPDATE_NODE_FULL_COPY : GP_UPDATE_NODE_LIGHT_COPY, data); +} + +void BKE_gpencil_traverse_update_cache(GPencilUpdateCache *cache, + GPencilUpdateCacheTraverseSettings *ts, + void *user_data) +{ + gpencil_traverse_update_cache_ex(cache, ts, 0, user_data); +} + +void BKE_gpencil_tag_full_update(bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps) +{ + update_cache_node_create(gpd, gpl, gpf, gps, true); +} + +void BKE_gpencil_tag_light_update(bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps) +{ + update_cache_node_create(gpd, gpl, gpf, gps, false); +} + +void BKE_gpencil_free_update_cache(bGPdata *gpd) +{ + GPencilUpdateCache *gpd_cache = gpd->runtime.update_cache; + if (gpd_cache) { + update_cache_free(gpd_cache); + gpd->runtime.update_cache = NULL; + } +} + +/** \} */ diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h index 3cf849efaef..ad6e350ba2c 100644 --- a/source/blender/blenlib/BLI_dlrbTree.h +++ b/source/blender/blenlib/BLI_dlrbTree.h @@ -99,6 +99,12 @@ typedef DLRBT_Node *(*DLRBT_NAlloc_FP)(void *data); */ typedef void (*DLRBT_NUpdate_FP)(void *node, void *data); +/** + * Free a node and the wrapped data. + * \param node: the node to free. + */ +typedef void (*DLRBT_NFree_FP)(void *node); + /* ********************************************** */ /* Public API */ @@ -122,7 +128,7 @@ void BLI_dlrbTree_init(DLRBT_Tree *tree); /** * Free the given tree's data but not the tree itself. */ -void BLI_dlrbTree_free(DLRBT_Tree *tree); +void BLI_dlrbTree_free(DLRBT_Tree *tree, DLRBT_NFree_FP free_cb); /** * Make sure the tree's Double-Linked list representation is valid. diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index f73d1f22502..f970563d2a6 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -58,6 +58,12 @@ ListBase BLI_listbase_from_link(struct Link *some_link); */ void *BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); + +/** + * Returns the nth element after \a link, numbering from 0. + */ +void *BLI_findlinkfrom(struct Link *start, int number) ATTR_WARN_UNUSED_RESULT; + /** * Finds the first element of \a listbase which contains the null-terminated * string \a id at the specified offset, returning NULL if not found. diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 66c394f5eb2..9c22afeb893 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -45,7 +45,7 @@ void BLI_dlrbTree_init(DLRBT_Tree *tree) } /* Helper for traversing tree and freeing sub-nodes */ -static void recursive_tree_free_nodes(DLRBT_Node *node) +static void recursive_tree_free_nodes(DLRBT_Node *node, DLRBT_NFree_FP free_cb) { /* sanity check */ if (node == NULL) { @@ -53,14 +53,16 @@ static void recursive_tree_free_nodes(DLRBT_Node *node) } /* free child nodes + subtrees */ - recursive_tree_free_nodes(node->left); - recursive_tree_free_nodes(node->right); + recursive_tree_free_nodes(node->left, free_cb); + recursive_tree_free_nodes(node->right, free_cb); /* free self */ - MEM_freeN(node); + if (free_cb) { + free_cb(node); + } } -void BLI_dlrbTree_free(DLRBT_Tree *tree) +void BLI_dlrbTree_free(DLRBT_Tree *tree, DLRBT_NFree_FP free_cb) { if (tree == NULL) { return; @@ -71,11 +73,19 @@ void BLI_dlrbTree_free(DLRBT_Tree *tree) */ if (tree->first) { /* free list */ - BLI_freelistN((ListBase *)tree); + if (free_cb) { + LISTBASE_FOREACH_MUTABLE(DLRBT_Node *, node, tree) { + free_cb(node); + } + BLI_listbase_clear((ListBase *)tree); + } + else { + BLI_freelistN((ListBase *)tree); + } } else { /* traverse tree, freeing sub-nodes */ - recursive_tree_free_nodes(tree->root); + recursive_tree_free_nodes(tree->root, free_cb); } /* clear pointers */ @@ -584,8 +594,10 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, } default: /* update the duplicate node as appropriate */ { + /* Return the updated node after calling the callback. */ + node = parNode; if (update_cb) { - update_cb(parNode, data); + update_cb(node, data); } break; } diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 513b08a589d..c21b448e505 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -537,6 +537,21 @@ void *BLI_rfindlink(const ListBase *listbase, int number) return link; } +void *BLI_findlinkfrom(Link *start, int number) +{ + Link *link = NULL; + + if (number >= 0) { + link = start; + while (link != NULL && number != 0) { + number--; + link = link->next; + } + } + + return link; +} + int BLI_findindex(const ListBase *listbase, const void *vlink) { Link *link = NULL; diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc index 9e4d7c7dd36..88f597cdf67 100644 --- a/source/blender/blenlib/tests/BLI_listbase_test.cc +++ b/source/blender/blenlib/tests/BLI_listbase_test.cc @@ -80,18 +80,26 @@ TEST(listbase, FindLinkOrIndex) EXPECT_EQ(BLI_rfindlink(&lb, 0), (void *)nullptr); EXPECT_EQ(BLI_rfindlink(&lb, 1), (void *)nullptr); EXPECT_EQ(BLI_findindex(&lb, link1), -1); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, -1), (void *)nullptr); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 0), (void *)nullptr); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 1), (void *)nullptr); /* One link */ BLI_addtail(&lb, link1); EXPECT_EQ(BLI_findlink(&lb, 0), link1); EXPECT_EQ(BLI_rfindlink(&lb, 0), link1); EXPECT_EQ(BLI_findindex(&lb, link1), 0); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 0), link1); /* Two links */ BLI_addtail(&lb, link2); EXPECT_EQ(BLI_findlink(&lb, 1), link2); EXPECT_EQ(BLI_rfindlink(&lb, 0), link2); EXPECT_EQ(BLI_findindex(&lb, link2), 1); + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 1), link2); + + /* After end of list */ + EXPECT_EQ(BLI_findlinkfrom((Link *)lb.first, 2), (void *)nullptr); BLI_freelistN(&lb); } diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 41253117096..91c7fac68de 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -70,6 +70,7 @@ set(SRC intern/eval/deg_eval_flush.cc intern/eval/deg_eval_runtime_backup.cc intern/eval/deg_eval_runtime_backup_animation.cc + intern/eval/deg_eval_runtime_backup_gpencil.cc intern/eval/deg_eval_runtime_backup_modifier.cc intern/eval/deg_eval_runtime_backup_movieclip.cc intern/eval/deg_eval_runtime_backup_object.cc @@ -131,6 +132,7 @@ set(SRC intern/eval/deg_eval_flush.h intern/eval/deg_eval_runtime_backup.h intern/eval/deg_eval_runtime_backup_animation.h + intern/eval/deg_eval_runtime_backup_gpencil.h intern/eval/deg_eval_runtime_backup_modifier.h intern/eval/deg_eval_runtime_backup_movieclip.h intern/eval/deg_eval_runtime_backup_object.h diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index b64f94568f6..48166567354 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -43,6 +43,7 @@ #include "BKE_curve.h" #include "BKE_global.h" #include "BKE_gpencil.h" +#include "BKE_gpencil_update_cache.h" #include "BKE_idprop.h" #include "BKE_layer.h" #include "BKE_lib_id.h" @@ -737,9 +738,6 @@ void update_id_after_copy(const Depsgraph *depsgraph, } BKE_pose_pchan_index_rebuild(object_cow->pose); } - if (object_cow->type == OB_GPENCIL) { - BKE_gpencil_update_orig_pointers(object_orig, object_cow); - } update_particles_after_copy(depsgraph, object_orig, object_cow); break; } @@ -892,6 +890,13 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, const IDNode update_edit_mode_pointers(depsgraph, id_orig, id_cow); return id_cow; } + /* In case we don't need to do a copy-on-write, we can use the update cache of the grease + * pencil data to do an update-on-write.*/ + if (id_type == ID_GD && BKE_gpencil_can_avoid_full_copy_on_write( + (const ::Depsgraph *)depsgraph, (bGPdata *)id_orig)) { + BKE_gpencil_update_on_write((bGPdata *)id_orig, (bGPdata *)id_cow); + return id_cow; + } } RuntimeBackup backup(depsgraph); diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc index 8bf64af7d5d..85ac8b509c2 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc @@ -40,7 +40,8 @@ RuntimeBackup::RuntimeBackup(const Depsgraph *depsgraph) object_backup(depsgraph), drawdata_ptr(nullptr), movieclip_backup(depsgraph), - volume_backup(depsgraph) + volume_backup(depsgraph), + gpencil_backup(depsgraph) { drawdata_backup.first = drawdata_backup.last = nullptr; } @@ -75,6 +76,8 @@ void RuntimeBackup::init_from_id(ID *id) case ID_VO: volume_backup.init_from_volume(reinterpret_cast(id)); break; + case ID_GD: + gpencil_backup.init_from_gpencil(reinterpret_cast(id)); default: break; } @@ -115,6 +118,8 @@ void RuntimeBackup::restore_to_id(ID *id) case ID_VO: volume_backup.restore_to_volume(reinterpret_cast(id)); break; + case ID_GD: + gpencil_backup.restore_to_gpencil(reinterpret_cast(id)); default: break; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h index 0629dbe62b4..c4f6bd954c0 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h @@ -31,6 +31,7 @@ #include "intern/eval/deg_eval_runtime_backup_scene.h" #include "intern/eval/deg_eval_runtime_backup_sound.h" #include "intern/eval/deg_eval_runtime_backup_volume.h" +#include "intern/eval/deg_eval_runtime_backup_gpencil.h" namespace blender { namespace deg { @@ -71,6 +72,7 @@ class RuntimeBackup { DrawDataList *drawdata_ptr; MovieClipBackup movieclip_backup; VolumeBackup volume_backup; + GPencilBackup gpencil_backup; }; } // namespace deg diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc new file mode 100644 index 00000000000..63d1eb9f711 --- /dev/null +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc @@ -0,0 +1,59 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup depsgraph + */ + +#include "intern/eval/deg_eval_runtime_backup_gpencil.h" +#include "intern/depsgraph.h" + +#include "BKE_gpencil.h" +#include "BKE_gpencil_update_cache.h" + +#include "DNA_gpencil_types.h" + +namespace blender::deg { + +GPencilBackup::GPencilBackup(const Depsgraph *depsgraph) : depsgraph(depsgraph) +{ +} + +void GPencilBackup::init_from_gpencil(bGPdata *UNUSED(gpd)) +{ +} + +void GPencilBackup::restore_to_gpencil(bGPdata *gpd) +{ + bGPdata *gpd_orig = reinterpret_cast(gpd->id.orig_id); + + /* We check for the active depsgraph here to avoid freeing the cache on the original object + * multiple times. This free is only needed for the case where we tagged a full update in the + * update cache and did not do an update-on-write. */ + if (depsgraph->is_active) { + BKE_gpencil_free_update_cache(gpd_orig); + } + /* Doing a copy-on-write copies the update cache pointer. Make sure to reset it + * to NULL as we should never use the update cache from eval data. */ + gpd->runtime.update_cache = NULL; + /* Make sure to update the original runtime pointers in the eval data. */ + BKE_gpencil_data_update_orig_pointers(gpd_orig, gpd); +} + +} // namespace blender::deg diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h new file mode 100644 index 00000000000..baf0f6a6945 --- /dev/null +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.h @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup depsgraph + */ + +#pragma once + +struct bGPdata; + +namespace blender { +namespace deg { + +struct Depsgraph; + +/* Backup of volume datablocks runtime data. */ +class GPencilBackup { + public: + GPencilBackup(const Depsgraph *depsgraph); + + void init_from_gpencil(bGPdata *gpd); + void restore_to_gpencil(bGPdata *gpd); + + const Depsgraph* depsgraph; +}; + +} // namespace deg +} // namespace blender diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 79dda480a0a..082deab823b 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -56,6 +56,7 @@ #include "BKE_gpencil.h" #include "BKE_gpencil_curve.h" #include "BKE_gpencil_geom.h" +#include "BKE_gpencil_update_cache.h" #include "BKE_layer.h" #include "BKE_main.h" #include "BKE_material.h" @@ -1341,6 +1342,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) } gpencil_update_cache(p->gpd); + BKE_gpencil_tag_full_update(p->gpd, gpl, p->gpf, NULL); } /* --- 'Eraser' for 'Paint' Tool ------ */ @@ -2108,6 +2110,9 @@ static void gpencil_session_cleanup(tGPsdata *p) gpd->runtime.sbuffer_used = 0; gpd->runtime.sbuffer_size = 0; gpd->runtime.sbuffer_sflag = 0; + /* This update is required for update-on-write because the sbuffer data is not longer overwritten + * by a copy-on-write. */ + ED_gpencil_sbuffer_update_eval(gpd, p->ob_eval); p->inittime = 0.0; } @@ -2136,6 +2141,7 @@ static void gpencil_paint_initstroke(tGPsdata *p, p->gpl = BKE_gpencil_layer_active_get(p->gpd); if (p->gpl == NULL) { p->gpl = BKE_gpencil_layer_addnew(p->gpd, DATA_("GP_Layer"), true, false); + BKE_gpencil_tag_full_update(p->gpd, NULL, NULL, NULL); changed = true; if (p->custom_color[3]) { copy_v3_v3(p->gpl->color, p->custom_color); @@ -2218,10 +2224,15 @@ static void gpencil_paint_initstroke(tGPsdata *p, } bool need_tag = p->gpl->actframe == NULL; + bGPDframe *actframe = p->gpl->actframe; + p->gpf = BKE_gpencil_layer_frame_get(p->gpl, CFRA, add_frame_mode); /* Only if there wasn't an active frame, need update. */ if (need_tag) { - DEG_id_tag_update(&p->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + DEG_id_tag_update(&p->gpd->id, ID_RECALC_GEOMETRY); + } + if (actframe != p->gpl->actframe) { + BKE_gpencil_tag_full_update(p->gpd, p->gpl, NULL, NULL); } if (p->gpf == NULL) { diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 0cd4efb10d6..66b7f260f28 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -56,6 +56,7 @@ #include "BKE_gpencil.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" +#include "BKE_gpencil_update_cache.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_object_deform.h" @@ -297,6 +298,8 @@ static void gpencil_update_geometry(bGPdata *gpd) return; } + bool changed = false; + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { if ((gpl->actframe != gpf) && ((gpf->flag & GP_FRAME_SELECT) == 0)) { @@ -306,13 +309,17 @@ static void gpencil_update_geometry(bGPdata *gpd) LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { if (gps->flag & GP_STROKE_TAG) { BKE_gpencil_stroke_geometry_update(gpd, gps); + BKE_gpencil_tag_full_update(gpd, gpl, gpf, gps); gps->flag &= ~GP_STROKE_TAG; + changed = true; } } } } - DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + if (changed) { + DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY); + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + } } /* ************************************************ */ @@ -1351,8 +1358,9 @@ static void gpencil_sculpt_brush_init_stroke(bContext *C, tGP_BrushEditData *gso */ if (IS_AUTOKEY_ON(scene) && (gpf->framenum != cfra)) { BKE_gpencil_frame_addcopy(gpl, cfra); + BKE_gpencil_tag_full_update(gpd, gpl, NULL, NULL); /* Need tag to recalculate evaluated data to avoid crashes. */ - DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); + DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } } @@ -1696,6 +1704,9 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C, /* Delay a full recalculation for other frames. */ gpencil_recalc_geometry_tag(gps_active); } + bGPDlayer *gpl_active = (gpl->runtime.gpl_orig) ? gpl->runtime.gpl_orig : gpl; + bGPDframe *gpf_active = (gpf->runtime.gpf_orig) ? gpf->runtime.gpf_orig : gpf; + BKE_gpencil_tag_full_update(gpd, gpl_active, gpf_active, gps_active); } } diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 0f570f8603d..3340782d64a 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -35,6 +35,7 @@ struct AnimData; struct Curve; struct Curve; struct MDeformVert; +struct GPencilUpdateCache; #define GP_DEFAULT_PIX_FACTOR 1.0f #define GP_DEFAULT_GRID_LINES 4 @@ -325,6 +326,8 @@ typedef struct bGPDstroke { /** Curve used to edit the stroke using Bezier handlers. */ struct bGPDcurve *editcurve; + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_stroke_copy_settings as well! */ + bGPDstroke_Runtime runtime; void *_pad5; } bGPDstroke; @@ -409,6 +412,8 @@ typedef struct bGPDframe { /** Keyframe type (eBezTriple_KeyframeType). */ short key_type; + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_frame_copy_settings as well! */ + bGPDframe_Runtime runtime; } bGPDframe; @@ -532,6 +537,8 @@ typedef struct bGPDlayer { float layer_mat[4][4], layer_invmat[4][4]; char _pad3[4]; + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_layer_copy_settings as well! */ + bGPDlayer_Runtime runtime; } bGPDlayer; @@ -633,6 +640,8 @@ typedef struct bGPdata_Runtime { Brush *sbuffer_brush; struct GpencilBatchCache *gpencil_cache; struct LineartCache *lineart_cache; + + struct GPencilUpdateCache *update_cache; } bGPdata_Runtime; /* grid configuration */ @@ -726,6 +735,8 @@ typedef struct bGPdata { bGPgrid grid; + /* NOTE: When adding new members, make sure to add them to BKE_gpencil_data_copy_settings as well! */ + bGPdata_Runtime runtime; } bGPdata; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 7ef2f757cd8..ff194e2c52a 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -172,6 +172,7 @@ static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = { # include "BKE_gpencil.h" # include "BKE_gpencil_curve.h" # include "BKE_gpencil_geom.h" +# include "BKE_gpencil_update_cache.h" # include "BKE_icons.h" # include "DEG_depsgraph.h" @@ -179,6 +180,12 @@ static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = { static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { +#if 0 + /* In case a property on a layer changed, tag it with a light update. */ + if (ptr->type == &RNA_GPencilLayer) { + BKE_gpencil_tag_light_update((bGPdata *)(ptr->owner_id), (bGPDlayer *)(ptr->data), NULL, NULL); + } +#endif DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY); WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } -- cgit v1.2.3 From 87d2de88fdeec75c7dcd77f93d51ee71542b45ce Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 10 Feb 2022 12:07:48 +0100 Subject: Fix T95664: missing update after changing active output node --- source/blender/blenkernel/BKE_node_tree_update.h | 2 ++ source/blender/blenkernel/intern/node_tree_update.cc | 5 +++++ source/blender/editors/space_node/node_edit.cc | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/source/blender/blenkernel/BKE_node_tree_update.h b/source/blender/blenkernel/BKE_node_tree_update.h index 443ceafb073..834445420ef 100644 --- a/source/blender/blenkernel/BKE_node_tree_update.h +++ b/source/blender/blenkernel/BKE_node_tree_update.h @@ -60,6 +60,8 @@ void BKE_ntree_update_tag_link_removed(struct bNodeTree *ntree); void BKE_ntree_update_tag_link_added(struct bNodeTree *ntree, struct bNodeLink *link); void BKE_ntree_update_tag_link_mute(struct bNodeTree *ntree, struct bNodeLink *link); +/** Used when the a new output node becomes active and therefore changes the output. */ +void BKE_ntree_update_tag_active_output_changed(struct bNodeTree *ntree); /** Used after file loading when run-time data on the tree has not been initialized yet. */ void BKE_ntree_update_tag_missing_runtime_data(struct bNodeTree *ntree); /** Used when the interface sockets/values have changed. */ diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 904a0de9a90..9f3ce68ca69 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -1614,6 +1614,11 @@ void BKE_ntree_update_tag_link_mute(bNodeTree *ntree, bNodeLink *UNUSED(link)) add_tree_tag(ntree, NTREE_CHANGED_LINK); } +void BKE_ntree_update_tag_active_output_changed(bNodeTree *ntree) +{ + add_tree_tag(ntree, NTREE_CHANGED_ANY); +} + void BKE_ntree_update_tag_missing_runtime_data(bNodeTree *ntree) { add_tree_tag(ntree, NTREE_CHANGED_ALL); diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index a513f5df7a0..aa27edd77a7 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -667,6 +667,7 @@ void ED_node_set_active( node->flag |= NODE_DO_OUTPUT; if (!was_output) { do_update = true; + BKE_ntree_update_tag_active_output_changed(ntree); } } @@ -684,6 +685,7 @@ void ED_node_set_active( } node->flag |= NODE_DO_OUTPUT; + BKE_ntree_update_tag_active_output_changed(ntree); } ED_node_tree_propagate_change(nullptr, bmain, ntree); @@ -750,6 +752,7 @@ void ED_node_set_active( node->flag |= NODE_DO_OUTPUT; if (was_output == 0) { + BKE_ntree_update_tag_active_output_changed(ntree); ED_node_tree_propagate_change(nullptr, bmain, ntree); } @@ -765,6 +768,7 @@ void ED_node_set_active( } node->flag |= NODE_DO_OUTPUT; + BKE_ntree_update_tag_active_output_changed(ntree); ED_node_tree_propagate_change(nullptr, bmain, ntree); } } -- cgit v1.2.3 From 04d55038ee52fc1155cc0ece916d90fd535c2364 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Feb 2022 10:37:00 +0100 Subject: Fix size_t -> int -> size_t round trip in Cycles There are two things achieved by this change: - No possible downcast of size_t to int when calculating motion steps. - Disambiguate call to `min()` which was for some reason considered ambiguous on 32bit platforms `min(int, unsigned int)`. - Do the same for the `max()` call to keep them symmetrical. On an implementation side the `min()` is defined for a fixed width integer type to disambiguate uint from size_t on 32bit platforms, and yet be able to use it for 32bit operands on 64bit platforms without upcast. This ended up in a bit bigger change as the conditional compile-in of functions is easiest if the functions is templated. Making the functions templated required to remove the other source of ambiguity which is `algorithm.h` which was pulling min/max from std. Now it is the `math.h` which is the source of truth for min/max. It was only one place which was relying on `algorithm.h` for these functions, hence the choice of `math.h` as the safest and least intrusive. Fixes 32bit platforms (such as i386) in Debian package build system. Differential Revision: https://developer.blender.org/D14062 --- intern/cycles/bvh/embree.cpp | 6 ++--- intern/cycles/device/device.cpp | 2 +- intern/cycles/device/memory.h | 2 +- intern/cycles/device/metal/bvh.mm | 2 +- intern/cycles/device/optix/device_impl.cpp | 4 ++-- intern/cycles/scene/hair.cpp | 12 +++++----- intern/cycles/scene/light.cpp | 4 ++-- intern/cycles/scene/mesh.cpp | 2 +- intern/cycles/scene/pointcloud.cpp | 2 +- intern/cycles/util/algorithm.h | 2 -- intern/cycles/util/math.h | 36 +++++++++++++++++++++++++++++- intern/cycles/util/murmurhash.cpp | 2 +- 12 files changed, 54 insertions(+), 22 deletions(-) diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index 616b6273e6a..731fef52063 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -471,7 +471,7 @@ void BVHEmbree::add_instance(Object *ob, int i) assert(instance_bvh != NULL); const size_t num_object_motion_steps = ob->use_motion() ? ob->get_motion().size() : 1; - const size_t num_motion_steps = min(num_object_motion_steps, RTC_MAX_TIME_STEP_COUNT); + const size_t num_motion_steps = min(num_object_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); assert(num_object_motion_steps <= RTC_MAX_TIME_STEP_COUNT); RTCGeometry geom_id = rtcNewGeometry(rtc_device, RTC_GEOMETRY_TYPE_INSTANCE); @@ -522,7 +522,7 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); const size_t num_triangles = mesh->num_triangles(); @@ -775,7 +775,7 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i) } assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT); - num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT); + num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT); const size_t num_curves = hair->num_curves(); size_t num_segments = 0; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 14c97affb76..4d981e45ff1 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -335,7 +335,7 @@ DeviceInfo Device::get_multi_device(const vector &subdevices, if (device.type == DEVICE_CPU && subdevices.size() > 1) { if (background) { int orig_cpu_threads = (threads) ? threads : TaskScheduler::max_concurrency(); - int cpu_threads = max(orig_cpu_threads - (subdevices.size() - 1), 0); + int cpu_threads = max(orig_cpu_threads - (subdevices.size() - 1), size_t(0)); VLOG(1) << "CPU render threads reduced from " << orig_cpu_threads << " to " << cpu_threads << ", to dedicate to GPU."; diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index 2db3ac9a440..5d7f1981e46 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -311,7 +311,7 @@ template class device_only_memory : public device_memory { : device_memory(device, name, allow_host_memory_fallback ? MEM_READ_WRITE : MEM_DEVICE_ONLY) { data_type = device_type_traits::data_type; - data_elements = max(device_type_traits::num_elements, 1); + data_elements = max(device_type_traits::num_elements, size_t(1)); } device_only_memory(device_only_memory &&other) noexcept : device_memory(std::move(other)) diff --git a/intern/cycles/device/metal/bvh.mm b/intern/cycles/device/metal/bvh.mm index 8b252f1a5ec..6c8288a7e0f 100644 --- a/intern/cycles/device/metal/bvh.mm +++ b/intern/cycles/device/metal/bvh.mm @@ -761,7 +761,7 @@ bool BVHMetal::build_TLAS(Progress &progress, num_instances++; if (ob->use_motion()) { - num_motion_transforms += max(1, ob->get_motion().size()); + num_motion_transforms += max((size_t)1, ob->get_motion().size()); } else { num_motion_transforms++; diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index cb6c36d5ea6..e49c67c7f91 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -1586,7 +1586,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) if (ob->is_traceable() && ob->use_motion()) { total_motion_transform_size = align_up(total_motion_transform_size, OPTIX_TRANSFORM_BYTE_ALIGNMENT); - const size_t motion_keys = max(ob->get_motion().size(), 2) - 2; + const size_t motion_keys = max(ob->get_motion().size(), (size_t)2) - 2; total_motion_transform_size = total_motion_transform_size + sizeof(OptixSRTMotionTransform) + motion_keys * sizeof(OptixSRTData); @@ -1660,7 +1660,7 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) /* Insert motion traversable if object has motion. */ if (motion_blur && ob->use_motion()) { - size_t motion_keys = max(ob->get_motion().size(), 2) - 2; + size_t motion_keys = max(ob->get_motion().size(), (size_t)2) - 2; size_t motion_transform_size = sizeof(OptixSRTMotionTransform) + motion_keys * sizeof(OptixSRTData); diff --git a/intern/cycles/scene/hair.cpp b/intern/cycles/scene/hair.cpp index 2951a609ae9..9ac502e2727 100644 --- a/intern/cycles/scene/hair.cpp +++ b/intern/cycles/scene/hair.cpp @@ -119,7 +119,7 @@ void Hair::Curve::motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = std::min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[2]; @@ -147,7 +147,7 @@ void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float4 curr_keys[4]; @@ -191,8 +191,8 @@ void Hair::Curve::keys_for_step(const float3 *curve_keys, size_t k1, float4 r_keys[2]) const { - k0 = max(k0, 0); - k1 = min(k1, num_keys - 1); + k0 = max(k0, (size_t)0); + k1 = min(k1, (size_t)(num_keys - 1)); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ @@ -237,8 +237,8 @@ void Hair::Curve::cardinal_keys_for_step(const float3 *curve_keys, size_t k3, float4 r_keys[4]) const { - k0 = max(k0, 0); - k3 = min(k3, num_keys - 1); + k0 = max(k0, (size_t)0); + k3 = min(k3, (size_t)(num_keys - 1)); const size_t center_step = ((num_steps - 1) / 2); if (step == center_step) { /* Center step: regular key location. */ diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index 83e531f42ef..415c4044aee 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -606,8 +606,8 @@ void LightManager::device_update_background(Device *device, ImageMetaData metadata; if (!env->handle.empty()) { ImageMetaData metadata = env->handle.metadata(); - environment_res.x = max(environment_res.x, metadata.width); - environment_res.y = max(environment_res.y, metadata.height); + environment_res.x = max(environment_res.x, (int)metadata.width); + environment_res.y = max(environment_res.y, (int)metadata.height); } } if (node->type == SkyTextureNode::get_node_type()) { diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp index c381d7a54ff..f53dca88ee0 100644 --- a/intern/cycles/scene/mesh.cpp +++ b/intern/cycles/scene/mesh.cpp @@ -53,7 +53,7 @@ void Mesh::Triangle::motion_verts(const float3 *verts, { /* Figure out which steps we need to fetch and their interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ float3 curr_verts[3]; diff --git a/intern/cycles/scene/pointcloud.cpp b/intern/cycles/scene/pointcloud.cpp index 4f88fe9db3d..6356a5030f3 100644 --- a/intern/cycles/scene/pointcloud.cpp +++ b/intern/cycles/scene/pointcloud.cpp @@ -55,7 +55,7 @@ float4 PointCloud::Point::motion_key(const float3 *points, /* Figure out which steps we need to fetch and their * interpolation factor. */ const size_t max_step = num_steps - 1; - const size_t step = min((int)(time * max_step), max_step - 1); + const size_t step = min((size_t)(time * max_step), max_step - 1); const float t = time * max_step - step; /* Fetch vertex coordinates. */ const float4 curr_key = point_for_step( diff --git a/intern/cycles/util/algorithm.h b/intern/cycles/util/algorithm.h index 63abd4e92a3..7a37ca0fdf4 100644 --- a/intern/cycles/util/algorithm.h +++ b/intern/cycles/util/algorithm.h @@ -21,8 +21,6 @@ CCL_NAMESPACE_BEGIN -using std::max; -using std::min; using std::remove; using std::sort; using std::stable_sort; diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h index 605a19aaef0..2bfd4ba19b6 100644 --- a/intern/cycles/util/math.h +++ b/intern/cycles/util/math.h @@ -124,7 +124,41 @@ ccl_device_inline int min(int a, int b) return (a < b) ? a : b; } -ccl_device_inline uint min(uint a, uint b) +ccl_device_inline uint32_t max(uint32_t a, uint32_t b) +{ + return (a > b) ? a : b; +} + +ccl_device_inline uint32_t min(uint32_t a, uint32_t b) +{ + return (a < b) ? a : b; +} + +ccl_device_inline uint64_t max(uint64_t a, uint64_t b) +{ + return (a > b) ? a : b; +} + +ccl_device_inline uint64_t min(uint64_t a, uint64_t b) +{ + return (a < b) ? a : b; +} + +/* NOTE: On 64bit Darwin the `size_t` is defined as `unsigned long int` and `uint64_t` is defined + * as `unsigned long long`. Both of the definitions are 64 bit unsigned integer, but the automatic + * substitution does not allow to automatically pick function defined for `uint64_t` as it is not + * exactly the same type definition. + * Work this around by adding a templated function enabled for `size_t` type which will be used + * when there is no explicit specialization of `min()`/`max()` above. */ + +template +ccl_device_inline typename std::enable_if_t, T> max(T a, T b) +{ + return (a > b) ? a : b; +} + +template +ccl_device_inline typename std::enable_if_t, T> min(T a, T b) { return (a < b) ? a : b; } diff --git a/intern/cycles/util/murmurhash.cpp b/intern/cycles/util/murmurhash.cpp index 9ba0a282cc2..603e4a717a1 100644 --- a/intern/cycles/util/murmurhash.cpp +++ b/intern/cycles/util/murmurhash.cpp @@ -23,7 +23,7 @@ #include #include -#include "util/algorithm.h" +#include "util/math.h" #include "util/murmurhash.h" #if defined(_MSC_VER) -- cgit v1.2.3 From e9c9a2183dbb9aa2ad05ec1253098ae0c5aede65 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 10 Feb 2022 14:55:12 +0100 Subject: LibOverride: Fix/improve handling of hierarchy root in tagged creation. Decouple the reference (linked) root ID and the hierarchy (override) root ID. Previous code was assuming that the reference ID was always also tagged for override creation, which is true in current master, but cannot be assumed in general (and won't be true with partial resync anymore). Also add asserts to validate conditions that the reference/hierarchy_root variables must meet. --- source/blender/blenkernel/BKE_lib_override.h | 9 +++++++-- source/blender/blenkernel/intern/lib_override.c | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h index e24f8dd8927..c81616110cc 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -103,8 +103,12 @@ struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain, * \param owner_library: the library in which the overrides should be created. Besides versioning * and resync code path, this should always be NULL (i.e. the local .blend file). * - * \param reference_library: the library from which the linked data being overridden come from - * (i.e. the library of the linked reference ID). + * \param id_root_reference: the linked ID that is considered as the root of the overridden + * hierarchy. + * + * \param id_hierarchy_root: the override ID that is the root of the hierarchy. May be NULL, in + * which case it is assumed that the given `id_root_reference` is tagged for override, and its + * newly created override will be used as hierarchy root. * * \param do_no_main: Create the new override data outside of Main database. * Used for resyncing of linked overrides. @@ -114,6 +118,7 @@ struct ID *BKE_lib_override_library_create_from_id(struct Main *bmain, bool BKE_lib_override_library_create_from_tag(struct Main *bmain, struct Library *owner_library, const struct ID *id_root_reference, + struct ID *id_hierarchy_root, bool do_no_main); /** * Advanced 'smart' function to create fully functional overrides. diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index fd8b4721500..961f63b1f82 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -332,8 +332,15 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain, bool BKE_lib_override_library_create_from_tag(Main *bmain, Library *owner_library, const ID *id_root_reference, + ID *id_hierarchy_root, const bool do_no_main) { + BLI_assert(id_root_reference != NULL); + BLI_assert(id_hierarchy_root != NULL || (id_root_reference->tag & LIB_TAG_DOIT) != 0); + BLI_assert(id_hierarchy_root == NULL || + (ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root) && + id_hierarchy_root->override_library->reference == id_root_reference)); + const Library *reference_library = id_root_reference->lib; ID *reference_id; @@ -388,7 +395,10 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, /* Only remap new local ID's pointers, we don't want to force our new overrides onto our whole * existing linked IDs usages. */ if (success) { - ID *hierarchy_root_id = id_root_reference->newid; + if (id_root_reference->newid != NULL) { + id_hierarchy_root = id_root_reference->newid; + } + BLI_assert(id_hierarchy_root != NULL); for (todo_id_iter = todo_ids.first; todo_id_iter != NULL; todo_id_iter = todo_id_iter->next) { reference_id = todo_id_iter->data; @@ -398,7 +408,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, continue; } - local_id->override_library->hierarchy_root = hierarchy_root_id; + local_id->override_library->hierarchy_root = id_hierarchy_root; Key *reference_key, *local_key = NULL; if ((reference_key = BKE_key_from_id(reference_id)) != NULL) { @@ -889,7 +899,7 @@ static bool lib_override_library_create_do(Main *bmain, lib_override_group_tag_data_clear(&data); const bool success = BKE_lib_override_library_create_from_tag( - bmain, owner_library, id_root, false); + bmain, owner_library, id_root, NULL, false); return success; } @@ -1424,7 +1434,7 @@ static bool lib_override_library_resync(Main *bmain, * override IDs (including within the old overrides themselves, since those are tagged too * above). */ const bool success = BKE_lib_override_library_create_from_tag( - bmain, NULL, id_root_reference, true); + bmain, NULL, id_root_reference, id_root->override_library->hierarchy_root, true); if (!success) { return success; -- cgit v1.2.3 From 94f023023035492da824fb1f4df1067e1e1237f1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Feb 2022 15:51:19 +0100 Subject: Fix T95666: Crash when attempting multires linear subdivide The crash was happening when the mesh had loose edges. Loose edges are not part of OpenSubdiv topology and hence should not be communicated to the refiner. Pass ta boolean flag indicating whether an edge is loose or not in the mesh foreach routines, which seems to be the easiest way. --- source/blender/blenkernel/BKE_subdiv_foreach.h | 1 + .../blenkernel/intern/multires_reshape_smooth.c | 5 ++++- source/blender/blenkernel/intern/subdiv_foreach.c | 20 +++++++++++--------- source/blender/blenkernel/intern/subdiv_mesh.c | 1 + .../draw/intern/draw_cache_impl_subdivision.cc | 1 + 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_subdiv_foreach.h b/source/blender/blenkernel/BKE_subdiv_foreach.h index 7d9a589666a..001a4f9401b 100644 --- a/source/blender/blenkernel/BKE_subdiv_foreach.h +++ b/source/blender/blenkernel/BKE_subdiv_foreach.h @@ -74,6 +74,7 @@ typedef void (*SubdivForeachEdgeCb)(const struct SubdivForeachContext *context, void *tls, int coarse_edge_index, int subdiv_edge_index, + bool is_loose, int subdiv_v1, int subdiv_v2); diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c index 839c457dd84..9ecd0901689 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.c +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c @@ -825,6 +825,7 @@ static void foreach_edge(const struct SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int UNUSED(subdiv_edge_index), + const bool is_loose, const int subdiv_v1, const int subdiv_v2) { @@ -832,7 +833,9 @@ static void foreach_edge(const struct SubdivForeachContext *foreach_context, const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context; if (reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR) { - store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, (char)255); + if (!is_loose) { + store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, (char)255); + } return; } diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index 69bead27fe6..b510a9b3bba 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -734,7 +734,7 @@ static int subdiv_foreach_edges_row(SubdivForeachTaskContext *ctx, const int v1 = vertex_index; const int v2 = vertex_index + 1; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, false, v1, v2); vertex_index += 1; } return subdiv_edge_index; @@ -762,7 +762,7 @@ static int subdiv_foreach_edges_column(SubdivForeachTaskContext *ctx, const int v1 = vertex_index; const int v2 = vertex_index + num_edges_per_row; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, false, v1, v2); vertex_index += 1; } return subdiv_edge_index; @@ -862,7 +862,7 @@ static void subdiv_foreach_edges_all_patches_regular(SubdivForeachTaskContext *c const int v1 = (flip) ? (start_edge_vertex + (resolution - i - 3)) : (start_edge_vertex + i); const int v2 = side_start_index + side_stride * i; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } } @@ -926,7 +926,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c const int v1 = current_patch_vertex_index; const int v2 = next_path_vertex_index; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); current_patch_vertex_index += ptex_face_inner_resolution + 1; next_path_vertex_index += 1; } @@ -940,7 +940,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c const int v1 = center_vertex_index; const int v2 = current_patch_end_vertex_index; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } /* Connect inner path of patch to boundary. */ @@ -964,7 +964,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c (start_edge_vertex + i); const int v2 = side_start_index + i; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } if (ptex_face_resolution >= 3) { @@ -978,7 +978,7 @@ static void subdiv_foreach_edges_all_patches_special(SubdivForeachTaskContext *c (start_edge_vertex + i); const int v2 = side_start_index + (ptex_face_inner_resolution + 1) * i; ctx->foreach_context->edge( - ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, ORIGINDEX_NONE, subdiv_edge_index, false, v1, v2); } } prev_coarse_loop = coarse_loop; @@ -1015,6 +1015,8 @@ static void subdiv_foreach_boundary_edges(SubdivForeachTaskContext *ctx, const int resolution = ctx->settings->resolution; const int num_subdiv_vertices_per_coarse_edge = resolution - 2; const int num_subdiv_edges_per_coarse_edge = resolution - 1; + const bool is_loose = !BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, coarse_edge_index); + int subdiv_edge_index = ctx->edge_boundary_offset + coarse_edge_index * num_subdiv_edges_per_coarse_edge; int last_vertex_index = ctx->vertices_corner_offset + coarse_edge->v1; @@ -1023,13 +1025,13 @@ static void subdiv_foreach_boundary_edges(SubdivForeachTaskContext *ctx, const int v2 = ctx->vertices_edge_offset + coarse_edge_index * num_subdiv_vertices_per_coarse_edge + i; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, is_loose, v1, v2); last_vertex_index = v2; } const int v1 = last_vertex_index; const int v2 = ctx->vertices_corner_offset + coarse_edge->v2; ctx->foreach_context->edge( - ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, v1, v2); + ctx->foreach_context, tls, coarse_edge_index, subdiv_edge_index, is_loose, v1, v2); } /** \} */ diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index c334d9a2c33..09af77d5f09 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -767,6 +767,7 @@ static void subdiv_mesh_edge(const SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int subdiv_edge_index, + const bool UNUSED(is_loose), const int subdiv_v1, const int subdiv_v2) { diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index a24a3a5a3a7..bfd6c6db926 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -820,6 +820,7 @@ static void draw_subdiv_edge_cb(const SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int subdiv_edge_index, + const bool UNUSED(is_loose), const int UNUSED(subdiv_v1), const int UNUSED(subdiv_v2)) { -- cgit v1.2.3 From ad77b52abcbd0daf0d1a3ad395983cb90beeb72a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Feb 2022 16:05:11 +0100 Subject: Correction to previous Clang strict warning commit Need to only pop diagnostic if it was really pushed. Pointed out by Aras Pranckevicius, thanks! --- source/blender/io/wavefront_obj/exporter/obj_export_io.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh index 7e5fe1ca526..1745169ff98 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_io.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_io.hh @@ -273,7 +273,7 @@ constexpr FormattingSyntax syntax_elem_to_formatting(const eMTLSyntaxElement key } } } -#if defined __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic pop #endif -- cgit v1.2.3