From 9b5a65d1ec08adc23b6ea71f02abaf4783daa49c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 11:20:15 +1100 Subject: [PATCH 01/46] Cleanup: suppress unused function warning --- source/blender/io/usd/intern/usd_writer_material.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index b574d6a3d5d..7c295409adc 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -1323,6 +1323,7 @@ static void export_texture(const USDExporterContext &usd_export_context, bNode * usd_export_context.export_params.worker_status->reports); } +#ifdef WITH_MATERIALX static void export_texture(const USDExporterContext &usd_export_context, Image *ima) { export_texture(ima, @@ -1330,6 +1331,7 @@ static void export_texture(const USDExporterContext &usd_export_context, Image * usd_export_context.export_params.overwrite_textures, usd_export_context.export_params.worker_status->reports); } +#endif void export_texture(bNode *node, const pxr::UsdStageRefPtr stage, From 0f0bc1a940b450b0b933a886b220a8811d306f12 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 11:34:59 +1100 Subject: [PATCH 02/46] Fix #107426: error when texture bake cannot access evaluated mesh data Changes in [0] broke baking to objects with animated render visibility, causing render visibility override not to work. Resolve by disabling visibility optimizations. Ref !133358 [0]: 0dcee6a386645bb1e976d11aa2d1ae45b01f968a --- source/blender/editors/object/object_bake_api.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index bbdb8aca844..3f596d3b11b 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -1405,6 +1405,10 @@ static int bake(const BakeAPIRender *bkr, /* We build a depsgraph for the baking, * so we don't need to change the original data to adjust visibility and modifiers. */ Depsgraph *depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER); + + /* Ensure meshes are generated even for objects with animated visibility, see: #107426. */ + DEG_disable_visibility_optimization(depsgraph); + DEG_graph_build_from_view_layer(depsgraph); int op_result = OPERATOR_CANCELLED; From ecdeeca5b38cacb1baecf289a222e782325fccba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 11:37:58 +1100 Subject: [PATCH 03/46] Cleanup: re-order baking highpoly break-on-error Avoid breaking with a partially initialized `highpoly` as this could cause complications when freeing members in the future. Also use variables for brevity. --- .../blender/editors/object/object_bake_api.cc | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index 3f596d3b11b..cd133b3d9b3 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -1577,13 +1577,23 @@ static int bake(const BakeAPIRender *bkr, continue; } - /* initialize highpoly_data */ + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); + ob_eval->visibility_flag &= ~OB_HIDE_RENDER; + ob_eval->base_flag |= (BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT | BASE_ENABLED_RENDER); + + Mesh *mesh_eval = BKE_mesh_new_from_object(nullptr, ob_eval, false, false); + + /* Initialize `highpoly` data. */ highpoly[i].ob = ob_iter; - highpoly[i].ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); - highpoly[i].ob_eval->visibility_flag &= ~OB_HIDE_RENDER; - highpoly[i].ob_eval->base_flag |= (BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT | - BASE_ENABLED_RENDER); - highpoly[i].mesh = BKE_mesh_new_from_object(nullptr, highpoly[i].ob_eval, false, false); + highpoly[i].ob_eval = ob_eval; + highpoly[i].mesh = mesh_eval; + + /* Low-poly to high-poly transformation matrix. */ + copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr()); + invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); + + highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world().ptr()); + i++; /* NOTE(@ideasman42): While ideally this should never happen, * it's possible the `visibility_flag` assignment in this function @@ -1594,7 +1604,7 @@ static int bake(const BakeAPIRender *bkr, * Use an error here instead of a warning so users don't accidentally perform * a bake which seems to succeed with invalid results. * If visibility could be forced/overridden - it would help avoid the problem. */ - if (UNLIKELY(highpoly[i].mesh == nullptr)) { + if (UNLIKELY(mesh_eval == nullptr)) { BKE_reportf( reports, RPT_ERROR, @@ -1602,14 +1612,6 @@ static int bake(const BakeAPIRender *bkr, ob_iter->id.name + 2); goto cleanup; } - - /* Low-poly to high-poly transformation matrix. */ - copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr()); - invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); - - highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world().ptr()); - - i++; } BLI_assert(i == highpoly_num); From efe75841d372a26984662a1c8564881e09355646 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 22 Jan 2025 03:30:40 +0100 Subject: [PATCH 04/46] UI: Status Bar Display for POSELIB_OT_blend_pose_asset Simplify and improve the status bar display by adding icons and state highlighting while running "Blend Pose Asset". Pull Request: https://projects.blender.org/blender/blender/pulls/133397 --- source/blender/editors/armature/pose_lib_2.cc | 14 ++++++-------- source/blender/editors/include/ED_util.hh | 3 +++ source/blender/editors/util/ed_draw.cc | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/armature/pose_lib_2.cc b/source/blender/editors/armature/pose_lib_2.cc index 28794356888..60f886b3745 100644 --- a/source/blender/editors/armature/pose_lib_2.cc +++ b/source/blender/editors/armature/pose_lib_2.cc @@ -535,21 +535,19 @@ static int poselib_blend_modal(bContext *C, wmOperator *op, const wmEvent *event } if (pbd->needs_redraw) { - char status_string[UI_MAX_DRAW_STR]; - char slider_string[UI_MAX_DRAW_STR]; - char tab_string[50]; - ED_slider_status_string_get(pbd->slider, slider_string, sizeof(slider_string)); + WorkspaceStatus status(C); if (pbd->state == POSE_BLEND_BLENDING) { - STRNCPY(tab_string, IFACE_("[Tab] - Show original pose")); + status.item(IFACE_("Show Original Pose"), ICON_EVENT_TAB); } else { - STRNCPY(tab_string, IFACE_("[Tab] - Show blended pose")); + status.item(IFACE_("Show Blended Pose"), ICON_EVENT_TAB); } - SNPRINTF(status_string, IFACE_("%s | %s | [Ctrl] - Flip Pose"), tab_string, slider_string); - ED_workspace_status_text(C, status_string); + ED_slider_status_get(pbd->slider, status); + + status.item_bool(IFACE_("Flip Pose"), pbd->is_flipped, ICON_EVENT_CTRL); poselib_blend_apply(C, op); } diff --git a/source/blender/editors/include/ED_util.hh b/source/blender/editors/include/ED_util.hh index da57cf1c943..29b7bd52a86 100644 --- a/source/blender/editors/include/ED_util.hh +++ b/source/blender/editors/include/ED_util.hh @@ -12,6 +12,7 @@ struct Main; struct bContext; +class WorkspaceStatus; namespace blender::bke::id { class IDRemapper; @@ -86,6 +87,8 @@ void ED_slider_status_string_get(const tSlider *slider, char *status_string, size_t size_of_status_string); +void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status); + float ED_slider_factor_get(const tSlider *slider); void ED_slider_factor_set(tSlider *slider, float factor); diff --git a/source/blender/editors/util/ed_draw.cc b/source/blender/editors/util/ed_draw.cc index 2a1c502e458..d15c9ec3c40 100644 --- a/source/blender/editors/util/ed_draw.cc +++ b/source/blender/editors/util/ed_draw.cc @@ -556,6 +556,22 @@ void ED_slider_status_string_get(const tSlider *slider, increments_str); } +void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status) +{ + if (slider->allow_overshoot_lower || slider->allow_overshoot_upper) { + status.item_bool(IFACE_("Overshoot"), slider->overshoot, ICON_EVENT_E); + } + else { + status.item(IFACE_("Overshoot Disabled"), ICON_INFO); + } + + status.item_bool(IFACE_("Precision"), slider->precision, ICON_EVENT_SHIFT); + + if (slider->allow_increments) { + status.item_bool(IFACE_("Increments"), slider->increments, ICON_EVENT_CTRL); + } +} + void ED_slider_destroy(bContext *C, tSlider *slider) { /* Remove draw callback. */ From e3c0224d16a813be239ddd98b9ffa3c1d1699c96 Mon Sep 17 00:00:00 2001 From: John Kiril Swenson Date: Wed, 22 Jan 2025 03:43:01 +0100 Subject: [PATCH 05/46] Fix #133193: VSE: Wrong mouse cursor over scroll bars Add a check to see if the mouse is in the scroller region in `sequencer_main_cursor()`. Pull Request: https://projects.blender.org/blender/blender/pulls/133353 --- source/blender/editors/space_sequencer/space_sequencer.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index 86c31dae5f4..7cf9ed81d4d 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -678,6 +678,12 @@ static void sequencer_main_cursor(wmWindow *win, ScrArea *area, ARegion *region) return; } + const View2D *v2d = ®ion->v2d; + if (UI_view2d_mouse_in_scrollers(region, v2d, win->eventstate->xy)) { + WM_cursor_set(win, wmcursor); + return; + } + float mouse_co_region[2] = {float(win->eventstate->xy[0] - region->winrct.xmin), float(win->eventstate->xy[1] - region->winrct.ymin)}; float mouse_co_view[2]; @@ -705,7 +711,6 @@ static void sequencer_main_cursor(wmWindow *win, ScrArea *area, ARegion *region) return; } - const View2D *v2d = ®ion->v2d; const float scale_y = UI_view2d_scale_get_y(v2d); if (!ED_sequencer_can_select_handle(scene, selection.seq1, v2d) || scale_y < 16 * U.pixelsize) { From e7efb704fab6eac46dce33bf69a65b4ec3645e4e Mon Sep 17 00:00:00 2001 From: YimingWu Date: Wed, 22 Jan 2025 03:51:45 +0100 Subject: [PATCH 06/46] Fix #133367: Use `BKE_unit_value_as_string_scaled` for ruler gizmo `BKE_unit_value_as_string` was modified in e949ff73349426c5aefe to include a `BKE_unit_value_as_string_scaled` version, some places on the interface needs to use the scaled version to show the string, this includes ruler gizmo length text. Pull Request: https://projects.blender.org/blender/blender/pulls/133373 --- source/blender/editors/space_view3d/view3d_gizmo_ruler.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc index adb8038d7a3..9185479b042 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc @@ -215,7 +215,8 @@ static void ruler_item_as_string( BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len); } else { - BKE_unit_value_as_string(numstr, numstr_size, ruler_len, prec, B_UNIT_LENGTH, unit, false); + BKE_unit_value_as_string_scaled( + numstr, numstr_size, ruler_len, prec, B_UNIT_LENGTH, unit, false); } } } From 58b7543ede16e2531145272538d909f0fe9ed0f9 Mon Sep 17 00:00:00 2001 From: Alaska Date: Wed, 22 Jan 2025 05:50:32 +0100 Subject: [PATCH 07/46] Fix #132322: Artifacts in Cycles volume rendering with Light tree on some devices In a previous commit (1), adjustments to light tree traversal were made to try and skip distant lights when deciding which light to sample while within a world volume. The skip wasn't implemented properly, and as a result distant lights were still included in the light tree traversal in that sitaution. And due to the way the skip was implemented, there were some unintialized variables used in the processing of the distant lights importance which caused artifacts on some platforms. This commit fixes this issue by reverting the skip of distant lights in that situation. (1) blender/blender@6fbc958e895e553dd85d002e87af965f06c0b426 Pull Request: https://projects.blender.org/blender/blender/pulls/132344 --- intern/cycles/kernel/light/background.h | 11 ++++++++--- intern/cycles/kernel/light/distant.h | 11 ++++++++--- intern/cycles/kernel/light/tree.h | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/intern/cycles/kernel/light/background.h b/intern/cycles/kernel/light/background.h index e3bec5011bc..559a8e8348f 100644 --- a/intern/cycles/kernel/light/background.h +++ b/intern/cycles/kernel/light/background.h @@ -477,10 +477,15 @@ ccl_device_forceinline bool background_light_tree_parameters(const float3 centro { if (in_volume_segment) { if (t == FLT_MAX) { - /* In world volume, distant light has no contribution. */ - return false; + /* In world volumes, distant lights can contribute to the lighting of the volume with + * specific configurations of procedurally generated volumes. Use a ray length of 1.0 in this + * case to give the distant light some weight, but one that isn't too high for a typical + * world volume use case. */ + theta_d = 1.0f; + } + else { + theta_d = t; } - theta_d = t; } /* Cover the whole sphere */ diff --git a/intern/cycles/kernel/light/distant.h b/intern/cycles/kernel/light/distant.h index 6fe16cff542..61e08946b36 100644 --- a/intern/cycles/kernel/light/distant.h +++ b/intern/cycles/kernel/light/distant.h @@ -142,10 +142,15 @@ ccl_device_forceinline bool distant_light_tree_parameters(const float3 centroid, { if (in_volume_segment) { if (t == FLT_MAX) { - /* In world volume, distant light has no contribution. */ - return false; + /* In world volumes, distant lights can contribute to the lighting of the volume with + * specific configurations of procedurally generated volumes. Use a ray length of 1.0 in this + * case to give the distant light some weight, but one that isn't too high for a typical + * world volume use case. */ + theta_d = 1.0f; + } + else { + theta_d = t; } - theta_d = t; } /* Treating it as a disk light 1 unit away */ diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 274438e1e38..54b2113d77f 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -322,10 +322,15 @@ ccl_device void light_tree_node_importance(KernelGlobals kg, cos_theta_u = fast_cosf(bcone.theta_o + bcone.theta_e); distance = 1.0f; /* For distant lights, the integral in Eq. (4) gives the ray length. */ - theta_d = t; if (t == FLT_MAX) { - /* In world volume, distant light has no contribution. */ - return; + /* In world volumes, distant lights can contribute to the lighting of the volume with + * specific configurations of procedurally generated volumes. Use a ray length of 1.0 in this + * case to give the distant light some weight, but one that isn't too high for a typical + * world volume use case. */ + theta_d = 1.0f; + } + else { + theta_d = t; } } else { From dfb01181cd0920626d7f97119255a781133d0b4b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 16:27:34 +1100 Subject: [PATCH 08/46] extern: update quadriflow patch to account for local changes --- extern/quadriflow/patches/blender.patch | 269 ++++++++++++------------ 1 file changed, 137 insertions(+), 132 deletions(-) diff --git a/extern/quadriflow/patches/blender.patch b/extern/quadriflow/patches/blender.patch index 42e0cd4d235..ade60d28d02 100644 --- a/extern/quadriflow/patches/blender.patch +++ b/extern/quadriflow/patches/blender.patch @@ -1,33 +1,5 @@ -diff --git a/extern/quadriflow/src/loader.cpp b/extern/quadriflow/src/loader.cpp ---- a/extern/quadriflow/src/loader.cpp -+++ b/extern/quadriflow/src/loader.cpp -@@ -69,7 +69,7 @@ - }; - - /// Hash function for obj_vertex -- struct obj_vertexHash : std::unary_function { -+ struct obj_vertexHash { - std::size_t operator()(const obj_vertex &v) const { - size_t hash = std::hash()(v.p); - hash = hash * 37 + std::hash()(v.uv); -diff --git a/extern/quadriflow/src/config.hpp b/extern/quadriflow/src/config.hpp -index 842b885..bf597ad 100644 ---- a/extern/quadriflow/src/config.hpp -+++ b/extern/quadriflow/src/config.hpp -@@ -1,6 +1,11 @@ - #ifndef CONFIG_H_ - #define CONFIG_H_ - -+/* Workaround a bug in boost 1.68, until we upgrade to a newer version. */ -+#if defined(__clang__) && defined(WIN32) -+ #include -+ using namespace boost; -+#endif - // Move settings to cmake to make CMake happy :) - - // #define WITH_SCALE diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc b/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc -index 35a73d9..0eeba8a 100644 +index 35a73d9f308..0eeba8ab6c2 100644 --- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc +++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc @@ -221,9 +221,8 @@ namespace lemon { @@ -41,8 +13,96 @@ index 35a73d9..0eeba8a 100644 ParData p; p.help=opt; p.mandatory=false; +diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h +index 355ee008246..a770bbee60c 100644 +--- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h ++++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h +@@ -88,7 +88,7 @@ namespace lemon { + Item it; + for (nf->first(it); it != INVALID; nf->next(it)) { + int id = nf->id(it);; +- allocator.construct(&(values[id]), Value()); ++ std::allocator_traits::construct(allocator, &(values[id]), Value()); + } + } + +@@ -218,15 +218,15 @@ namespace lemon { + for (nf->first(it); it != INVALID; nf->next(it)) { + int jd = nf->id(it);; + if (id != jd) { +- allocator.construct(&(new_values[jd]), values[jd]); +- allocator.destroy(&(values[jd])); ++ std::allocator_traits::construct(allocator, &(new_values[jd]), values[jd]); ++ std::allocator_traits::destroy(allocator, &(values[jd])); + } + } + if (capacity != 0) allocator.deallocate(values, capacity); + values = new_values; + capacity = new_capacity; + } +- allocator.construct(&(values[id]), Value()); ++ std::allocator_traits::construct(allocator, &(values[id]), Value()); + } + + // \brief Adds more new keys to the map. +@@ -260,8 +260,8 @@ namespace lemon { + } + } + if (found) continue; +- allocator.construct(&(new_values[id]), values[id]); +- allocator.destroy(&(values[id])); ++ std::allocator_traits::construct(allocator, &(new_values[id]), values[id]); ++ std::allocator_traits::destroy(allocator, &(values[id])); + } + if (capacity != 0) allocator.deallocate(values, capacity); + values = new_values; +@@ -269,7 +269,7 @@ namespace lemon { + } + for (int i = 0; i < int(keys.size()); ++i) { + int id = nf->id(keys[i]); +- allocator.construct(&(values[id]), Value()); ++ std::allocator_traits::construct(allocator, &(values[id]), Value()); + } + } + +@@ -279,7 +279,7 @@ namespace lemon { + // and it overrides the erase() member function of the observer base. + virtual void erase(const Key& key) { + int id = Parent::notifier()->id(key); +- allocator.destroy(&(values[id])); ++ std::allocator_traits::destroy(allocator, &(values[id])); + } + + // \brief Erase more keys from the map. +@@ -289,7 +289,7 @@ namespace lemon { + virtual void erase(const std::vector& keys) { + for (int i = 0; i < int(keys.size()); ++i) { + int id = Parent::notifier()->id(keys[i]); +- allocator.destroy(&(values[id])); ++ std::allocator_traits::destroy(allocator, &(values[id])); + } + } + +@@ -303,7 +303,7 @@ namespace lemon { + Item it; + for (nf->first(it); it != INVALID; nf->next(it)) { + int id = nf->id(it);; +- allocator.construct(&(values[id]), Value()); ++ std::allocator_traits::construct(allocator, &(values[id]), Value()); + } + } + +@@ -317,7 +317,7 @@ namespace lemon { + Item it; + for (nf->first(it); it != INVALID; nf->next(it)) { + int id = nf->id(it); +- allocator.destroy(&(values[id])); ++ std::allocator_traits::destroy(allocator, &(values[id])); + } + allocator.deallocate(values, capacity); + capacity = 0; diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h -index 6ccad33..388e990 100644 +index 6ccad33e68e..388e990ec3b 100644 --- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h +++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h @@ -234,7 +234,7 @@ namespace lemon { @@ -114,20 +174,6 @@ index 6ccad33..388e990 100644 changeFlow(change); if (change) { updateTreeStructure(); -diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp -index c333256..8cc41da 100644 ---- a/extern/quadriflow/src/hierarchy.cpp -+++ b/extern/quadriflow/src/hierarchy.cpp -@@ -1133,7 +1133,8 @@ void Hierarchy::propagateConstraints() { - auto& COw = mCOw[l]; - auto& COw_next = mCOw[l + 1]; - auto& toUpper = mToUpper[l]; -- MatrixXd& S = mS[l]; -+ // FIXME -+ // MatrixXd& S = mS[l]; - - for (uint32_t i = 0; i != mV[l + 1].cols(); ++i) { - Vector2i upper = toUpper.col(i); diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h index 8de74ede8a9..f9861f39169 100644 --- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h @@ -143,96 +189,24 @@ index 8de74ede8a9..f9861f39169 100644 num = length - shift; while (num--) { -diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h -index 355ee008246..a770bbee60c 100644 ---- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h -+++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h -@@ -88,7 +88,7 @@ namespace lemon { - Item it; - for (nf->first(it); it != INVALID; nf->next(it)) { - int id = nf->id(it);; -- allocator.construct(&(values[id]), Value()); -+ std::allocator_traits::construct(allocator, &(values[id]), Value()); - } - } - -@@ -218,15 +218,15 @@ namespace lemon { - for (nf->first(it); it != INVALID; nf->next(it)) { - int jd = nf->id(it);; - if (id != jd) { -- allocator.construct(&(new_values[jd]), values[jd]); -- allocator.destroy(&(values[jd])); -+ std::allocator_traits::construct(allocator, &(new_values[jd]), values[jd]); -+ std::allocator_traits::destroy(allocator, &(values[jd])); - } - } - if (capacity != 0) allocator.deallocate(values, capacity); - values = new_values; - capacity = new_capacity; - } -- allocator.construct(&(values[id]), Value()); -+ std::allocator_traits::construct(allocator, &(values[id]), Value()); - } - - // \brief Adds more new keys to the map. -@@ -260,8 +260,8 @@ namespace lemon { - } - } - if (found) continue; -- allocator.construct(&(new_values[id]), values[id]); -- allocator.destroy(&(values[id])); -+ std::allocator_traits::construct(allocator, &(new_values[id]), values[id]); -+ std::allocator_traits::destroy(allocator, &(values[id])); - } - if (capacity != 0) allocator.deallocate(values, capacity); - values = new_values; -@@ -269,7 +269,7 @@ namespace lemon { - } - for (int i = 0; i < int(keys.size()); ++i) { - int id = nf->id(keys[i]); -- allocator.construct(&(values[id]), Value()); -+ std::allocator_traits::construct(allocator, &(values[id]), Value()); - } - } - -@@ -279,7 +279,7 @@ namespace lemon { - // and it overrides the erase() member function of the observer base. - virtual void erase(const Key& key) { - int id = Parent::notifier()->id(key); -- allocator.destroy(&(values[id])); -+ std::allocator_traits::destroy(allocator, &(values[id])); - } - - // \brief Erase more keys from the map. -@@ -289,7 +289,7 @@ namespace lemon { - virtual void erase(const std::vector& keys) { - for (int i = 0; i < int(keys.size()); ++i) { - int id = Parent::notifier()->id(keys[i]); -- allocator.destroy(&(values[id])); -+ std::allocator_traits::destroy(allocator, &(values[id])); - } - } +diff --git a/extern/quadriflow/src/config.hpp b/extern/quadriflow/src/config.hpp +index 842b885a209..bf597ad0f39 100644 +--- a/extern/quadriflow/src/config.hpp ++++ b/extern/quadriflow/src/config.hpp +@@ -1,6 +1,11 @@ + #ifndef CONFIG_H_ + #define CONFIG_H_ -@@ -303,7 +303,7 @@ namespace lemon { - Item it; - for (nf->first(it); it != INVALID; nf->next(it)) { - int id = nf->id(it);; -- allocator.construct(&(values[id]), Value()); -+ std::allocator_traits::construct(allocator, &(values[id]), Value()); - } - } ++/* Workaround a bug in boost 1.68, until we upgrade to a newer version. */ ++#if defined(__clang__) && defined(WIN32) ++ #include ++ using namespace boost; ++#endif + // Move settings to cmake to make CMake happy :) -@@ -317,7 +317,7 @@ namespace lemon { - Item it; - for (nf->first(it); it != INVALID; nf->next(it)) { - int id = nf->id(it); -- allocator.destroy(&(values[id])); -+ std::allocator_traits::destroy(allocator, &(values[id])); - } - allocator.deallocate(values, capacity); - capacity = 0; + // #define WITH_SCALE diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp -index 8cc41da23d0..70a9628320f 100644 +index c333256a139..70a9628320f 100644 --- a/extern/quadriflow/src/hierarchy.cpp +++ b/extern/quadriflow/src/hierarchy.cpp @@ -269,7 +269,13 @@ void Hierarchy::DownsampleGraph(const AdjacentMatrix adj, const MatrixXd& V, con @@ -249,4 +223,35 @@ index 8cc41da23d0..70a9628320f 100644 + } *entry_it = Entry(i, k, dp * ratio); } - } \ No newline at end of file + } +@@ -1133,7 +1139,8 @@ void Hierarchy::propagateConstraints() { + auto& COw = mCOw[l]; + auto& COw_next = mCOw[l + 1]; + auto& toUpper = mToUpper[l]; +- MatrixXd& S = mS[l]; ++ // FIXME ++ // MatrixXd& S = mS[l]; + + for (uint32_t i = 0; i != mV[l + 1].cols(); ++i) { + Vector2i upper = toUpper.col(i); +diff --git a/extern/quadriflow/src/loader.cpp b/extern/quadriflow/src/loader.cpp +index aa27066e6e4..5b9d717db71 100644 +--- a/extern/quadriflow/src/loader.cpp ++++ b/extern/quadriflow/src/loader.cpp +@@ -8,6 +8,7 @@ + + #include "loader.hpp" + ++#include + #include + #include + +@@ -69,7 +70,7 @@ void load(const char* filename, MatrixXd& V, MatrixXi& F) + }; + + /// Hash function for obj_vertex +- struct obj_vertexHash : std::unary_function { ++ struct obj_vertexHash { + std::size_t operator()(const obj_vertex &v) const { + size_t hash = std::hash()(v.p); + hash = hash * 37 + std::hash()(v.uv); From 9cdbb72c1adf037dc819f84917757a72be9bae8d Mon Sep 17 00:00:00 2001 From: T0MIS0N Date: Wed, 22 Jan 2025 08:29:48 +0100 Subject: [PATCH 09/46] Fix #132643: Deleting Color Ramp's penultimate stop doesn't update the Color Ramp This bug occurs when the user deletes the rightmost stop on a color ramp with 2 stops. After doing this, the color ramp appears to stop updating its results. This bug is due to a shader optimization for color ramps. For ramps with 2 stops or less, the first and second stops are hardcoded as inputs to get the results of the color ramp. When deleting the rightmost stop, the stop's data isn't actually changed. The ramp just updates its total stop number. Because of this, the result of the color ramp won't change. This is fixed by only allowing this optimization when a ramp has exactly 2 stops. This solution works well since it keeps color ramp code neat and concise. It also makes more logical sense to only allow this optimization to work with 2 stops since it uses 2 hardcoded values from the color ramp. It's also unlikely this will lead to adverse performance problems since it doesn't make sense to use a color ramp with 1 color stop. In that case, the user should just use an RGB node. Another possible solution for this problem would be to update the data for the second stop in the color ramp to exactly match the first when deleting the second stop. However, this is undesirable since the code wouldn't make much sense to those who don't know about the color ramp optimizations. Pull Request: https://projects.blender.org/blender/blender/pulls/132951 --- source/blender/nodes/shader/nodes/node_shader_color_ramp.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc index 25f5a4b9b2f..a7fbd6639de 100644 --- a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc @@ -50,7 +50,10 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, int size; /* Common / easy case optimization. */ - if ((coba->tot <= 2) && (coba->color_mode == COLBAND_BLEND_RGB)) { + if (coba->tot == 1) { + return GPU_link(mat, "set_rgba", GPU_uniform(&coba->data[0].r), &out[0].link); + } + else if ((coba->tot == 2) && (coba->color_mode == COLBAND_BLEND_RGB)) { float mul_bias[2]; switch (coba->ipotype) { case COLBAND_INTERP_LINEAR: From 820f261371c78a62c49b50b03ef833f1f72b4560 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 14 Dec 2024 17:32:49 +0100 Subject: [PATCH 10/46] Refactor: Replace Boost Locale for translation Use code adapted from boost::locale to implement locale name parsing and .mo file reading ourselves. Together with #132142 this removes the last direct Blender dependency on Boost. Pull Request: https://projects.blender.org/blender/blender/pulls/133347 --- CMakeLists.txt | 1 - .../cmake/platform/platform_apple.cmake | 7 +- .../cmake/platform/platform_unix.cmake | 3 - .../cmake/platform/platform_win32.cmake | 10 +- doc/license/Boost-license.txt | 23 + doc/license/SPDX-license-identifiers.txt | 1 + intern/locale/CMakeLists.txt | 28 +- intern/locale/blender_locale.cpp | 100 ++++ ...oost_locale_wrapper.h => blender_locale.h} | 0 intern/locale/boost_locale_wrapper.cpp | 136 ----- intern/locale/messages.cpp | 554 ++++++++++++++++++ intern/locale/messages.h | 44 ++ .../{osx_user_locale.mm => messages_apple.mm} | 19 +- .../blentranslation/intern/blt_lang.cc | 2 +- .../blentranslation/intern/blt_translation.cc | 2 +- 15 files changed, 746 insertions(+), 184 deletions(-) create mode 100644 doc/license/Boost-license.txt create mode 100644 intern/locale/blender_locale.cpp rename intern/locale/{boost_locale_wrapper.h => blender_locale.h} (100%) delete mode 100644 intern/locale/boost_locale_wrapper.cpp create mode 100644 intern/locale/messages.cpp create mode 100644 intern/locale/messages.h rename intern/locale/{osx_user_locale.mm => messages_apple.mm} (74%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe942083e76..5a9061d06ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1277,7 +1277,6 @@ set_and_warn_dependency(WITH_PYTHON WITH_MOD_FLUID OFF) # enable boost for cycles, audaspace or i18n # otherwise if the user disabled -set_and_warn_dependency(WITH_BOOST WITH_INTERNATIONAL OFF) set_and_warn_dependency(WITH_BOOST WITH_OPENVDB OFF) set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF) set_and_warn_dependency(WITH_BOOST WITH_USD OFF) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 814f0abb705..7d6f0cdde7d 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -256,9 +256,6 @@ if(WITH_BOOST) set(Boost_ROOT ${LIBDIR}/boost) set(Boost_NO_SYSTEM_PATHS ON) set(_boost_FIND_COMPONENTS) - if(WITH_INTERNATIONAL) - list(APPEND _boost_FIND_COMPONENTS locale) - endif() if(WITH_USD AND USD_PYTHON_SUPPORT) list(APPEND _boost_FIND_COMPONENTS python${PYTHON_VERSION_NO_DOTS}) endif() @@ -280,8 +277,8 @@ if(WITH_BOOST) endif() add_bundled_libraries(boost/lib) -if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG) - string(APPEND PLATFORM_LINKFLAGS " -liconv") # boost_locale and ffmpeg needs it ! +if(WITH_CODEC_FFMPEG) + string(APPEND PLATFORM_LINKFLAGS " -liconv") # ffmpeg needs it ! endif() if(WITH_PUGIXML) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 25bd6c3a631..66dee945388 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -472,9 +472,6 @@ if(WITH_BOOST) endif() set(Boost_USE_MULTITHREADED ON) set(__boost_packages) - if(WITH_INTERNATIONAL) - list(APPEND __boost_packages locale) - endif() if(WITH_USD AND USD_PYTHON_SUPPORT) list(APPEND __boost_packages python${PYTHON_VERSION_NO_DOTS}) endif() diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 4564ac2b075..1f1d8c926a5 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -680,9 +680,7 @@ if(NOT WITH_WINDOWS_FIND_MODULES) endif() if(WITH_BOOST) - if(WITH_INTERNATIONAL) - list(APPEND boost_extra_libs locale) - endif() + set(boost_extra_libs) set(Boost_USE_STATIC_RUNTIME ON) # prefix lib set(Boost_USE_MULTITHREADED ON) # suffix -mt set(Boost_USE_STATIC_LIBS ON) # suffix -s @@ -707,12 +705,6 @@ if(WITH_BOOST) ) endif() endif() - if(WITH_INTERNATIONAL) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_locale-${BOOST_POSTFIX}.lib - debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_locale-${BOOST_DEBUG_POSTFIX}.lib - ) - endif() else() # we found boost using find_package set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) set(BOOST_LIBRARIES ${Boost_LIBRARIES}) diff --git a/doc/license/Boost-license.txt b/doc/license/Boost-license.txt new file mode 100644 index 00000000000..36b7cd93cdf --- /dev/null +++ b/doc/license/Boost-license.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/doc/license/SPDX-license-identifiers.txt b/doc/license/SPDX-license-identifiers.txt index 62aa0bbb4cd..c63ed010b44 100644 --- a/doc/license/SPDX-license-identifiers.txt +++ b/doc/license/SPDX-license-identifiers.txt @@ -3,6 +3,7 @@ Corresponding SPDX license identifiers in the source code: Apache-2.0 Apache-2-license.txt https://spdx.org/licenses/Apache-2.0.html BSD-2-Clause BSD-2-Clause-license.txt https://spdx.org/licenses/BSD-2-Clause.html BSD-3-Clause BSD-3-Clause-license.txt https://spdx.org/licenses/BSD-3-Clause.html +BSL-1.0 Boost-license.txt https://spdx.org/licenses/BSL-1.0.html GPL-2.0-or-later GPL-license.txt https://spdx.org/licenses/GPL-2.0-or-later.html GPL-3.0-or-later GPL3-license.txt https://spdx.org/licenses/GPL-3.0-or-later.html LGPL-2.1-or-later LGPL2.1-license.txt https://spdx.org/licenses/LGPL-2.1-or-later.html diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt index 06587b36218..5c69a3242d5 100644 --- a/intern/locale/CMakeLists.txt +++ b/intern/locale/CMakeLists.txt @@ -10,26 +10,22 @@ set(INC_SYS ) set(SRC - boost_locale_wrapper.cpp + blender_locale.cpp + messages.cpp - boost_locale_wrapper.h + blender_locale.h + messages.h ) set(LIB + PRIVATE bf::blenlib + PRIVATE bf::intern::guardedalloc ) -if(WIN32) - # This is set in platform_win32.cmake, will exist for 3.4+ library - # folders which are dynamic, but not for 3.3 which will be static. - if(EXISTS ${BOOST_34_TRIGGER_FILE}) - add_definitions(-DBOOST_ALL_DYN_LINK=1) - endif() -endif() - if(APPLE) # Cocoa code to read the locale on OSX list(APPEND SRC - osx_user_locale.mm + messages_apple.mm ) endif() @@ -41,14 +37,4 @@ if(WITH_GHOST_SDL) add_definitions(-DWITH_GHOST_SDL) endif() -if(WITH_INTERNATIONAL) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) - add_definitions(${BOOST_DEFINITIONS}) -endif() - blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/intern/locale/blender_locale.cpp b/intern/locale/blender_locale.cpp new file mode 100644 index 00000000000..b67bb6f7ad5 --- /dev/null +++ b/intern/locale/blender_locale.cpp @@ -0,0 +1,100 @@ +/* SPDX-FileCopyrightText: 2012 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup intern_locale + */ + +#include + +#include "blender_locale.h" +#include "messages.h" + +static std::string messages_path; +static std::string default_domain; +static std::string locale_str; + +/* NOTE: We cannot use short stuff like `boost::locale::gettext`, because those return + * `std::basic_string` objects, which c_ptr()-returned char* is no more valid + * once deleted (which happens as soons they are out of scope of this func). */ +static std::locale locale_global; +static blender::locale::MessageFacet const *facet_global = nullptr; + +static void bl_locale_global_cache() +{ + /* Cache facet in global variable. Not only is it better for performance, + * it also fixes crashes on macOS when doing translation from threads other + * than main. Likely because of some internal thread local variables. */ + try { + /* facet_global reference is valid as long as local_global exists, + * so we store both. */ + locale_global = std::locale(); + facet_global = &std::use_facet(locale_global); + } + // TODO: verify it's not installed for C case + /* `if std::has_facet(l) == false`, LC_ALL = "C" case. */ + catch (const std::bad_cast &e) { +#ifndef NDEBUG + std::cout << "bl_locale_global_cache:" << e.what() << " \n"; +#endif + (void)e; + facet_global = nullptr; + } + catch (const std::exception &e) { +#ifndef NDEBUG + std::cout << "bl_locale_global_cache:" << e.what() << " \n"; +#endif + (void)e; + facet_global = nullptr; + } +} + +void bl_locale_init(const char *_messages_path, const char *_default_domain) +{ + /* TODO: Do we need to modify locale for other things like numeric or time? + * And if so, do we need to set it to "C", or to the chosen language? */ + messages_path = _messages_path; + default_domain = _default_domain; +} + +void bl_locale_set(const char *locale_name) +{ + /* Get locale name from system if not specified. */ + std::string locale_full_name = locale_name ? locale_name : ""; + + try { + /* Retrieve and parse full locale name. */ + blender::locale::Info info(locale_full_name); + + /* Load .mo file for locale. */ + std::locale _locale = blender::locale::MessageFacet::install( + std::locale(), info, {default_domain}, {messages_path}); + std::locale::global(_locale); + + bl_locale_global_cache(); + + /* Generate the locale string, to known which one is used in case of default locale. */ + locale_str = info.to_full_name(); + } + catch (std::exception const &e) { + std::cout << "bl_locale_set(" << locale_full_name << "): " << e.what() << " \n"; + } +} + +const char *bl_locale_get(void) +{ + return locale_str.c_str(); +} + +const char *bl_locale_pgettext(const char *msgctxt, const char *msgid) +{ + if (facet_global) { + char const *r = facet_global->translate(0, msgctxt, msgid); + if (r) { + return r; + } + } + + return msgid; +} diff --git a/intern/locale/boost_locale_wrapper.h b/intern/locale/blender_locale.h similarity index 100% rename from intern/locale/boost_locale_wrapper.h rename to intern/locale/blender_locale.h diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp deleted file mode 100644 index 97bef248aac..00000000000 --- a/intern/locale/boost_locale_wrapper.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* SPDX-FileCopyrightText: 2012 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup intern_locale - */ - -#include -#include -#include - -#include "boost_locale_wrapper.h" - -static std::string messages_path; -static std::string default_domain; -static std::string locale_str; - -/* NOTE: We cannot use short stuff like `boost::locale::gettext`, because those return - * `std::basic_string` objects, which c_ptr()-returned char* is no more valid - * once deleted (which happens as soons they are out of scope of this func). */ -typedef boost::locale::message_format char_message_facet; -static std::locale locale_global; -static char_message_facet const *facet_global = NULL; - -static void bl_locale_global_cache() -{ - /* Cache facet in global variable. Not only is it better for performance, - * it also fixes crashes on macOS when doing translation from threads other - * than main. Likely because of some internal thread local variables. */ - try { - /* facet_global reference is valid as long as local_global exists, - * so we store both. */ - locale_global = std::locale(); - facet_global = &std::use_facet(locale_global); - } - /* `if std::has_facet(l) == false`, LC_ALL = "C" case. */ - catch (const std::bad_cast &e) { -#ifndef NDEBUG - std::cout << "bl_locale_global_cache:" << e.what() << " \n"; -#endif - (void)e; - facet_global = NULL; - } - catch (const std::exception &e) { -#ifndef NDEBUG - std::cout << "bl_locale_global_cache:" << e.what() << " \n"; -#endif - (void)e; - facet_global = NULL; - } -} - -void bl_locale_init(const char *_messages_path, const char *_default_domain) -{ - /* Avoid using ICU backend, we do not need its power and it's rather heavy! */ - boost::locale::localization_backend_manager lman = - boost::locale::localization_backend_manager::global(); -#if defined(_WIN32) - lman.select("winapi"); -#else - lman.select("posix"); -#endif - boost::locale::localization_backend_manager::global(lman); - - messages_path = _messages_path; - default_domain = _default_domain; -} - -void bl_locale_set(const char *locale) -{ - boost::locale::generator gen; - std::locale _locale; - /* Specify location of dictionaries. */ - gen.add_messages_path(messages_path); - gen.add_messages_domain(default_domain); - // gen.set_default_messages_domain(default_domain); - - try { - if (locale && locale[0]) { - _locale = gen(locale); - } - else { -#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) - std::string locale_osx = osx_user_locale() + std::string(".UTF-8"); - _locale = gen(locale_osx.c_str()); -#else - _locale = gen(""); -#endif - } - std::locale::global(_locale); - /* NOTE: boost always uses "C" LC_NUMERIC by default! */ - - bl_locale_global_cache(); - - /* Generate the locale string - * (useful to know which locale we are actually using in case of "default" one). */ -#define LOCALE_INFO std::use_facet(_locale) - - locale_str = LOCALE_INFO.language(); - if (LOCALE_INFO.country() != "") { - locale_str += "_" + LOCALE_INFO.country(); - } - if (LOCALE_INFO.variant() != "") { - locale_str += "@" + LOCALE_INFO.variant(); - } - -#undef LOCALE_INFO - } - /* Extra catch on `std::runtime_error` is needed for macOS/Clang as it seems that exceptions - * like `boost::locale::conv::conversion_error` (which inherit from `std::runtime_error`) are - * not caught by their ancestor `std::exception`. See #88877#1177108 */ - catch (std::runtime_error const &e) { - std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n"; - } - catch (std::exception const &e) { - std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n"; - } -} - -const char *bl_locale_get(void) -{ - return locale_str.c_str(); -} - -const char *bl_locale_pgettext(const char *msgctxt, const char *msgid) -{ - if (facet_global) { - char const *r = facet_global->get(0, msgctxt, msgid); - if (r) { - return r; - } - } - - return msgid; -} diff --git a/intern/locale/messages.cpp b/intern/locale/messages.cpp new file mode 100644 index 00000000000..202b55a3445 --- /dev/null +++ b/intern/locale/messages.cpp @@ -0,0 +1,554 @@ +/* SPDX-FileCopyrightText: 2009-2015 Artyom Beilis (Tonkikh) + * SPDX-FileCopyrightText: 2021-2023 Alexander Grund + * SPDX-FileCopyrightText: 2025 Blender Authors + * SPDX-License-Identifier: BSL-1.0 + * + * Adapted from boost::locale */ + +#include "messages.h" + +#include +#include +#include +#include +#include +#include + +#include "BLI_assert.h" +#include "BLI_fileops.h" +#include "BLI_hash.hh" +#include "BLI_map.hh" +#include "BLI_path_utils.hh" +#include "BLI_string_ref.hh" +#include "BLI_vector.hh" + +#ifdef _WIN32 +# include "BLI_winstuff.h" +#endif + +namespace blender::locale { + +/* Upper/lower case, intentionally restricted to ASCII. */ + +static constexpr bool is_upper_ascii(const char c) +{ + return 'A' <= c && c <= 'Z'; +} + +static constexpr bool is_lower_ascii(const char c) +{ + return 'a' <= c && c <= 'z'; +} + +static bool make_lower_ascii(char &c) +{ + if (is_upper_ascii(c)) { + c += 'a' - 'A'; + return true; + } + return false; +} + +static bool make_upper_ascii(char &c) +{ + if (is_lower_ascii(c)) { + c += 'A' - 'a'; + return true; + } + return false; +} + +static constexpr bool is_numeric_ascii(const char c) +{ + return '0' <= c && c <= '9'; +} + +/* Locale parsing. */ + +static bool parse_from_variant(Info &info, const std::string_view input) +{ + if (info.language == "C" || input.empty()) { + return false; + } + info.variant = input; + /* No assumptions, just make it lowercase. */ + for (char &c : info.variant) { + make_lower_ascii(c); + } + return true; +} + +static bool parse_from_encoding(Info &info, const std::string_view input) +{ + const auto end = input.find_first_of('@'); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + /* tmp contains encoding, we ignore it. */ + if (end >= input.size()) { + return true; + } + BLI_assert(input[end] == '@'); + return parse_from_variant(info, input.substr(end + 1)); +} + +static bool parse_from_country(Info &info, const std::string_view input) +{ + if (info.language == "C") { + return false; + } + + const auto end = input.find_first_of("@."); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + + for (char &c : tmp) { + make_upper_ascii(c); + } + + /* If it's ALL uppercase ASCII, assume ISO 3166 country id. */ + if (std::find_if_not(tmp.begin(), tmp.end(), is_upper_ascii) != tmp.end()) { + /* else handle special cases: + * - en_US_POSIX is an alias for C + * - M49 country code: 3 digits */ + if (info.language == "en" && tmp == "US_POSIX") { + info.language = "C"; + tmp.clear(); + } + else if (tmp.size() != 3u || + std::find_if_not(tmp.begin(), tmp.end(), is_numeric_ascii) != tmp.end()) + { + return false; + } + } + + info.country = tmp; + if (end >= input.size()) { + return true; + } + if (input[end] == '.') { + return parse_from_encoding(info, input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(info, input.substr(end + 1)); +} + +static bool parse_from_script(Info &info, const std::string_view input) +{ + const auto end = input.find_first_of("-_@."); + std::string tmp(input.substr(0, end)); + /* Script is exactly 4 ASCII characters, otherwise it is not present. */ + if (tmp.length() != 4) { + return parse_from_country(info, input); + } + + for (char &c : tmp) { + if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + return parse_from_country(info, input); + } + } + make_upper_ascii(tmp[0]); /* Capitalize first letter only. */ + info.script = tmp; + + if (end >= input.size()) { + return true; + } + if (input[end] == '-' || input[end] == '_') { + return parse_from_country(info, input.substr(end + 1)); + } + if (input[end] == '.') { + return parse_from_encoding(info, input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(info, input.substr(end + 1)); +} + +static bool parse_from_lang(Info &info, const std::string_view input) +{ + const auto end = input.find_first_of("-_@."); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + for (char &c : tmp) { + if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + return false; + } + } + if (tmp != "c" && tmp != "posix") { /* Keep default if C or POSIX. */ + info.language = tmp; + } + + if (end >= input.size()) { + return true; + } + if (input[end] == '-' || input[end] == '_') { + return parse_from_script(info, input.substr(end + 1)); + } + if (input[end] == '.') { + return parse_from_encoding(info, input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(info, input.substr(end + 1)); +} + +/* Info about a locale. */ + +Info::Info(const StringRef locale_full_name) +{ + std::string locale_name(locale_full_name); + + /* If locale name not specified, try to get the appropriate one from the system. */ +#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) + if (locale_name.empty()) { + locale_name = macos_user_locale(); + } +#endif + + if (locale_name.empty()) { + const char *lc_all = BLI_getenv("LC_ALL"); + if (lc_all) { + locale_name = lc_all; + } + } + if (locale_name.empty()) { + const char *lang = BLI_getenv("LANG"); + if (lang) { + locale_name = lang; + } + } + +#ifdef _WIN32 + if (locale_name.empty()) { + char buf[128] = {}; + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, sizeof(buf)) != 0) { + locale_name = buf; + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf, sizeof(buf)) != 0) { + locale_name += "_"; + locale_name += buf; + } + } + } +#endif + + parse_from_lang(*this, locale_name); +} + +std::string Info::to_full_name() const +{ + std::string result = language; + if (!script.empty()) { + result += '_' + script; + } + if (!country.empty()) { + result += '_' + country; + } + if (!variant.empty()) { + result += '@' + variant; + } + return result; +} + +/* .mo file reader. */ + +class MOFile { + uint32_t keys_offset_ = 0; + uint32_t translations_offset_ = 0; + + Vector data_; + bool native_byteorder_ = false; + size_t size_ = false; + + std::string error_; + + public: + MOFile(const std::string &filepath) + { + FILE *file = BLI_fopen(filepath.c_str(), "rb"); + if (!file) { + return; + } + + fseek(file, 0, SEEK_END); + const int64_t len = BLI_ftell(file); + if (len >= 0) { + fseek(file, 0, SEEK_SET); + data_.resize(len); + if (fread(data_.data(), 1, len, file) != len) { + data_.clear(); + error_ = "Failed to read file"; + } + } + else { + error_ = "Wrong file object"; + } + + fclose(file); + + if (error_.empty()) { + read_data(); + } + } + + const char *key(int id) + { + const uint32_t off = get(keys_offset_ + id * 8 + 4); + return data_.data() + off; + } + + StringRef value(int id) + { + const uint32_t len = get(translations_offset_ + id * 8); + const uint32_t off = get(translations_offset_ + id * 8 + 4); + if (len > data_.size() || off > data_.size() - len) { + error_ = "Bad mo-file format"; + return ""; + } + return StringRef(&data_[off], len); + } + + size_t size() const + { + return size_; + } + + bool empty() const + { + return size_ == 0; + } + + const std::string &error() const + { + return error_; + } + + private: + void read_data() + { + if (data_.size() < 4) { + error_ = "Invalid 'mo' file format - the file is too short"; + return; + } + + uint32_t magic; + memcpy(&magic, data_.data(), sizeof(magic)); + if (magic == 0x950412de) { + native_byteorder_ = true; + } + else if (magic == 0xde120495) { + native_byteorder_ = false; + } + else { + error_ = "Invalid file format - invalid magic number"; + return; + } + + // Read all format sizes + size_ = get(8); + keys_offset_ = get(12); + translations_offset_ = get(16); + } + + uint32_t get(int offset) + { + if (offset > data_.size() - 4) { + error_ = "Bad mo-file format"; + return 0; + } + uint32_t v; + memcpy(&v, &data_[offset], 4); + if (!native_byteorder_) { + v = ((v & 0xFF) << 24) | ((v & 0xFF00) << 8) | ((v & 0xFF0000) >> 8) | + ((v & 0xFF000000) >> 24); + } + + return v; + } +}; + +/* Message lookup key. */ + +struct MessageKeyRef { + StringRef context_; + StringRef str_; + + uint64_t hash() const + { + return get_default_hash(context_, str_); + } +}; + +struct MessageKey { + std::string context_; + std::string str_; + + MessageKey(const StringRef c) + { + const size_t pos = c.find(char(4)); + if (pos == StringRef::not_found) { + str_ = c; + } + else { + context_ = c.substr(0, pos); + str_ = c.substr(pos + 1); + } + } + + uint64_t hash() const + { + return get_default_hash(context_, str_); + } + + static uint64_t hash_as(const MessageKeyRef &key) + { + return key.hash(); + } +}; + +inline bool operator==(const MessageKey &a, const MessageKey &b) +{ + return a.context_ == b.context_ && a.str_ == b.str_; +} + +inline bool operator==(const MessageKeyRef &a, const MessageKey &b) +{ + return a.context_ == b.context_ && a.str_ == b.str_; +} + +/* std::locale facet for translation based on .mo files. */ + +class MOMessageFacet : public MessageFacet { + using Catalog = Map; + Vector catalogs_; + std::string error_; + + public: + MOMessageFacet(const Info &info, + const Vector &domains, + const Vector &paths) + { + const Vector catalog_paths = get_catalog_paths(info, paths); + for (size_t i = 0; i < domains.size(); i++) { + const std::string &domain_name = domains[i]; + const std::string filename = domain_name + ".mo"; + Catalog catalog; + for (const std::string &path : catalog_paths) { + if (load_file(path + "/" + filename, catalog)) { + break; + } + } + catalogs_.append(std::move(catalog)); + } + } + + const char *translate(const int domain, + const StringRef context, + const StringRef str) const override + { + if (domain < 0 || domain >= catalogs_.size()) { + return nullptr; + } + const MessageKeyRef key{context, str}; + const std::string *result = catalogs_[domain].lookup_ptr_as(key); + return (result) ? result->c_str() : nullptr; + } + + const std::string &error() + { + return error_; + } + + private: + Vector get_catalog_paths(const Info &info, const Vector &paths) + { + /* Find language folders. */ + Vector lang_folders; + if (!info.language.empty()) { + if (!info.variant.empty() && !info.country.empty()) { + lang_folders.append(info.language + "_" + info.country + "@" + info.variant); + } + if (!info.variant.empty()) { + lang_folders.append(info.language + "@" + info.variant); + } + if (!info.country.empty()) { + lang_folders.append(info.language + "_" + info.country); + } + lang_folders.append(info.language); + } + + /* Find catalogs in language folders. */ + Vector result; + result.reserve(lang_folders.size() * paths.size()); + for (const std::string &lang_folder : lang_folders) { + for (const std::string &search_path : paths) { + result.append(search_path + "/" + lang_folder + "/LC_MESSAGES"); + } + } + return result; + } + + bool load_file(const std::string &filepath, Catalog &catalog) + { + MOFile mo(filepath); + if (!mo.error().empty()) { + error_ = mo.error(); + return false; + } + if (mo.empty()) { + return false; + } + + /* Only support UTF-8 encoded files, as created by our msgfmt tool. */ + const std::string mo_encoding = extract(mo.value(0), "charset=", " \r\n;"); + if (mo_encoding.empty()) { + error_ = "Invalid mo-format, encoding is not specified"; + return false; + } + if (mo_encoding != "UTF-8") { + error_ = "supported mo-format, encoding must be UTF-8"; + return false; + } + + /* Create context + key to translated string mapping. */ + for (size_t i = 0; i < mo.size(); i++) { + const MessageKey key(mo.key(i)); + catalog.add(std::move(key), std::string(mo.value(i))); + } + + return true; + } + + static std::string extract(StringRef meta, const std::string &key, const StringRef separators) + { + const size_t pos = meta.find(key); + if (pos == StringRef::not_found) { + return ""; + } + meta = meta.substr(pos + key.size()); + const size_t end_pos = meta.find_first_of(separators); + return std::string(meta.substr(0, end_pos)); + } +}; + +/* Install facet into std::locale. */ + +std::locale::id MessageFacet::id; + +std::locale MessageFacet::install(const std::locale &locale, + const Info &info, + const Vector &domains, + const Vector &paths) +{ + MOMessageFacet *facet = new MOMessageFacet(info, domains, paths); + if (!facet->error().empty()) { + throw std::runtime_error(facet->error()); + return locale; + } + + return std::locale(locale, facet); +} + +} // namespace blender::locale diff --git a/intern/locale/messages.h b/intern/locale/messages.h new file mode 100644 index 00000000000..3a0f933406b --- /dev/null +++ b/intern/locale/messages.h @@ -0,0 +1,44 @@ +/* SPDX-FileCopyrightText: 2025 Blender Authors + * SPDX-License-Identifier: BSL-1.0 + * + * Adapted from boost::locale */ + +#include +#include + +#include "BLI_string_ref.hh" +#include "BLI_vector.hh" + +namespace blender::locale { + +/* Info about a locale. */ +struct Info { + Info(const StringRef locale_full_name); + + std::string language = "C"; + std::string script; + std::string country; + std::string variant; + + std::string to_full_name() const; + +#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) + static std::string macos_user_locale(); +#endif +}; + +/* Message facet to install into std::locale for translation. */ +class MessageFacet : public std::locale::facet { + public: + static std::locale::id id; + static std::locale install(const std::locale &locale, + const Info &info, + const Vector &domains, /* Application names. */ + const Vector &paths); /* Search paths for .mo files. */ + + virtual const char *translate(const int domain, + const StringRef context, + const StringRef key) const = 0; +}; + +} // namespace blender::locale diff --git a/intern/locale/osx_user_locale.mm b/intern/locale/messages_apple.mm similarity index 74% rename from intern/locale/osx_user_locale.mm rename to intern/locale/messages_apple.mm index 5d1be240f44..c24b9777163 100644 --- a/intern/locale/osx_user_locale.mm +++ b/intern/locale/messages_apple.mm @@ -2,22 +2,24 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "boost_locale_wrapper.h" - /** \file * \ingroup intern_locale */ +#include "messages.h" + #import #include +#include -static char *user_locale = nullptr; +namespace blender::locale { +#if !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) /* Get current locale. */ -const char *osx_user_locale() +std::string Info::macos_user_locale() { - ::free(user_locale); + std::string result; @autoreleasepool { CFLocaleRef myCFLocale = CFLocaleCopyCurrent(); @@ -34,8 +36,11 @@ nsIdentifier = [NSString stringWithFormat:@"%@_%@", nsIdentifier, nsIdentifier_country]; } - user_locale = ::strdup(nsIdentifier.UTF8String); + result = nsIdentifier.UTF8String; } - return user_locale; + return result + ".UTF-8"; } +#endif + +} // namespace blender::locale diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index 3fe958b78c3..90142e1197b 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -38,7 +38,7 @@ # include "BLI_fileops.h" # include "BLI_linklist.h" -# include "boost_locale_wrapper.h" +# include "blender_locale.h" /* Locale options. */ static const char **locales = nullptr; diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index bfe76f7f03c..cbc9fe65b50 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -24,7 +24,7 @@ #ifdef WITH_INTERNATIONAL # include "BLI_threads.h" -# include "boost_locale_wrapper.h" +# include "blender_locale.h" #endif /* WITH_INTERNATIONAL */ bool BLT_is_default_context(const char *msgctxt) From 860bfd786e3a0c974be9a38ba88070e400ea3873 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Jan 2025 08:07:44 +0100 Subject: [PATCH 11/46] Refactor: Don't modify std::locale::global for translation Without boost::locale, there seems no particular reason to modify the global locale, we can just translate strings ourselves. Other locale facets like numeric and time are also left unchanged from the default, which is the "C" locale. This appears to match previous Blender behavior with boost::locale. That protects against bugs where formatting floats for I/O unexpectedly depends on the system language. Pull Request: https://projects.blender.org/blender/blender/pulls/133347 --- intern/locale/blender_locale.cpp | 74 +--- intern/locale/blender_locale.h | 1 + intern/locale/messages.cpp | 381 ++++++++++-------- intern/locale/messages.h | 33 +- intern/locale/messages_apple.mm | 2 +- .../blentranslation/intern/blt_lang.cc | 2 +- 6 files changed, 227 insertions(+), 266 deletions(-) diff --git a/intern/locale/blender_locale.cpp b/intern/locale/blender_locale.cpp index b67bb6f7ad5..4dfc69e4793 100644 --- a/intern/locale/blender_locale.cpp +++ b/intern/locale/blender_locale.cpp @@ -6,8 +6,6 @@ * \ingroup intern_locale */ -#include - #include "blender_locale.h" #include "messages.h" @@ -15,71 +13,27 @@ static std::string messages_path; static std::string default_domain; static std::string locale_str; -/* NOTE: We cannot use short stuff like `boost::locale::gettext`, because those return - * `std::basic_string` objects, which c_ptr()-returned char* is no more valid - * once deleted (which happens as soons they are out of scope of this func). */ -static std::locale locale_global; -static blender::locale::MessageFacet const *facet_global = nullptr; - -static void bl_locale_global_cache() -{ - /* Cache facet in global variable. Not only is it better for performance, - * it also fixes crashes on macOS when doing translation from threads other - * than main. Likely because of some internal thread local variables. */ - try { - /* facet_global reference is valid as long as local_global exists, - * so we store both. */ - locale_global = std::locale(); - facet_global = &std::use_facet(locale_global); - } - // TODO: verify it's not installed for C case - /* `if std::has_facet(l) == false`, LC_ALL = "C" case. */ - catch (const std::bad_cast &e) { -#ifndef NDEBUG - std::cout << "bl_locale_global_cache:" << e.what() << " \n"; -#endif - (void)e; - facet_global = nullptr; - } - catch (const std::exception &e) { -#ifndef NDEBUG - std::cout << "bl_locale_global_cache:" << e.what() << " \n"; -#endif - (void)e; - facet_global = nullptr; - } -} - void bl_locale_init(const char *_messages_path, const char *_default_domain) { - /* TODO: Do we need to modify locale for other things like numeric or time? - * And if so, do we need to set it to "C", or to the chosen language? */ messages_path = _messages_path; default_domain = _default_domain; } +void bl_locale_free() +{ + blender::locale::free(); +} + void bl_locale_set(const char *locale_name) { /* Get locale name from system if not specified. */ std::string locale_full_name = locale_name ? locale_name : ""; - try { - /* Retrieve and parse full locale name. */ - blender::locale::Info info(locale_full_name); - - /* Load .mo file for locale. */ - std::locale _locale = blender::locale::MessageFacet::install( - std::locale(), info, {default_domain}, {messages_path}); - std::locale::global(_locale); + /* Initialize and load .mo file for locale. */ + blender::locale::init(locale_full_name, {default_domain}, {messages_path}); - bl_locale_global_cache(); - - /* Generate the locale string, to known which one is used in case of default locale. */ - locale_str = info.to_full_name(); - } - catch (std::exception const &e) { - std::cout << "bl_locale_set(" << locale_full_name << "): " << e.what() << " \n"; - } + /* Generate the locale string, to known which one is used in case of default locale. */ + locale_str = blender::locale::full_name(); } const char *bl_locale_get(void) @@ -89,12 +43,6 @@ const char *bl_locale_get(void) const char *bl_locale_pgettext(const char *msgctxt, const char *msgid) { - if (facet_global) { - char const *r = facet_global->translate(0, msgctxt, msgid); - if (r) { - return r; - } - } - - return msgid; + const char *r = blender::locale::translate(0, msgctxt, msgid); + return (r) ? r : msgid; } diff --git a/intern/locale/blender_locale.h b/intern/locale/blender_locale.h index 162f1eca968..d45b666da2a 100644 --- a/intern/locale/blender_locale.h +++ b/intern/locale/blender_locale.h @@ -16,6 +16,7 @@ extern "C" { void bl_locale_init(const char *messages_path, const char *default_domain); void bl_locale_set(const char *locale); +void bl_locale_free(void); const char *bl_locale_get(void); const char *bl_locale_pgettext(const char *msgctxt, const char *msgid); diff --git a/intern/locale/messages.cpp b/intern/locale/messages.cpp index 202b55a3445..bcbc541faff 100644 --- a/intern/locale/messages.cpp +++ b/intern/locale/messages.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -63,194 +63,202 @@ static constexpr bool is_numeric_ascii(const char c) return '0' <= c && c <= '9'; } -/* Locale parsing. */ - -static bool parse_from_variant(Info &info, const std::string_view input) -{ - if (info.language == "C" || input.empty()) { - return false; - } - info.variant = input; - /* No assumptions, just make it lowercase. */ - for (char &c : info.variant) { - make_lower_ascii(c); - } - return true; -} - -static bool parse_from_encoding(Info &info, const std::string_view input) -{ - const auto end = input.find_first_of('@'); - std::string tmp(input.substr(0, end)); - if (tmp.empty()) { - return false; - } - /* tmp contains encoding, we ignore it. */ - if (end >= input.size()) { - return true; - } - BLI_assert(input[end] == '@'); - return parse_from_variant(info, input.substr(end + 1)); -} +/* Info about a locale. */ -static bool parse_from_country(Info &info, const std::string_view input) -{ - if (info.language == "C") { - return false; - } +class Info { + public: + std::string language = "C"; + std::string script; + std::string country; + std::string variant; - const auto end = input.find_first_of("@."); - std::string tmp(input.substr(0, end)); - if (tmp.empty()) { - return false; - } + Info(const StringRef locale_full_name) + { + std::string locale_name(locale_full_name); - for (char &c : tmp) { - make_upper_ascii(c); - } + /* If locale name not specified, try to get the appropriate one from the system. */ +#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) + if (locale_name.empty()) { + locale_name = macos_user_locale(); + } +#endif - /* If it's ALL uppercase ASCII, assume ISO 3166 country id. */ - if (std::find_if_not(tmp.begin(), tmp.end(), is_upper_ascii) != tmp.end()) { - /* else handle special cases: - * - en_US_POSIX is an alias for C - * - M49 country code: 3 digits */ - if (info.language == "en" && tmp == "US_POSIX") { - info.language = "C"; - tmp.clear(); - } - else if (tmp.size() != 3u || - std::find_if_not(tmp.begin(), tmp.end(), is_numeric_ascii) != tmp.end()) - { - return false; + if (locale_name.empty()) { + const char *lc_all = BLI_getenv("LC_ALL"); + if (lc_all) { + locale_name = lc_all; + } + } + if (locale_name.empty()) { + const char *lang = BLI_getenv("LANG"); + if (lang) { + locale_name = lang; + } } - } - info.country = tmp; - if (end >= input.size()) { - return true; - } - if (input[end] == '.') { - return parse_from_encoding(info, input.substr(end + 1)); - } - BLI_assert(input[end] == '@'); - return parse_from_variant(info, input.substr(end + 1)); -} +#ifdef _WIN32 + if (locale_name.empty()) { + char buf[128] = {}; + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, sizeof(buf)) != 0) { + locale_name = buf; + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf, sizeof(buf)) != 0) { + locale_name += "_"; + locale_name += buf; + } + } + } +#endif -static bool parse_from_script(Info &info, const std::string_view input) -{ - const auto end = input.find_first_of("-_@."); - std::string tmp(input.substr(0, end)); - /* Script is exactly 4 ASCII characters, otherwise it is not present. */ - if (tmp.length() != 4) { - return parse_from_country(info, input); + parse_from_lang(locale_name); } - for (char &c : tmp) { - if (!is_lower_ascii(c) && !make_lower_ascii(c)) { - return parse_from_country(info, input); + std::string to_full_name() const + { + std::string result = language; + if (!script.empty()) { + result += '_' + script; + } + if (!country.empty()) { + result += '_' + country; + } + if (!variant.empty()) { + result += '@' + variant; } + return result; } - make_upper_ascii(tmp[0]); /* Capitalize first letter only. */ - info.script = tmp; - if (end >= input.size()) { + private: + /* Locale parsing. */ + bool parse_from_variant(const std::string_view input) + { + if (language == "C" || input.empty()) { + return false; + } + variant = input; + /* No assumptions, just make it lowercase. */ + for (char &c : variant) { + make_lower_ascii(c); + } return true; } - if (input[end] == '-' || input[end] == '_') { - return parse_from_country(info, input.substr(end + 1)); - } - if (input[end] == '.') { - return parse_from_encoding(info, input.substr(end + 1)); - } - BLI_assert(input[end] == '@'); - return parse_from_variant(info, input.substr(end + 1)); -} -static bool parse_from_lang(Info &info, const std::string_view input) -{ - const auto end = input.find_first_of("-_@."); - std::string tmp(input.substr(0, end)); - if (tmp.empty()) { - return false; - } - for (char &c : tmp) { - if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + bool parse_from_encoding(const std::string_view input) + { + const int64_t end = input.find_first_of('@'); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { return false; } - } - if (tmp != "c" && tmp != "posix") { /* Keep default if C or POSIX. */ - info.language = tmp; + /* tmp contains encoding, we ignore it. */ + if (end >= input.size()) { + return true; + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); } - if (end >= input.size()) { - return true; - } - if (input[end] == '-' || input[end] == '_') { - return parse_from_script(info, input.substr(end + 1)); - } - if (input[end] == '.') { - return parse_from_encoding(info, input.substr(end + 1)); - } - BLI_assert(input[end] == '@'); - return parse_from_variant(info, input.substr(end + 1)); -} + bool parse_from_country(const std::string_view input) + { + if (language == "C") { + return false; + } -/* Info about a locale. */ + const int64_t end = input.find_first_of("@."); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } -Info::Info(const StringRef locale_full_name) -{ - std::string locale_name(locale_full_name); + for (char &c : tmp) { + make_upper_ascii(c); + } - /* If locale name not specified, try to get the appropriate one from the system. */ -#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) - if (locale_name.empty()) { - locale_name = macos_user_locale(); - } -#endif + /* If it's ALL uppercase ASCII, assume ISO 3166 country id. */ + if (std::find_if_not(tmp.begin(), tmp.end(), is_upper_ascii) != tmp.end()) { + /* else handle special cases: + * - en_US_POSIX is an alias for C + * - M49 country code: 3 digits */ + if (language == "en" && tmp == "US_POSIX") { + language = "C"; + tmp.clear(); + } + else if (tmp.size() != 3u || + std::find_if_not(tmp.begin(), tmp.end(), is_numeric_ascii) != tmp.end()) + { + return false; + } + } - if (locale_name.empty()) { - const char *lc_all = BLI_getenv("LC_ALL"); - if (lc_all) { - locale_name = lc_all; + country = tmp; + if (end >= input.size()) { + return true; } - } - if (locale_name.empty()) { - const char *lang = BLI_getenv("LANG"); - if (lang) { - locale_name = lang; + if (input[end] == '.') { + return parse_from_encoding(input.substr(end + 1)); } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); } -#ifdef _WIN32 - if (locale_name.empty()) { - char buf[128] = {}; - if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, sizeof(buf)) != 0) { - locale_name = buf; - if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf, sizeof(buf)) != 0) { - locale_name += "_"; - locale_name += buf; + bool parse_from_script(const std::string_view input) + { + const int64_t end = input.find_first_of("-_@."); + std::string tmp(input.substr(0, end)); + /* Script is exactly 4 ASCII characters, otherwise it is not present. */ + if (tmp.length() != 4) { + return parse_from_country(input); + } + + for (char &c : tmp) { + if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + return parse_from_country(input); } } + make_upper_ascii(tmp[0]); /* Capitalize first letter only. */ + script = tmp; + + if (end >= input.size()) { + return true; + } + if (input[end] == '-' || input[end] == '_') { + return parse_from_country(input.substr(end + 1)); + } + if (input[end] == '.') { + return parse_from_encoding(input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); } -#endif - parse_from_lang(*this, locale_name); -} + bool parse_from_lang(const std::string_view input) + { + const int64_t end = input.find_first_of("-_@."); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + for (char &c : tmp) { + if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + return false; + } + } + if (tmp != "c" && tmp != "posix") { /* Keep default if C or POSIX. */ + language = tmp; + } -std::string Info::to_full_name() const -{ - std::string result = language; - if (!script.empty()) { - result += '_' + script; - } - if (!country.empty()) { - result += '_' + country; - } - if (!variant.empty()) { - result += '@' + variant; + if (end >= input.size()) { + return true; + } + if (input[end] == '-' || input[end] == '_') { + return parse_from_script(input.substr(end + 1)); + } + if (input[end] == '.') { + return parse_from_encoding(input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); } - return result; -} +}; /* .mo file reader. */ @@ -418,17 +426,17 @@ inline bool operator==(const MessageKeyRef &a, const MessageKey &b) return a.context_ == b.context_ && a.str_ == b.str_; } -/* std::locale facet for translation based on .mo files. */ +/* Messages translation based on .mo files. */ -class MOMessageFacet : public MessageFacet { +class MOMessages { using Catalog = Map; Vector catalogs_; std::string error_; public: - MOMessageFacet(const Info &info, - const Vector &domains, - const Vector &paths) + MOMessages(const Info &info, + const Vector &domains, + const Vector &paths) { const Vector catalog_paths = get_catalog_paths(info, paths); for (size_t i = 0; i < domains.size(); i++) { @@ -444,9 +452,7 @@ class MOMessageFacet : public MessageFacet { } } - const char *translate(const int domain, - const StringRef context, - const StringRef str) const override + const char *translate(const int domain, const StringRef context, const StringRef str) const { if (domain < 0 || domain >= catalogs_.size()) { return nullptr; @@ -533,22 +539,47 @@ class MOMessageFacet : public MessageFacet { } }; -/* Install facet into std::locale. */ +/* Public API */ -std::locale::id MessageFacet::id; +static std::unique_ptr global_messages; +static std::string global_full_name; -std::locale MessageFacet::install(const std::locale &locale, - const Info &info, - const Vector &domains, - const Vector &paths) +void init(const StringRef locale_full_name, + const Vector &domains, + const Vector &paths) { - MOMessageFacet *facet = new MOMessageFacet(info, domains, paths); - if (!facet->error().empty()) { - throw std::runtime_error(facet->error()); - return locale; + Info info(locale_full_name); + if (global_full_name == info.to_full_name()) { + return; } - return std::locale(locale, facet); + global_messages = std::make_unique(info, domains, paths); + global_full_name = info.to_full_name(); + + if (!global_messages->error().empty()) { + printf("bl_locale_set(%s): %s\n", global_full_name.c_str(), global_messages->error().c_str()); + free(); + } +} + +void free() +{ + global_messages.reset(); + global_full_name = ""; +} + +const char *translate(const int domain, const StringRef context, const StringRef key) +{ + if (!global_messages) { + return nullptr; + } + + return global_messages->translate(domain, context, key); +} + +const char *full_name() +{ + return global_full_name.c_str(); } } // namespace blender::locale diff --git a/intern/locale/messages.h b/intern/locale/messages.h index 3a0f933406b..916ec1bbf80 100644 --- a/intern/locale/messages.h +++ b/intern/locale/messages.h @@ -3,7 +3,6 @@ * * Adapted from boost::locale */ -#include #include #include "BLI_string_ref.hh" @@ -11,34 +10,16 @@ namespace blender::locale { -/* Info about a locale. */ -struct Info { - Info(const StringRef locale_full_name); +void init(const StringRef locale_full_name, /* Local name. */ + const Vector &domains, /* Application names. */ + const Vector &paths); /* Search paths for .mo files. */ +void free(); - std::string language = "C"; - std::string script; - std::string country; - std::string variant; - - std::string to_full_name() const; +const char *translate(const int domain, const StringRef context, const StringRef key); +const char *full_name(); #if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) - static std::string macos_user_locale(); +std::string macos_user_locale(); #endif -}; - -/* Message facet to install into std::locale for translation. */ -class MessageFacet : public std::locale::facet { - public: - static std::locale::id id; - static std::locale install(const std::locale &locale, - const Info &info, - const Vector &domains, /* Application names. */ - const Vector &paths); /* Search paths for .mo files. */ - - virtual const char *translate(const int domain, - const StringRef context, - const StringRef key) const = 0; -}; } // namespace blender::locale diff --git a/intern/locale/messages_apple.mm b/intern/locale/messages_apple.mm index c24b9777163..c818297c8c0 100644 --- a/intern/locale/messages_apple.mm +++ b/intern/locale/messages_apple.mm @@ -17,7 +17,7 @@ #if !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) /* Get current locale. */ -std::string Info::macos_user_locale() +std::string macos_user_locale() { std::string result; diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index 90142e1197b..c15db05e245 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -227,8 +227,8 @@ void BLT_lang_init() void BLT_lang_free() { #ifdef WITH_INTERNATIONAL + bl_locale_free(); free_locales(); -#else #endif } From 139f0d8c3253fcb9b201a3087c775d2e43fbfbcd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 14 Dec 2024 17:33:02 +0100 Subject: [PATCH 12/46] Refactor: Move translation handling fully into blentranslation No need to have the extra abstraction, simpler to have it together in the same module. Pull Request: https://projects.blender.org/blender/blender/pulls/133347 --- intern/CMakeLists.txt | 4 - intern/locale/CMakeLists.txt | 40 ---------- intern/locale/blender_locale.cpp | 48 ------------ intern/locale/blender_locale.h | 31 -------- source/blender/blentranslation/CMakeLists.txt | 17 +++- .../blentranslation/intern/blt_lang.cc | 77 +++++++------------ .../blentranslation/intern/blt_translation.cc | 18 ++--- .../blentranslation/intern/messages.cc | 17 +++- .../blentranslation/intern/messages.hh | 4 + .../blentranslation/intern}/messages_apple.mm | 4 +- 10 files changed, 71 insertions(+), 189 deletions(-) delete mode 100644 intern/locale/CMakeLists.txt delete mode 100644 intern/locale/blender_locale.cpp delete mode 100644 intern/locale/blender_locale.h rename intern/locale/messages.cpp => source/blender/blentranslation/intern/messages.cc (97%) rename intern/locale/messages.h => source/blender/blentranslation/intern/messages.hh (95%) rename {intern/locale => source/blender/blentranslation/intern}/messages_apple.mm (95%) diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index 16e0c11b413..bc003ef827f 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -35,10 +35,6 @@ if(WITH_CYCLES) add_subdirectory(cycles) endif() -if(WITH_INTERNATIONAL) - add_subdirectory(locale) -endif() - if(WITH_BULLET) add_subdirectory(rigidbody) endif() diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt deleted file mode 100644 index 5c69a3242d5..00000000000 --- a/intern/locale/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-FileCopyrightText: 2012 Blender Authors -# -# SPDX-License-Identifier: GPL-2.0-or-later - -set(INC - . -) - -set(INC_SYS -) - -set(SRC - blender_locale.cpp - messages.cpp - - blender_locale.h - messages.h -) - -set(LIB - PRIVATE bf::blenlib - PRIVATE bf::intern::guardedalloc -) - -if(APPLE) - # Cocoa code to read the locale on OSX - list(APPEND SRC - messages_apple.mm - ) -endif() - -if(WITH_HEADLESS) - add_definitions(-DWITH_HEADLESS) -endif() - -if(WITH_GHOST_SDL) - add_definitions(-DWITH_GHOST_SDL) -endif() - -blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/intern/locale/blender_locale.cpp b/intern/locale/blender_locale.cpp deleted file mode 100644 index 4dfc69e4793..00000000000 --- a/intern/locale/blender_locale.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-FileCopyrightText: 2012 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup intern_locale - */ - -#include "blender_locale.h" -#include "messages.h" - -static std::string messages_path; -static std::string default_domain; -static std::string locale_str; - -void bl_locale_init(const char *_messages_path, const char *_default_domain) -{ - messages_path = _messages_path; - default_domain = _default_domain; -} - -void bl_locale_free() -{ - blender::locale::free(); -} - -void bl_locale_set(const char *locale_name) -{ - /* Get locale name from system if not specified. */ - std::string locale_full_name = locale_name ? locale_name : ""; - - /* Initialize and load .mo file for locale. */ - blender::locale::init(locale_full_name, {default_domain}, {messages_path}); - - /* Generate the locale string, to known which one is used in case of default locale. */ - locale_str = blender::locale::full_name(); -} - -const char *bl_locale_get(void) -{ - return locale_str.c_str(); -} - -const char *bl_locale_pgettext(const char *msgctxt, const char *msgid) -{ - const char *r = blender::locale::translate(0, msgctxt, msgid); - return (r) ? r : msgid; -} diff --git a/intern/locale/blender_locale.h b/intern/locale/blender_locale.h deleted file mode 100644 index d45b666da2a..00000000000 --- a/intern/locale/blender_locale.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-FileCopyrightText: 2012 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup intern_locale - * A thin C wrapper around `boost::locale`. - */ - -#ifndef __BOOST_LOCALE_WRAPPER_H__ -#define __BOOST_LOCALE_WRAPPER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void bl_locale_init(const char *messages_path, const char *default_domain); -void bl_locale_set(const char *locale); -void bl_locale_free(void); -const char *bl_locale_get(void); -const char *bl_locale_pgettext(const char *msgctxt, const char *msgid); - -#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) -const char *osx_user_locale(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __BOOST_LOCALE_WRAPPER_H__ */ diff --git a/source/blender/blentranslation/CMakeLists.txt b/source/blender/blentranslation/CMakeLists.txt index 1fa3570bc27..fe0a068a1f3 100644 --- a/source/blender/blentranslation/CMakeLists.txt +++ b/source/blender/blentranslation/CMakeLists.txt @@ -19,19 +19,30 @@ set(SRC BLT_translation.hh ) +if(WITH_INTERNATIONAL) + list(APPEND SRC + intern/messages.cc + intern/messages.hh + ) + + if(APPLE) + list(APPEND SRC + intern/messages_apple.mm + ) + endif() +endif() + set(LIB PRIVATE bf::blenkernel PRIVATE bf::blenlib PRIVATE bf::dna PRIVATE bf::imbuf + PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc ) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) - list(APPEND LIB - bf_intern_locale - ) endif() if(WITH_PYTHON) diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index c15db05e245..112807a9ad7 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -11,6 +11,7 @@ #include #include #include +#include #ifndef _WIN32 # include @@ -27,8 +28,6 @@ #include "BKE_appdir.hh" -#include "IMB_thumbs.hh" - #include "DNA_userdef_types.h" #include "MEM_guardedalloc.h" @@ -38,7 +37,11 @@ # include "BLI_fileops.h" # include "BLI_linklist.h" -# include "blender_locale.h" +# include "CLG_log.h" + +# include "messages.hh" + +static CLG_LogRef LOG = {"translation.language"}; /* Locale options. */ static const char **locales = nullptr; @@ -66,17 +69,19 @@ static void free_locales() static void fill_locales() { std::optional languages_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); - char languages[FILE_MAX]; - LinkNode *lines = nullptr, *line = nullptr; - char *str; - int idx = 0; + if (!languages_path.has_value()) { + CLOG_WARN(&LOG, "'locale' data path for translations not found"); + return; + } free_locales(); - if (languages_path.has_value()) { - BLI_path_join(languages, FILE_MAX, languages_path->c_str(), "languages"); - line = lines = BLI_file_read_as_lines(languages); - } + char languages[FILE_MAX]; + BLI_path_join(languages, FILE_MAX, languages_path->c_str(), "languages"); + + LinkNode *lines = BLI_file_read_as_lines(languages); + LinkNode *line = lines; + int idx = 0; /* This whole "parsing" code is a bit weak, in that it expects strictly formatted input file... * Should not be a problem, though, as this file is script-generated! */ @@ -84,7 +89,7 @@ static void fill_locales() /* First loop to find highest locale ID */ while (line) { int t; - str = (char *)line->link; + char *str = (char *)line->link; if (ELEM(str[0], '#', '\0')) { line = line->next; continue; /* Comment or void... */ @@ -109,7 +114,7 @@ static void fill_locales() while (line) { const char *loc, *sep1, *sep2, *sep3; - str = (char *)line->link; + char *str = (char *)line->link; if (ELEM(str[0], '#', '\0')) { line = line->next; continue; @@ -181,10 +186,6 @@ const EnumPropertyItem *BLT_lang_RNA_enum_properties() void BLT_lang_init() { -#ifdef WITH_INTERNATIONAL - const std::optional messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); -#endif - /* Make sure LANG is correct and wouldn't cause #std::runtime_error. */ #ifndef _WIN32 /* TODO(sergey): This code only ensures LANG is set properly, so later when @@ -205,7 +206,7 @@ void BLT_lang_init() old_locale = BLI_strdup(old_locale); if (setlocale(LC_ALL, lang) == nullptr) { setenv("LANG", "C", 1); - printf("Warning: Falling back to the standard locale (\"C\")\n"); + CLOG_WARN(&LOG, "Falling back to standard locale (\"C\")"); } setlocale(LC_ALL, old_locale); MEM_freeN(old_locale); @@ -213,21 +214,14 @@ void BLT_lang_init() #endif #ifdef WITH_INTERNATIONAL - if (messagepath.has_value()) { - bl_locale_init(messagepath->c_str(), TEXT_DOMAIN_NAME); - fill_locales(); - } - else { - printf("%s: 'locale' data path for translations not found, continuing\n", __func__); - } -#else + fill_locales(); #endif } void BLT_lang_free() { #ifdef WITH_INTERNATIONAL - bl_locale_free(); + blender::locale::free(); free_locales(); #endif } @@ -252,27 +246,12 @@ void BLT_lang_set(const char *str) { #ifdef WITH_INTERNATIONAL int ulang = ULANGUAGE; - const char *short_locale = str ? str : LOCALE(ulang); - const char *short_locale_utf8 = nullptr; - - /* We want to avoid locales like '.UTF-8'! */ - if (short_locale[0]) { - /* Hooray! Encoding needs to be placed *before* variant! */ - const char *variant = strchr(short_locale, '@'); - if (variant) { - char *locale = BLI_strdupn(short_locale, variant - short_locale); - short_locale_utf8 = BLI_sprintfN("%s.UTF-8%s", locale, variant); - MEM_freeN(locale); - } - else { - short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale); - } - bl_locale_set(short_locale_utf8); - MEM_freeN((void *)short_locale_utf8); - } - else { - bl_locale_set(short_locale); - } + std::string locale_name = str ? str : LOCALE(ulang); + + /* blender::locale assumes UTF-8, no need to put it in the name. */ + const std::optional messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); + blender::locale::init(locale_name, {TEXT_DOMAIN_NAME}, {messagepath.value_or("")}); + #else (void)str; #endif @@ -285,7 +264,7 @@ const char *BLT_lang_get() const char *locale = LOCALE(ULANGUAGE); if (locale[0] == '\0') { /* Default locale, we have to find which one we are actually using! */ - locale = bl_locale_get(); + locale = blender::locale::full_name(); } return locale; } diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index cbc9fe65b50..f5f85caad79 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -14,8 +14,6 @@ #include "BLT_translation.hh" -#include "MEM_guardedalloc.h" - #include "DNA_userdef_types.h" /* For user settings. */ #ifdef WITH_PYTHON @@ -24,7 +22,7 @@ #ifdef WITH_INTERNATIONAL # include "BLI_threads.h" -# include "blender_locale.h" +# include "messages.hh" #endif /* WITH_INTERNATIONAL */ bool BLT_is_default_context(const char *msgctxt) @@ -45,15 +43,17 @@ const char *BLT_pgettext(const char *msgctxt, const char *msgid) if (BLT_is_default_context(msgctxt)) { msgctxt = BLT_I18NCONTEXT_DEFAULT; } - ret = bl_locale_pgettext(msgctxt, msgid); -/* We assume if the returned string is the same (memory level) as the msgid, - * no translation was found, and we can try py scripts' ones! - */ + + ret = blender::locale::translate(0, msgctxt, msgid); + + /* No translation found? Try py script translations. */ + if (ret == nullptr) { # ifdef WITH_PYTHON - if (ret == msgid) { ret = BPY_app_translations_py_pgettext(msgctxt, msgid); - } +# else + ret = msgid; # endif + } } return ret; diff --git a/intern/locale/messages.cpp b/source/blender/blentranslation/intern/messages.cc similarity index 97% rename from intern/locale/messages.cpp rename to source/blender/blentranslation/intern/messages.cc index bcbc541faff..a0f00d631a2 100644 --- a/intern/locale/messages.cpp +++ b/source/blender/blentranslation/intern/messages.cc @@ -5,7 +5,11 @@ * * Adapted from boost::locale */ -#include "messages.h" +/** \file + * \ingroup blt + */ + +#include "messages.hh" #include #include @@ -26,8 +30,12 @@ # include "BLI_winstuff.h" #endif +#include "CLG_log.h" + namespace blender::locale { +static CLG_LogRef LOG = {"translation.messages"}; + /* Upper/lower case, intentionally restricted to ASCII. */ static constexpr bool is_upper_ascii(const char c) @@ -556,8 +564,11 @@ void init(const StringRef locale_full_name, global_messages = std::make_unique(info, domains, paths); global_full_name = info.to_full_name(); - if (!global_messages->error().empty()) { - printf("bl_locale_set(%s): %s\n", global_full_name.c_str(), global_messages->error().c_str()); + if (global_messages->error().empty()) { + CLOG_INFO(&LOG, 2, "Locale %s used for translation", global_full_name.c_str()); + } + else { + CLOG_ERROR(&LOG, "Locale %s: %s", global_full_name.c_str(), global_messages->error().c_str()); free(); } } diff --git a/intern/locale/messages.h b/source/blender/blentranslation/intern/messages.hh similarity index 95% rename from intern/locale/messages.h rename to source/blender/blentranslation/intern/messages.hh index 916ec1bbf80..8031d903da9 100644 --- a/intern/locale/messages.h +++ b/source/blender/blentranslation/intern/messages.hh @@ -3,6 +3,10 @@ * * Adapted from boost::locale */ +/** \file + * \ingroup blt + */ + #include #include "BLI_string_ref.hh" diff --git a/intern/locale/messages_apple.mm b/source/blender/blentranslation/intern/messages_apple.mm similarity index 95% rename from intern/locale/messages_apple.mm rename to source/blender/blentranslation/intern/messages_apple.mm index c818297c8c0..2d5554d0334 100644 --- a/intern/locale/messages_apple.mm +++ b/source/blender/blentranslation/intern/messages_apple.mm @@ -3,10 +3,10 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file - * \ingroup intern_locale + * \ingroup blt */ -#include "messages.h" +#include "messages.hh" #import From bec858191621e724b9d05acaff35eb489293c5b5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 19 Dec 2024 01:09:05 +0100 Subject: [PATCH 13/46] Refactor: Remove Boost from Quadriflow Extract Boykov-Kolmogorov max flow algorithm from boost::graph. As part of work towards removing Boost as a Blender dependency. Together with #133347 this removes the last direct Blender dependency on Boost. Pull Request: https://projects.blender.org/blender/blender/pulls/132142 --- CMakeLists.txt | 1 - extern/quadriflow/CMakeLists.txt | 3 +- extern/quadriflow/patches/blender.patch | 166 ++++- .../patches/boykov_kolmogorov_max_flow.hpp | 691 ++++++++++++++++++ extern/quadriflow/src/config.hpp | 5 - extern/quadriflow/src/flow.hpp | 101 +-- extern/quadriflow/src/post-solver.cpp | 2 + intern/quadriflow/CMakeLists.txt | 2 - 8 files changed, 879 insertions(+), 92 deletions(-) create mode 100644 extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a9061d06ec..6f22f8b4a22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1278,7 +1278,6 @@ set_and_warn_dependency(WITH_PYTHON WITH_MOD_FLUID OFF) # otherwise if the user disabled set_and_warn_dependency(WITH_BOOST WITH_OPENVDB OFF) -set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF) set_and_warn_dependency(WITH_BOOST WITH_USD OFF) if(WITH_CYCLES) set_and_warn_dependency(WITH_BOOST WITH_CYCLES_OSL OFF) diff --git a/extern/quadriflow/CMakeLists.txt b/extern/quadriflow/CMakeLists.txt index 8c0938ca730..f42a68ab246 100644 --- a/extern/quadriflow/CMakeLists.txt +++ b/extern/quadriflow/CMakeLists.txt @@ -51,11 +51,11 @@ set(INC ) set(INC_SYS - ${BOOST_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIRS} ) set(SRC + patches/boykov_kolmogorov_max_flow.hpp src/adjacent-matrix.cpp src/adjacent-matrix.hpp src/compare-key.hpp @@ -91,7 +91,6 @@ set(SRC ) set(LIB - ${BOOST_LIBRARIES} ) blender_add_lib(extern_quadriflow "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/extern/quadriflow/patches/blender.patch b/extern/quadriflow/patches/blender.patch index ade60d28d02..cc7a21adaa8 100644 --- a/extern/quadriflow/patches/blender.patch +++ b/extern/quadriflow/patches/blender.patch @@ -189,22 +189,6 @@ index 8de74ede8a9..f9861f39169 100644 num = length - shift; while (num--) { -diff --git a/extern/quadriflow/src/config.hpp b/extern/quadriflow/src/config.hpp -index 842b885a209..bf597ad0f39 100644 ---- a/extern/quadriflow/src/config.hpp -+++ b/extern/quadriflow/src/config.hpp -@@ -1,6 +1,11 @@ - #ifndef CONFIG_H_ - #define CONFIG_H_ - -+/* Workaround a bug in boost 1.68, until we upgrade to a newer version. */ -+#if defined(__clang__) && defined(WIN32) -+ #include -+ using namespace boost; -+#endif - // Move settings to cmake to make CMake happy :) - - // #define WITH_SCALE diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp index c333256a139..70a9628320f 100644 --- a/extern/quadriflow/src/hierarchy.cpp @@ -255,3 +239,153 @@ index aa27066e6e4..5b9d717db71 100644 std::size_t operator()(const obj_vertex &v) const { size_t hash = std::hash()(v.p); hash = hash * 37 + std::hash()(v.uv); +diff --git a/extern/quadriflow/src/flow.hpp b/extern/quadriflow/src/flow.hpp +index ab4a01c..a77f7ae 100644 +--- a/extern/quadriflow/src/flow.hpp ++++ b/extern/quadriflow/src/flow.hpp +@@ -7,17 +7,12 @@ + #include + + #include "config.hpp" +- +-#include +-#include +-#include +-#include ++#include "../patches/boykov_kolmogorov_max_flow.hpp" + + #include + #include + #include + +-using namespace boost; + using namespace Eigen; + + namespace qflow { +@@ -34,78 +29,52 @@ class MaxFlowHelper { + + class BoykovMaxFlowHelper : public MaxFlowHelper { + public: +- typedef int EdgeWeightType; +- typedef adjacency_list_traits Traits; +- // clang-format off +- typedef adjacency_list < vecS, vecS, directedS, +- property < vertex_name_t, std::string, +- property < vertex_index_t, long, +- property < vertex_color_t, boost::default_color_type, +- property < vertex_distance_t, long, +- property < vertex_predecessor_t, Traits::edge_descriptor > > > > >, +- +- property < edge_capacity_t, EdgeWeightType, +- property < edge_residual_capacity_t, EdgeWeightType, +- property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; +- // clang-format on +- +- public: +- BoykovMaxFlowHelper() { rev = get(edge_reverse, g); } +- void resize(int n, int m) { +- vertex_descriptors.resize(n); +- for (int i = 0; i < n; ++i) vertex_descriptors[i] = add_vertex(g); +- } +- int compute() { +- EdgeWeightType flow = +- boykov_kolmogorov_max_flow(g, vertex_descriptors.front(), vertex_descriptors.back()); +- return flow; ++ BoykovMaxFlowHelper() = default; ++ void resize(int n, int m) override { ++ num_verts = n; ++ num_edges = 0; ++ flow.resize(num_verts, m * 2); + } +- void addDirectEdge(Traits::vertex_descriptor& v1, Traits::vertex_descriptor& v2, +- property_map::type& rev, const int capacity, +- const int inv_capacity, Graph& g, Traits::edge_descriptor& e1, +- Traits::edge_descriptor& e2) { +- e1 = add_edge(v1, v2, g).first; +- e2 = add_edge(v2, v1, g).first; +- put(edge_capacity, g, e1, capacity); +- put(edge_capacity, g, e2, inv_capacity); +- +- rev[e1] = e2; +- rev[e2] = e1; ++ int compute() override { ++ return flow.max_flow(0, num_verts - 1); + } +- void addEdge(int x, int y, int c, int rc, int v, int cost = 1) { +- Traits::edge_descriptor e1, e2; +- addDirectEdge(vertex_descriptors[x], vertex_descriptors[y], rev, c, rc, g, e1, e2); ++ void addEdge(int x, int y, int c, int rc, int v, int cost = 1) override { ++ const int e1 = num_edges++; ++ const int e2 = num_edges++; ++ flow.set_edge(e1, e2, x, y, c); ++ flow.set_edge(e2, e1, y, x, rc); + if (v != -1) { +- edge_to_variables[e1] = std::make_pair(v, -1); +- edge_to_variables[e2] = std::make_pair(v, 1); ++ edge_to_variables.emplace_back(v, -1); ++ edge_to_variables.emplace_back(v, 1); ++ } ++ else { ++ edge_to_variables.emplace_back(-1, -1); ++ edge_to_variables.emplace_back(-1, -1); + } + } +- void applyTo(std::vector& edge_diff) { +- property_map::type capacity = get(edge_capacity, g); +- property_map::type residual_capacity = +- get(edge_residual_capacity, g); +- +- graph_traits::vertex_iterator u_iter, u_end; +- graph_traits::out_edge_iterator ei, e_end; +- for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) +- for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) +- if (capacity[*ei] > 0) { +- int flow = (capacity[*ei] - residual_capacity[*ei]); ++ void applyTo(std::vector& edge_diff) override { ++ for (int vert = 0; vert < num_verts; vert++) { ++ for (int edge : flow.vertex_out_edges(vert)) { ++ const int capacity = flow.edge_capacity(edge); ++ const int residual_capacity = flow.edge_residual_capacity(edge); ++ if (capacity > 0) { ++ int flow = (capacity - residual_capacity); + if (flow > 0) { +- auto it = edge_to_variables.find(*ei); +- if (it != edge_to_variables.end()) { +- edge_diff[it->second.first / 2][it->second.first % 2] += +- it->second.second * flow; ++ std::pair e2v = edge_to_variables[edge]; ++ if (e2v.first != -1) { ++ edge_diff[e2v.first / 2][e2v.first % 2] += e2v.second * flow; + } + } + } ++ } ++ } + } + + private: +- Graph g; +- property_map::type rev; +- std::vector vertex_descriptors; +- std::map> edge_to_variables; ++ BoykovKolmogorovMaxFlow flow; ++ std::vector> edge_to_variables; ++ int num_verts = 0; ++ int num_edges = 0; + }; + + class NetworkSimplexFlowHelper : public MaxFlowHelper { +diff --git a/extern/quadriflow/src/post-solver.cpp b/extern/quadriflow/src/post-solver.cpp +index 6027ddd..ccefd15 100644 +--- a/extern/quadriflow/src/post-solver.cpp ++++ b/extern/quadriflow/src/post-solver.cpp +@@ -5,7 +5,9 @@ + // Created by Jingwei on 2/5/18. + // + #include ++#ifdef POST_SOLVER + #include ++#endif + #include + #include + #include diff --git a/extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp b/extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp new file mode 100644 index 00000000000..96df563f0c4 --- /dev/null +++ b/extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp @@ -0,0 +1,691 @@ +// SPDX-FileCopyrightText: 2006 Stephan Diederich +// SPDX-FileCopyrightText: 2024 Blender Authors +// SPDX-License-Identifier: MIT +// +// Adapted from boost::graph + +#include +#include +#include +#include +#include +#include + +namespace qflow { + +class BoykovKolmogorovMaxFlow { + // Types + enum class Color { white, black, gray }; + + struct Edge { + int source; + int target; + }; + + const int NULL_VERTEX = -1; + const int NULL_EDGE = -1; + + public: + BoykovKolmogorovMaxFlow() = default; + + void resize(int num_verts, int num_edges) + { + m_graph_edges.resize(num_edges); + m_graph_out_edges.resize(num_verts); + m_cap_map.resize(num_edges); + m_res_cap_map.resize(num_edges); + m_rev_edge_map.resize(num_edges); + m_pre_map.resize(num_verts, 0); + m_tree_map.resize(num_verts, Color::gray); + m_dist_map.resize(num_verts, 0); + m_in_active_list_map.resize(num_verts, false); + m_has_parent_map.resize(num_verts, false); + m_time_map.resize(num_verts, 0); + } + + void set_edge(const int edge, + const int reverse_edge, + const int source, + const int target, + const int capacity) + { + m_graph_edges[edge] = Edge{source, target}; + m_graph_out_edges[source].push_back(edge); + m_rev_edge_map[edge] = reverse_edge; + + // Initialize flow to zero which means initializing + // the residual capacity equal to the capacity + m_cap_map[edge] = capacity; + m_res_cap_map[edge] = capacity; + } + + int edge_capacity(const int edge) + { + return m_cap_map[edge]; + } + + int edge_residual_capacity(const int edge) + { + return m_res_cap_map[edge]; + } + + const std::vector &vertex_out_edges(const int vertex) + { + return m_graph_out_edges[vertex]; + } + + int max_flow(int src, int sink) + { + m_source = src; + m_sink = sink; + + // init the search trees with the two terminals + m_tree_map[m_source] = Color::black; + m_tree_map[m_sink] = Color::white; + m_time_map[m_source] = 1; + m_time_map[m_sink] = 1; + + // augment direct paths from SOURCE->SINK and SOURCE->VERTEX->SINK + augment_direct_paths(); + // start the main-loop + while (true) { + bool path_found; + int connecting_edge; + std::tie(connecting_edge, path_found) = grow(); // find a path from source to sink + if (!path_found) { + // we're finished, no more paths were found + break; + } + ++m_time; + augment(connecting_edge); // augment that path + adopt(); // rebuild search tree structure + } + return m_flow; + } + + protected: + int lookup_edge(int source, int target) + { + for (const int e : m_graph_out_edges[source]) { + if (m_graph_edges[e].target == target) { + return e; + } + } + return NULL_EDGE; + } + + void augment_direct_paths() + { + // in a first step, we augment all direct paths from + // source->NODE->sink and additionally paths from source->sink. This + // improves especially graphcuts for segmentation, as most of the + // nodes have source/sink connects but shouldn't have an impact on + // other maxflow problems (this is done in grow() anyway) + for (const int ei : m_graph_out_edges[m_source]) { + int from_source = ei; + int current_node = m_graph_edges[from_source].target; + if (current_node == m_sink) { + int cap = m_res_cap_map[from_source]; + m_res_cap_map[from_source] = 0; + m_flow += cap; + continue; + } + const int to_sink = lookup_edge(current_node, m_sink); + if (to_sink != NULL_EDGE) { + int cap_from_source = m_res_cap_map[from_source]; + int cap_to_sink = m_res_cap_map[to_sink]; + if (cap_from_source > cap_to_sink) { + m_tree_map[current_node] = Color::black; + add_active_node(current_node); + set_edge_to_parent(current_node, from_source); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + // add stuff to flow and update residuals. we dont need + // to update reverse_edges, as incoming/outgoing edges + // to/from source/sink don't count for max-flow + m_res_cap_map[from_source] = m_res_cap_map[from_source] - cap_to_sink; + m_res_cap_map[to_sink] = 0; + m_flow += cap_to_sink; + } + else if (cap_to_sink > 0) { + m_tree_map[current_node] = Color::white; + add_active_node(current_node); + set_edge_to_parent(current_node, to_sink); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + // add stuff to flow and update residuals. we dont need + // to update reverse_edges, as incoming/outgoing edges + // to/from source/sink don't count for max-flow + m_res_cap_map[to_sink] = m_res_cap_map[to_sink] - cap_from_source; + m_res_cap_map[from_source] = 0; + m_flow += cap_from_source; + } + } + else if (m_res_cap_map[from_source]) { + // there is no sink connect, so we can't augment this path, + // but to avoid adding m_source to the active nodes, we just + // activate this node and set the approciate things + m_tree_map[current_node] = Color::black; + set_edge_to_parent(current_node, from_source); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + add_active_node(current_node); + } + } + for (const int ei : m_graph_out_edges[m_sink]) { + int to_sink = m_rev_edge_map[ei]; + int current_node = m_graph_edges[to_sink].source; + if (m_res_cap_map[to_sink]) { + m_tree_map[current_node] = Color::white; + set_edge_to_parent(current_node, to_sink); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + add_active_node(current_node); + } + } + } + + /** + * Returns a pair of an edge and a boolean. if the bool is true, the + * edge is a connection of a found path from s->t , read "the link" and + * m_graph_edges[returnVal].source is the end of the path found in the + * source-tree m_graph_edges[returnVal].target is the beginning of the path found + * in the sink-tree + */ + std::pair grow() + { + assert(m_orphans.empty()); + int current_node; + while ((current_node = get_next_active_node()) != NULL_VERTEX) { // if there is one + assert(m_tree_map[current_node] != Color::gray && + (has_parent(current_node) || current_node == m_source || current_node == m_sink)); + + if (m_tree_map[current_node] == Color::black) { + // source tree growing + if (current_node != m_last_grow_vertex) { + m_last_grow_vertex = current_node; + m_last_grow_out_edge = 0; + } + const std::vector &out_edges = m_graph_out_edges[m_last_grow_vertex]; + for (; m_last_grow_out_edge < out_edges.size(); m_last_grow_out_edge++) { + int out_edge = out_edges[m_last_grow_out_edge]; + if (m_res_cap_map[out_edge] > 0) { // check if we have capacity left on this edge + int other_node = m_graph_edges[out_edge].target; + if (m_tree_map[other_node] == Color::gray) { // it's a free node + // aquire other node to our search tree + m_tree_map[other_node] = Color::black; + set_edge_to_parent(other_node, out_edge); // set us as parent + m_dist_map[other_node] = m_dist_map[current_node] + 1; // and update the + // distance-heuristic + m_time_map[other_node] = m_time_map[current_node]; + add_active_node(other_node); + } + else if (m_tree_map[other_node] == Color::black) { + // we do this to get shorter paths. check if we + // are nearer to the source as its parent is + if (is_closer_to_terminal(current_node, other_node)) { + set_edge_to_parent(other_node, out_edge); + m_dist_map[other_node] = m_dist_map[current_node] + 1; + m_time_map[other_node] = m_time_map[current_node]; + } + } + else { + assert(m_tree_map[other_node] == Color::white); + // kewl, found a path from one to the other + // search tree, return + // the connecting edge in src->sink dir + return std::make_pair(out_edge, true); + } + } + } // for all out-edges + } // source-tree-growing + else { + assert(m_tree_map[current_node] == Color::white); + if (current_node != m_last_grow_vertex) { + m_last_grow_vertex = current_node; + m_last_grow_out_edge = 0; + } + const std::vector &out_edges = m_graph_out_edges[m_last_grow_vertex]; + for (; m_last_grow_out_edge < out_edges.size(); m_last_grow_out_edge++) { + int in_edge = m_rev_edge_map[out_edges[m_last_grow_out_edge]]; + if (m_res_cap_map[in_edge] > 0) { // check if there is capacity left + int other_node = m_graph_edges[in_edge].source; + if (m_tree_map[other_node] == Color::gray) { // it's a free node + // aquire other node to our search tree + m_tree_map[other_node] = Color::white; + set_edge_to_parent(other_node, in_edge); // set us as parent + add_active_node(other_node); // activate that node + m_dist_map[other_node] = m_dist_map[current_node] + 1; // set its distance + m_time_map[other_node] = m_time_map[current_node]; // and time + } + else if (m_tree_map[other_node] == Color::white) { + if (is_closer_to_terminal(current_node, other_node)) { + // we are closer to the sink than its parent + // is, so we "adopt" him + set_edge_to_parent(other_node, in_edge); + m_dist_map[other_node] = m_dist_map[current_node] + 1; + m_time_map[other_node] = m_time_map[current_node]; + } + } + else { + assert(m_tree_map[other_node] == Color::black); + // kewl, found a path from one to the other + // search tree, + // return the connecting edge in src->sink dir + return std::make_pair(in_edge, true); + } + } + } // for all out-edges + } // sink-tree growing + + // all edges of that node are processed, and no more paths were + // found. + // remove if from the front of the active queue + finish_node(current_node); + } // while active_nodes not empty + + // no active nodes anymore and no path found, we're done + return std::make_pair(int(), false); + } + + /** + * augments path from s->t and updates residual graph + * m_graph_edges[e].source is the end of the path found in the source-tree + * m_graph_edges[e].target is the beginning of the path found in the sink-tree + * this phase generates orphans on satured edges, if the attached verts + * are from different search-trees orphans are ordered in distance to + * sink/source. first the farest from the source are front_inserted into + * the orphans list, and after that the sink-tree-orphans are + * front_inserted. when going to adoption stage the orphans are + * popped_front, and so we process the nearest verts to the terminals + * first + */ + void augment(int e) + { + assert(m_tree_map[m_graph_edges[e].target] == Color::white); + assert(m_tree_map[m_graph_edges[e].source] == Color::black); + assert(m_orphans.empty()); + + const int bottleneck = find_bottleneck(e); + // now we push the found flow through the path + // for each edge we saturate we have to look for the verts that + // belong to that edge, one of them becomes an orphans now process + // the connecting edge + m_res_cap_map[e] = m_res_cap_map[e] - bottleneck; + assert(m_res_cap_map[e] >= 0); + m_res_cap_map[m_rev_edge_map[e]] = m_res_cap_map[m_rev_edge_map[e]] + bottleneck; + + // now we follow the path back to the source + int current_node = m_graph_edges[e].source; + while (current_node != m_source) { + int pred = get_edge_to_parent(current_node); + m_res_cap_map[pred] = m_res_cap_map[pred] - bottleneck; + assert(m_res_cap_map[pred] >= 0); + m_res_cap_map[m_rev_edge_map[pred]] = m_res_cap_map[m_rev_edge_map[pred]] + bottleneck; + if (m_res_cap_map[pred] == 0) { + set_no_parent(current_node); + m_orphans.push_front(current_node); + } + current_node = m_graph_edges[pred].source; + } + // then go forward in the sink-tree + current_node = m_graph_edges[e].target; + while (current_node != m_sink) { + int pred = get_edge_to_parent(current_node); + m_res_cap_map[pred] = m_res_cap_map[pred] - bottleneck; + assert(m_res_cap_map[pred] >= 0); + m_res_cap_map[m_rev_edge_map[pred]] = m_res_cap_map[m_rev_edge_map[pred]] + bottleneck; + if (m_res_cap_map[pred] == 0) { + set_no_parent(current_node); + m_orphans.push_front(current_node); + } + current_node = m_graph_edges[pred].target; + } + // and add it to the max-flow + m_flow += bottleneck; + } + + /** + * returns the bottleneck of a s->t path (end_of_path is last vertex in + * source-tree, begin_of_path is first vertex in sink-tree) + */ + int find_bottleneck(int e) + { + int minimum_cap = m_res_cap_map[e]; + int current_node = m_graph_edges[e].source; + // first go back in the source tree + while (current_node != m_source) { + int pred = get_edge_to_parent(current_node); + minimum_cap = std::min(minimum_cap, m_res_cap_map[pred]); + current_node = m_graph_edges[pred].source; + } + // then go forward in the sink-tree + current_node = m_graph_edges[e].target; + while (current_node != m_sink) { + int pred = get_edge_to_parent(current_node); + minimum_cap = std::min(minimum_cap, m_res_cap_map[pred]); + current_node = m_graph_edges[pred].target; + } + return minimum_cap; + } + + /** + * rebuild search trees + * empty the queue of orphans, and find new parents for them or just + * drop them from the search trees + */ + void adopt() + { + while (!m_orphans.empty() || !m_child_orphans.empty()) { + int current_node; + if (m_child_orphans.empty()) { + // get the next orphan from the main-queue and remove it + current_node = m_orphans.front(); + m_orphans.pop_front(); + } + else { + current_node = m_child_orphans.front(); + m_child_orphans.pop(); + } + if (m_tree_map[current_node] == Color::black) { + // we're in the source-tree + int min_distance = (std::numeric_limits::max)(); + int new_parent_edge; + for (const int ei : m_graph_out_edges[current_node]) { + const int in_edge = m_rev_edge_map[ei]; + assert(m_graph_edges[in_edge].target == current_node); // we should be the target of + // this edge + if (m_res_cap_map[in_edge] > 0) { + int other_node = m_graph_edges[in_edge].source; + if (m_tree_map[other_node] == Color::black && has_source_connect(other_node)) { + if (m_dist_map[other_node] < min_distance) { + min_distance = m_dist_map[other_node]; + new_parent_edge = in_edge; + } + } + } + } + if (min_distance != (std::numeric_limits::max)()) { + set_edge_to_parent(current_node, new_parent_edge); + m_dist_map[current_node] = min_distance + 1; + m_time_map[current_node] = m_time; + } + else { + m_time_map[current_node] = 0; + for (const int ei : m_graph_out_edges[current_node]) { + int in_edge = m_rev_edge_map[ei]; + int other_node = m_graph_edges[in_edge].source; + if (m_tree_map[other_node] == Color::black && other_node != m_source) { + if (m_res_cap_map[in_edge] > 0) { + add_active_node(other_node); + } + if (has_parent(other_node) && + m_graph_edges[get_edge_to_parent(other_node)].source == current_node) + { + // we are the parent of that node + // it has to find a new parent, too + set_no_parent(other_node); + m_child_orphans.push(other_node); + } + } + } + m_tree_map[current_node] = Color::gray; + } // no parent found + } // source-tree-adoption + else { + // now we should be in the sink-tree, check that... + assert(m_tree_map[current_node] == Color::white); + int new_parent_edge; + int min_distance = (std::numeric_limits::max)(); + for (const int ei : m_graph_out_edges[current_node]) { + const int out_edge = ei; + if (m_res_cap_map[out_edge] > 0) { + const int other_node = m_graph_edges[out_edge].target; + if (m_tree_map[other_node] == Color::white && has_sink_connect(other_node)) { + if (m_dist_map[other_node] < min_distance) { + min_distance = m_dist_map[other_node]; + new_parent_edge = out_edge; + } + } + } + } + if (min_distance != (std::numeric_limits::max)()) { + set_edge_to_parent(current_node, new_parent_edge); + m_dist_map[current_node] = min_distance + 1; + m_time_map[current_node] = m_time; + } + else { + m_time_map[current_node] = 0; + for (const int ei : m_graph_out_edges[current_node]) { + const int out_edge = ei; + const int other_node = m_graph_edges[out_edge].target; + if (m_tree_map[other_node] == Color::white && other_node != m_sink) { + if (m_res_cap_map[out_edge] > 0) { + add_active_node(other_node); + } + if (has_parent(other_node) && + m_graph_edges[get_edge_to_parent(other_node)].target == current_node) + { + // we were it's parent, so it has to find a + // new one, too + set_no_parent(other_node); + m_child_orphans.push(other_node); + } + } + } + m_tree_map[current_node] = Color::gray; + } // no parent found + } // sink-tree adoption + } // while !orphans.empty() + } // adopt + + /** + * return next active vertex if there is one, otherwise a null_vertex + */ + int get_next_active_node() + { + while (true) { + if (m_active_nodes.empty()) { + return NULL_VERTEX; + } + int v = m_active_nodes.front(); + + // if it has no parent, this node can't be active (if its not + // source or sink) + if (!has_parent(v) && v != m_source && v != m_sink) { + m_active_nodes.pop(); + m_in_active_list_map[v] = false; + } + else { + assert(m_tree_map[v] == Color::black || m_tree_map[v] == Color::white); + return v; + } + } + } + + /** + * adds v as an active vertex, but only if its not in the list already + */ + void add_active_node(int v) + { + assert(m_tree_map[v] != Color::gray); + if (m_in_active_list_map[v]) { + if (m_last_grow_vertex == v) { + m_last_grow_vertex = NULL_VERTEX; + } + return; + } + + m_in_active_list_map[v] = true; + m_active_nodes.push(v); + } + + /** + * finish_node removes a node from the front of the active queue (its + * called in grow phase, if no more paths can be found using this node) + */ + void finish_node(int v) + { + assert(m_active_nodes.front() == v); + m_active_nodes.pop(); + m_in_active_list_map[v] = false; + m_last_grow_vertex = NULL_VERTEX; + } + + /** + * returns edge to parent vertex of v; + */ + int get_edge_to_parent(int v) const + { + return m_pre_map[v]; + } + + /** + * returns true if the edge stored in m_pre_map[v] is a valid entry + */ + bool has_parent(int v) const + { + return m_has_parent_map[v]; + } + + /** + * sets edge to parent vertex of v; + */ + void set_edge_to_parent(int v, int f_edge_to_parent) + { + assert(m_res_cap_map[f_edge_to_parent] > 0); + m_pre_map[v] = f_edge_to_parent; + m_has_parent_map[v] = true; + } + + /** + * removes the edge to parent of v (this is done by invalidating the + * entry an additional map) + */ + void set_no_parent(int v) + { + m_has_parent_map[v] = false; + } + + /** + * checks if vertex v has a connect to the sink-vertex (@var m_sink) + * @param v the vertex which is checked + * @return true if a path to the sink was found, false if not + */ + bool has_sink_connect(int v) + { + int current_distance = 0; + int current_vertex = v; + while (true) { + if (m_time_map[current_vertex] == m_time) { + // we found a node which was already checked this round. use + // it for distance calculations + current_distance += m_dist_map[current_vertex]; + break; + } + if (current_vertex == m_sink) { + m_time_map[m_sink] = m_time; + break; + } + if (has_parent(current_vertex)) { + // it has a parent, so get it + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].target; + ++current_distance; + } + else { + // no path found + return false; + } + } + current_vertex = v; + while (m_time_map[current_vertex] != m_time) { + m_dist_map[current_vertex] = current_distance; + --current_distance; + m_time_map[current_vertex] = m_time; + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].target; + } + return true; + } + + /** + * checks if vertex v has a connect to the source-vertex (@var m_source) + * @param v the vertex which is checked + * @return true if a path to the source was found, false if not + */ + bool has_source_connect(int v) + { + int current_distance = 0; + int current_vertex = v; + while (true) { + if (m_time_map[current_vertex] == m_time) { + // we found a node which was already checked this round. use + // it for distance calculations + current_distance += m_dist_map[current_vertex]; + break; + } + if (current_vertex == m_source) { + m_time_map[m_source] = m_time; + break; + } + if (has_parent(current_vertex)) { + // it has a parent, so get it + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].source; + ++current_distance; + } + else { + // no path found + return false; + } + } + current_vertex = v; + while (m_time_map[current_vertex] != m_time) { + m_dist_map[current_vertex] = current_distance; + --current_distance; + m_time_map[current_vertex] = m_time; + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].source; + } + return true; + } + + /** + * returns true, if p is closer to a terminal than q + */ + bool is_closer_to_terminal(int p, int q) + { + // checks the timestamps first, to build no cycles, and after that + // the real distance + return (m_time_map[q] <= m_time_map[p] && m_dist_map[q] > m_dist_map[p] + 1); + } + + // Member variables + std::vector m_graph_edges; + std::vector> m_graph_out_edges; + + std::vector m_cap_map; + std::vector m_res_cap_map; + std::vector m_rev_edge_map; + std::vector m_pre_map; // stores paths found in the growth stage + std::vector m_tree_map; // maps each vertex into white, black or gray + std::vector m_dist_map; // stores distance to source/sink nodes + + int m_source; + int m_sink; + + std::queue m_active_nodes; + std::vector m_in_active_list_map; + + std::list m_orphans; + std::queue m_child_orphans; // we use a second queuqe for child orphans, as + // they are FIFO processed + std::vector m_has_parent_map; + + std::vector m_time_map; // timestamp of each node, used for + // sink/source-path calculations + int m_flow = 0; + int m_time = 1; + + int m_last_grow_vertex = NULL_VERTEX; + int m_last_grow_out_edge = 0; +}; + +} // namespace qflow diff --git a/extern/quadriflow/src/config.hpp b/extern/quadriflow/src/config.hpp index bf597ad0f39..842b885a209 100644 --- a/extern/quadriflow/src/config.hpp +++ b/extern/quadriflow/src/config.hpp @@ -1,11 +1,6 @@ #ifndef CONFIG_H_ #define CONFIG_H_ -/* Workaround a bug in boost 1.68, until we upgrade to a newer version. */ -#if defined(__clang__) && defined(WIN32) - #include - using namespace boost; -#endif // Move settings to cmake to make CMake happy :) // #define WITH_SCALE diff --git a/extern/quadriflow/src/flow.hpp b/extern/quadriflow/src/flow.hpp index ab4a01cb4ed..a77f7ae6639 100644 --- a/extern/quadriflow/src/flow.hpp +++ b/extern/quadriflow/src/flow.hpp @@ -7,17 +7,12 @@ #include #include "config.hpp" - -#include -#include -#include -#include +#include "../patches/boykov_kolmogorov_max_flow.hpp" #include #include #include -using namespace boost; using namespace Eigen; namespace qflow { @@ -34,78 +29,52 @@ class MaxFlowHelper { class BoykovMaxFlowHelper : public MaxFlowHelper { public: - typedef int EdgeWeightType; - typedef adjacency_list_traits Traits; - // clang-format off - typedef adjacency_list < vecS, vecS, directedS, - property < vertex_name_t, std::string, - property < vertex_index_t, long, - property < vertex_color_t, boost::default_color_type, - property < vertex_distance_t, long, - property < vertex_predecessor_t, Traits::edge_descriptor > > > > >, - - property < edge_capacity_t, EdgeWeightType, - property < edge_residual_capacity_t, EdgeWeightType, - property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; - // clang-format on - - public: - BoykovMaxFlowHelper() { rev = get(edge_reverse, g); } - void resize(int n, int m) { - vertex_descriptors.resize(n); - for (int i = 0; i < n; ++i) vertex_descriptors[i] = add_vertex(g); - } - int compute() { - EdgeWeightType flow = - boykov_kolmogorov_max_flow(g, vertex_descriptors.front(), vertex_descriptors.back()); - return flow; + BoykovMaxFlowHelper() = default; + void resize(int n, int m) override { + num_verts = n; + num_edges = 0; + flow.resize(num_verts, m * 2); } - void addDirectEdge(Traits::vertex_descriptor& v1, Traits::vertex_descriptor& v2, - property_map::type& rev, const int capacity, - const int inv_capacity, Graph& g, Traits::edge_descriptor& e1, - Traits::edge_descriptor& e2) { - e1 = add_edge(v1, v2, g).first; - e2 = add_edge(v2, v1, g).first; - put(edge_capacity, g, e1, capacity); - put(edge_capacity, g, e2, inv_capacity); - - rev[e1] = e2; - rev[e2] = e1; + int compute() override { + return flow.max_flow(0, num_verts - 1); } - void addEdge(int x, int y, int c, int rc, int v, int cost = 1) { - Traits::edge_descriptor e1, e2; - addDirectEdge(vertex_descriptors[x], vertex_descriptors[y], rev, c, rc, g, e1, e2); + void addEdge(int x, int y, int c, int rc, int v, int cost = 1) override { + const int e1 = num_edges++; + const int e2 = num_edges++; + flow.set_edge(e1, e2, x, y, c); + flow.set_edge(e2, e1, y, x, rc); if (v != -1) { - edge_to_variables[e1] = std::make_pair(v, -1); - edge_to_variables[e2] = std::make_pair(v, 1); + edge_to_variables.emplace_back(v, -1); + edge_to_variables.emplace_back(v, 1); + } + else { + edge_to_variables.emplace_back(-1, -1); + edge_to_variables.emplace_back(-1, -1); } } - void applyTo(std::vector& edge_diff) { - property_map::type capacity = get(edge_capacity, g); - property_map::type residual_capacity = - get(edge_residual_capacity, g); - - graph_traits::vertex_iterator u_iter, u_end; - graph_traits::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) - if (capacity[*ei] > 0) { - int flow = (capacity[*ei] - residual_capacity[*ei]); + void applyTo(std::vector& edge_diff) override { + for (int vert = 0; vert < num_verts; vert++) { + for (int edge : flow.vertex_out_edges(vert)) { + const int capacity = flow.edge_capacity(edge); + const int residual_capacity = flow.edge_residual_capacity(edge); + if (capacity > 0) { + int flow = (capacity - residual_capacity); if (flow > 0) { - auto it = edge_to_variables.find(*ei); - if (it != edge_to_variables.end()) { - edge_diff[it->second.first / 2][it->second.first % 2] += - it->second.second * flow; + std::pair e2v = edge_to_variables[edge]; + if (e2v.first != -1) { + edge_diff[e2v.first / 2][e2v.first % 2] += e2v.second * flow; } } } + } + } } private: - Graph g; - property_map::type rev; - std::vector vertex_descriptors; - std::map> edge_to_variables; + BoykovKolmogorovMaxFlow flow; + std::vector> edge_to_variables; + int num_verts = 0; + int num_edges = 0; }; class NetworkSimplexFlowHelper : public MaxFlowHelper { diff --git a/extern/quadriflow/src/post-solver.cpp b/extern/quadriflow/src/post-solver.cpp index 6027ddd2eb7..ccefd1557d8 100644 --- a/extern/quadriflow/src/post-solver.cpp +++ b/extern/quadriflow/src/post-solver.cpp @@ -5,7 +5,9 @@ // Created by Jingwei on 2/5/18. // #include +#ifdef POST_SOLVER #include +#endif #include #include #include diff --git a/intern/quadriflow/CMakeLists.txt b/intern/quadriflow/CMakeLists.txt index b253d1feb0e..5aef735fc7e 100644 --- a/intern/quadriflow/CMakeLists.txt +++ b/intern/quadriflow/CMakeLists.txt @@ -8,7 +8,6 @@ set(INC set(INC_SYS ../../extern/quadriflow/src - ${BOOST_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIRS} ) @@ -20,7 +19,6 @@ set(SRC set(LIB PRIVATE bf::intern::guardedalloc extern_quadriflow - ${BOOST_LIBRARIES} ) if(WIN32) From 71d3e32974d64cd69d15e564e118e10ac0bd0967 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 22 Jan 2025 09:08:36 +0100 Subject: [PATCH 14/46] glTF exporter: Tweak for action filter in Collection Export Waiting a proper solution for props declaration: - Filter now happen even if the list is not displayed - Avoid spaming console with error, display a label saying what to do --- scripts/addons_core/io_scene_gltf2/__init__.py | 11 ++++++++++- .../io_scene_gltf2/blender/com/gltf2_blender_ui.py | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index 6b63dbae85d..d997f30bdf5 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -5,7 +5,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (4, 4, 34), + "version": (4, 4, 35), 'blender': (4, 4, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -1099,6 +1099,15 @@ def execute(self, context): # All custom export settings are stored in this container. export_settings = {} + # Collection Export does not handle correctly props declaration for now + # So use this tweak to manage it, waiting for a better solution + is_file_browser = context.space_data.type == 'FILE_BROWSER' + if not is_file_browser: + if not hasattr(context.scene, "gltf_action_filter") and self.export_action_filter: + bpy.types.Scene.gltf_action_filter = bpy.props.CollectionProperty(type=GLTF2_filter_action) + bpy.types.Scene.gltf_action_filter_active = bpy.props.IntProperty() + + # Get log level from parameters # If not set, get it from Blender app debug value export_settings['gltf_loglevel'] = self.export_loglevel diff --git a/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py b/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py index df81e064302..7598cbe84b4 100644 --- a/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py +++ b/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py @@ -650,6 +650,13 @@ def export_panel_animation_action_filter(layout, operator): row = body.row() + # Collection Export does not handle correctly property declaration + # So use this tweak to avoid spaming the console, waiting for a better solution + is_file_browser = bpy.context.space_data.type == 'FILE_BROWSER' + if not is_file_browser and not hasattr(bpy.data.scenes[0], "gltf_action_filter"): + row.label(text="Please disable/enable 'action filter' to refresh the list") + return + if len(bpy.data.actions) > 0: row.template_list( "SCENE_UL_gltf2_filter_action", From 00968fe6dbc85b6982a508041f9b7671c87f61b3 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 22 Jan 2025 09:15:53 +0100 Subject: [PATCH 15/46] Fix: Grease pencil inconsistent inverting of influence vertex groups Behavior was not consistent across modifiers - Opacity -- strokes were using inverted weights only when MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR was OFF, fills however when MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR was ON - Tint -- strokes and fills were using inverted weights only when MOD_GREASE_PENCIL_TINT_USE_WEIGHT_AS_FACTOR was ON - others (Envelope, Lattice, Noise, Offset ) were ignoring inverting the influence vertex group alltogether (but that is reported in #133055 and will be handled separately, see below) - others (Hook, ... ) were always inverting it, which is correct This pull requeset only corrects this for Opacity and Tint (in the way that now weights are always inverted, no matter if "Use Weight As Factor" is used). This also paves the way to a more general fix for #133055 (which intends to move the weight inversion to the very general greasepencil::get_influence_vertex_weights) Pull Request: https://projects.blender.org/blender/blender/pulls/133310 --- .../intern/MOD_grease_pencil_opacity.cc | 16 +++++++--------- .../modifiers/intern/MOD_grease_pencil_tint.cc | 11 ++++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc b/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc index 2caf50d6deb..494ea9d9dcc 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc @@ -89,7 +89,8 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd, curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) { const IndexRange points = points_by_curve[curve_i]; for (const int64_t point_i : points) { - const float vgroup_weight = vgroup_weights[point_i]; + const float vgroup_weight = invert_vertex_group ? 1.0f - vgroup_weights[point_i] : + vgroup_weights[point_i]; if (vgroup_weight <= 0.0f) { continue; } @@ -110,9 +111,8 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd, } else { /* Use vertex group weights as influence factors. */ - const float vgroup_influence = invert_vertex_group ? 1.0f - vgroup_weight : vgroup_weight; opacities.span[point_i] = std::clamp( - opacities.span[point_i] + (omd.color_factor * curve_factor - 1.0f) * vgroup_influence, + opacities.span[point_i] + (omd.color_factor * curve_factor - 1.0f) * vgroup_weight, 0.0f, 1.0f); } @@ -144,17 +144,15 @@ static void modify_fill_color(const GreasePencilOpacityModifierData &omd, /* Use the first stroke point as vertex weight. */ const IndexRange points = points_by_curve[curve_i]; const float vgroup_weight_first = vgroup_weights[points.first()]; - float stroke_weight = vgroup_weight_first; + float stroke_weight = invert_vertex_group ? 1.0f - vgroup_weight_first : vgroup_weight_first; if (use_vgroup_opacity) { - if (points.is_empty() || (vgroup_weight_first <= 0.0f)) { + if (points.is_empty() || (stroke_weight <= 0.0f)) { stroke_weight = 1.0f; } - const float stroke_influence = invert_vertex_group ? 1.0f - stroke_weight : stroke_weight; - - fill_opacities.span[curve_i] = std::clamp(stroke_influence, 0.0f, 1.0f); + fill_opacities.span[curve_i] = std::clamp(stroke_weight, 0.0f, 1.0f); } else { - if (!points.is_empty() && (vgroup_weight_first > 0.0f)) { + if (!points.is_empty() && (stroke_weight > 0.0f)) { fill_opacities.span[curve_i] = std::clamp(omd.color_factor * stroke_weight, 0.0f, 1.0f); } } diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc index dad006eaa64..366f7c72dbb 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc @@ -187,9 +187,10 @@ static void modify_stroke_color(Object &ob, }; auto get_point_factor = [&](const int64_t point_i) { - const float weight = vgroup_weights[point_i]; + const float weight = invert_vertex_group ? 1.0f - vgroup_weights[point_i] : + vgroup_weights[point_i]; if (use_weight_as_factor) { - return invert_vertex_group ? 1.0f - weight : weight; + return weight; } return tmd.factor * weight; }; @@ -275,12 +276,12 @@ static void modify_fill_color(Object &ob, /* Use the first stroke point as vertex weight. */ const IndexRange points = points_by_curve[curve_i]; const float vgroup_weight_first = vgroup_weights[points.first()]; - float stroke_weight = vgroup_weight_first; - if (points.is_empty() || (vgroup_weight_first <= 0.0f)) { + float stroke_weight = invert_vertex_group ? 1.0f - vgroup_weight_first : vgroup_weight_first; + if (points.is_empty() || (stroke_weight <= 0.0f)) { return 0.0f; } else if (use_weight_as_factor) { - return invert_vertex_group ? 1.0f - stroke_weight : stroke_weight; + return stroke_weight; } return tmd.factor * stroke_weight; }; From 2a52ca42bd9949eacac8687cd6e0ef9a0f150434 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 22 Jan 2025 09:16:25 +0100 Subject: [PATCH 16/46] Fix #131836: Texture paint: "Texture Mask" stencil is not drawing Reason for this is that all the brushes in essentials assets have a zero default `mask_stencil_pos` / `mask_stencil_dimension`. At that time, they have been created resetting a brush to defaults and using that as a starting point. At that time though, these settings didnt have a default (which b2dd308dcacf fixed, so that method should not result in those settings being zero). The brushes in essentials assets still do though, now correct these in versioning code. Pull Request: https://projects.blender.org/blender/blender/pulls/133374 --- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenloader/intern/versioning_400.cc | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index ef82e6fdc30..dd6d7ae833d 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -31,7 +31,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 25 +#define BLENDER_FILE_SUBVERSION 26 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 775bbbf377d..1dee556cfed 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -5689,6 +5689,20 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 404, 26)) { + const Brush *default_brush = DNA_struct_default_get(Brush); + LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { + if ((brush->mask_stencil_dimension[0] == 0) && (brush->mask_stencil_dimension[1] == 0)) { + brush->mask_stencil_dimension[0] = default_brush->mask_stencil_dimension[0]; + brush->mask_stencil_dimension[1] = default_brush->mask_stencil_dimension[1]; + } + if ((brush->mask_stencil_pos[0] == 0) && (brush->mask_stencil_pos[1] == 0)) { + brush->mask_stencil_pos[0] = default_brush->mask_stencil_pos[0]; + brush->mask_stencil_pos[1] = default_brush->mask_stencil_pos[1]; + } + } + } + /* Always run this versioning; meshes are written with the legacy format which always needs to * be converted to the new format on file load. Can be moved to a subversion check in a larger * breaking release. */ From 16f728cfe58dd497d16b62d73430e62eb988a6d3 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 22 Jan 2025 09:19:13 +0100 Subject: [PATCH 17/46] glTF exporter: Missed background check in previous commit --- scripts/addons_core/io_scene_gltf2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index d997f30bdf5..4b168ad0875 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -1101,7 +1101,7 @@ def execute(self, context): # Collection Export does not handle correctly props declaration for now # So use this tweak to manage it, waiting for a better solution - is_file_browser = context.space_data.type == 'FILE_BROWSER' + is_file_browser = context.space_data and context.space_data.type == 'FILE_BROWSER' if not is_file_browser: if not hasattr(context.scene, "gltf_action_filter") and self.export_action_filter: bpy.types.Scene.gltf_action_filter = bpy.props.CollectionProperty(type=GLTF2_filter_action) From 46724ca841a679545694011258589d052afed11f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 19:17:20 +1100 Subject: [PATCH 18/46] Fix #105164: Blender exits when QuadriFlow solver fails Replace calls to exit(..) with an error return value. --- extern/quadriflow/patches/blender.patch | 150 ++++++++++++++++++++++++ extern/quadriflow/src/main.cpp | 5 +- extern/quadriflow/src/parametrizer.cpp | 19 ++- extern/quadriflow/src/parametrizer.hpp | 3 +- extern/quadriflow/src/subdivide.cpp | 11 +- extern/quadriflow/src/subdivide.hpp | 3 +- intern/quadriflow/quadriflow_capi.cpp | 7 +- 7 files changed, 182 insertions(+), 16 deletions(-) diff --git a/extern/quadriflow/patches/blender.patch b/extern/quadriflow/patches/blender.patch index cc7a21adaa8..d74bd09f22f 100644 --- a/extern/quadriflow/patches/blender.patch +++ b/extern/quadriflow/patches/blender.patch @@ -375,6 +375,88 @@ index ab4a01c..a77f7ae 100644 }; class NetworkSimplexFlowHelper : public MaxFlowHelper { +diff --git a/extern/quadriflow/src/main.cpp b/extern/quadriflow/src/main.cpp +index 18bc4063c42..63c9e61b8c9 100644 +--- a/extern/quadriflow/src/main.cpp ++++ b/extern/quadriflow/src/main.cpp +@@ -110,7 +110,10 @@ int main(int argc, char** argv) { + printf("Use %lf seconds\n", (t2 - t1) * 1e-3); + t1 = GetCurrentTime64(); + printf("Solve index map...\n"); +- field.ComputeIndexMap(); ++ if (!field.ComputeIndexMap()) { ++ fprintf(stderr, "Failed to solve result, exiting!\n"); ++ return 1; ++ } + t2 = GetCurrentTime64(); + printf("Indexmap Use %lf seconds\n", (t2 - t1) * 1e-3); + printf("Writing the file...\n"); +diff --git a/extern/quadriflow/src/parametrizer.cpp b/extern/quadriflow/src/parametrizer.cpp +index b85383566c9..3dbdc386eca 100644 +--- a/extern/quadriflow/src/parametrizer.cpp ++++ b/extern/quadriflow/src/parametrizer.cpp +@@ -18,7 +18,7 @@ + + namespace qflow { + +-void Parametrizer::ComputeIndexMap(int with_scale) { ++bool Parametrizer::ComputeIndexMap(int with_scale) { + // build edge info + auto& V = hierarchy.mV[0]; + auto& F = hierarchy.mF; +@@ -80,9 +80,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { + #ifdef LOG_OUTPUT + printf("subdivide...\n"); + #endif +- subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, +- edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, +- singularities, 1); ++ if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, ++ edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, ++ singularities, 1)) ++ { ++ return false; ++ } + + allow_changes.clear(); + allow_changes.resize(edge_diff.size() * 2, 1); +@@ -99,9 +102,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { + int t1 = GetCurrentTime64(); + #endif + FixFlipHierarchy(); +- subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, ++ if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, + edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, +- singularities, 1); ++ singularities, 1)) ++ { ++ return false; ++ } + FixFlipSat(); + + #ifdef LOG_OUTPUT +@@ -242,6 +248,7 @@ void Parametrizer::ComputeIndexMap(int with_scale) { + // E2E_compact, + // V, N, Q, O, F, V2E, hierarchy.mE2E, disajoint_tree, + // hierarchy.mScale, false); ++ return true; + } + + } // namespace qflow +diff --git a/extern/quadriflow/src/parametrizer.hpp b/extern/quadriflow/src/parametrizer.hpp +index 1f4a02be6c2..9703ebbfff6 100644 +--- a/extern/quadriflow/src/parametrizer.hpp ++++ b/extern/quadriflow/src/parametrizer.hpp +@@ -54,7 +54,8 @@ class Parametrizer { + void ComputePositionSingularities(); + + // Integer Grid Map Pipeline +- void ComputeIndexMap(int with_scale = 0); ++ // Return false when the solver fails. ++ bool ComputeIndexMap(int with_scale = 0); + void BuildEdgeInfo(); + void ComputeMaxFlow(); + void MarkInteger(); diff --git a/extern/quadriflow/src/post-solver.cpp b/extern/quadriflow/src/post-solver.cpp index 6027ddd..ccefd15 100644 --- a/extern/quadriflow/src/post-solver.cpp @@ -389,3 +471,71 @@ index 6027ddd..ccefd15 100644 #include #include #include +diff --git a/extern/quadriflow/src/subdivide.cpp b/extern/quadriflow/src/subdivide.cpp +index c408bbc6394..babff96ccb4 100644 +--- a/extern/quadriflow/src/subdivide.cpp ++++ b/extern/quadriflow/src/subdivide.cpp +@@ -145,7 +145,7 @@ void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi + E2E.conservativeResize(nF * 3); + } + +-void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, ++bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, + VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, + std::vector &edge_diff, std::vector &edge_values, + std::vector &face_edgeOrients, std::vector &face_edgeIds, +@@ -500,17 +500,18 @@ void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, Matr + for (int j = 0; j < 3; ++j) { + auto diff = edge_diff[face_edgeIds[i][j]]; + if (abs(diff[0]) > 1 || abs(diff[1]) > 1) { +- printf("wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); +- exit(0); ++ fprintf(stderr, "wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); ++ return false; + } + } + } + for (int i = 0; i < edge_diff.size(); ++i) { + if (abs(edge_diff[i][0]) > 1 || abs(edge_diff[i][1]) > 1) { +- printf("wrong...\n"); +- exit(0); ++ fprintf(stderr, "wrong...\n"); ++ return false; + } + } ++ return true; + } + + } // namespace qflow +diff --git a/extern/quadriflow/src/subdivide.hpp b/extern/quadriflow/src/subdivide.hpp +index a93c58ac2a7..8c682b6d9f2 100644 +--- a/extern/quadriflow/src/subdivide.hpp ++++ b/extern/quadriflow/src/subdivide.hpp +@@ -9,7 +9,8 @@ namespace qflow { + void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, + VectorXi &nonmanifold, double maxLength); + +-void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, ++// Return false when solving fails. ++bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, + VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, + std::vector &edge_diff, std::vector &edge_values, + std::vector &face_edgeOrients, std::vector &face_edgeIds, +diff --git a/intern/quadriflow/quadriflow_capi.cpp b/intern/quadriflow/quadriflow_capi.cpp +index fad604f679a..014ac2a5613 100644 +--- a/intern/quadriflow/quadriflow_capi.cpp ++++ b/intern/quadriflow/quadriflow_capi.cpp +@@ -190,8 +190,11 @@ void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd, + return; + } + +- /* Compute the final quad geomtry using a maxflow solver */ +- field.ComputeIndexMap(); ++ /* Compute the final quad geometry using a maxflow solver */ ++ if (!field.ComputeIndexMap()) { ++ /* Error computing the result. */ ++ return; ++ } + + if (check_if_canceled(0.9f, update_cb, update_cb_data)) { + return; diff --git a/extern/quadriflow/src/main.cpp b/extern/quadriflow/src/main.cpp index 18bc4063c42..63c9e61b8c9 100644 --- a/extern/quadriflow/src/main.cpp +++ b/extern/quadriflow/src/main.cpp @@ -110,7 +110,10 @@ int main(int argc, char** argv) { printf("Use %lf seconds\n", (t2 - t1) * 1e-3); t1 = GetCurrentTime64(); printf("Solve index map...\n"); - field.ComputeIndexMap(); + if (!field.ComputeIndexMap()) { + fprintf(stderr, "Failed to solve result, exiting!\n"); + return 1; + } t2 = GetCurrentTime64(); printf("Indexmap Use %lf seconds\n", (t2 - t1) * 1e-3); printf("Writing the file...\n"); diff --git a/extern/quadriflow/src/parametrizer.cpp b/extern/quadriflow/src/parametrizer.cpp index b85383566c9..3dbdc386eca 100644 --- a/extern/quadriflow/src/parametrizer.cpp +++ b/extern/quadriflow/src/parametrizer.cpp @@ -18,7 +18,7 @@ namespace qflow { -void Parametrizer::ComputeIndexMap(int with_scale) { +bool Parametrizer::ComputeIndexMap(int with_scale) { // build edge info auto& V = hierarchy.mV[0]; auto& F = hierarchy.mF; @@ -80,9 +80,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { #ifdef LOG_OUTPUT printf("subdivide...\n"); #endif - subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, - edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, - singularities, 1); + if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, + edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, + singularities, 1)) + { + return false; + } allow_changes.clear(); allow_changes.resize(edge_diff.size() * 2, 1); @@ -99,9 +102,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { int t1 = GetCurrentTime64(); #endif FixFlipHierarchy(); - subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, + if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, - singularities, 1); + singularities, 1)) + { + return false; + } FixFlipSat(); #ifdef LOG_OUTPUT @@ -242,6 +248,7 @@ void Parametrizer::ComputeIndexMap(int with_scale) { // E2E_compact, // V, N, Q, O, F, V2E, hierarchy.mE2E, disajoint_tree, // hierarchy.mScale, false); + return true; } } // namespace qflow diff --git a/extern/quadriflow/src/parametrizer.hpp b/extern/quadriflow/src/parametrizer.hpp index 1f4a02be6c2..9703ebbfff6 100644 --- a/extern/quadriflow/src/parametrizer.hpp +++ b/extern/quadriflow/src/parametrizer.hpp @@ -54,7 +54,8 @@ class Parametrizer { void ComputePositionSingularities(); // Integer Grid Map Pipeline - void ComputeIndexMap(int with_scale = 0); + // Return false when the solver fails. + bool ComputeIndexMap(int with_scale = 0); void BuildEdgeInfo(); void ComputeMaxFlow(); void MarkInteger(); diff --git a/extern/quadriflow/src/subdivide.cpp b/extern/quadriflow/src/subdivide.cpp index c408bbc6394..babff96ccb4 100644 --- a/extern/quadriflow/src/subdivide.cpp +++ b/extern/quadriflow/src/subdivide.cpp @@ -145,7 +145,7 @@ void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi E2E.conservativeResize(nF * 3); } -void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, +bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, std::vector &edge_diff, std::vector &edge_values, std::vector &face_edgeOrients, std::vector &face_edgeIds, @@ -500,17 +500,18 @@ void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, Matr for (int j = 0; j < 3; ++j) { auto diff = edge_diff[face_edgeIds[i][j]]; if (abs(diff[0]) > 1 || abs(diff[1]) > 1) { - printf("wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); - exit(0); + fprintf(stderr, "wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); + return false; } } } for (int i = 0; i < edge_diff.size(); ++i) { if (abs(edge_diff[i][0]) > 1 || abs(edge_diff[i][1]) > 1) { - printf("wrong...\n"); - exit(0); + fprintf(stderr, "wrong...\n"); + return false; } } + return true; } } // namespace qflow diff --git a/extern/quadriflow/src/subdivide.hpp b/extern/quadriflow/src/subdivide.hpp index a93c58ac2a7..8c682b6d9f2 100644 --- a/extern/quadriflow/src/subdivide.hpp +++ b/extern/quadriflow/src/subdivide.hpp @@ -9,7 +9,8 @@ namespace qflow { void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, double maxLength); -void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, +// Return false when solving fails. +bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, std::vector &edge_diff, std::vector &edge_values, std::vector &face_edgeOrients, std::vector &face_edgeIds, diff --git a/intern/quadriflow/quadriflow_capi.cpp b/intern/quadriflow/quadriflow_capi.cpp index fad604f679a..014ac2a5613 100644 --- a/intern/quadriflow/quadriflow_capi.cpp +++ b/intern/quadriflow/quadriflow_capi.cpp @@ -190,8 +190,11 @@ void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd, return; } - /* Compute the final quad geomtry using a maxflow solver */ - field.ComputeIndexMap(); + /* Compute the final quad geometry using a maxflow solver */ + if (!field.ComputeIndexMap()) { + /* Error computing the result. */ + return; + } if (check_if_canceled(0.9f, update_cb, update_cb_data)) { return; From acf270b2162086c3474432e8847032288a708c97 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 19:39:34 +1100 Subject: [PATCH 19/46] Unbreak build WITH_INTERNATIONAL=OFF --- source/blender/blentranslation/CMakeLists.txt | 1 - source/blender/blentranslation/intern/blt_lang.cc | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/blender/blentranslation/CMakeLists.txt b/source/blender/blentranslation/CMakeLists.txt index fe0a068a1f3..772c739b39d 100644 --- a/source/blender/blentranslation/CMakeLists.txt +++ b/source/blender/blentranslation/CMakeLists.txt @@ -5,7 +5,6 @@ set(INC PUBLIC . ../makesrna - ../../../intern/locale ) set(INC_SYS diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index 112807a9ad7..4bbd23975af 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -32,17 +32,17 @@ #include "MEM_guardedalloc.h" +#include "CLG_log.h" + +static CLG_LogRef LOG = {"translation.language"}; + #ifdef WITH_INTERNATIONAL # include "BLI_fileops.h" # include "BLI_linklist.h" -# include "CLG_log.h" - # include "messages.hh" -static CLG_LogRef LOG = {"translation.language"}; - /* Locale options. */ static const char **locales = nullptr; static int num_locales = 0; From 6c05859b12fe972581dcc07674387d8e921d5e36 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 19:46:16 +1100 Subject: [PATCH 20/46] UI: mitigate problem where remesh could accidentally hang/crash Having a small voxel size meant typing in zero would clamp the voxel size to a small number which was often small enough to hang calculating large voxels which would eventually fail to allocate memory & crash. Instead, allow a zero value but bypass calculation. See #130526. --- source/blender/makesrna/intern/rna_modifier.cc | 8 +++++++- source/blender/modifiers/intern/MOD_remesh.cc | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index fa548247728..7f981f923b6 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -6350,9 +6350,11 @@ static void rna_def_modifier_remesh(BlenderRNA *brna) "edges closer to the input"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* NOTE: allow zero (which skips computation), to avoid zero clamping + * to a small value which is likely to run out of memory, see: #130526. */ prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, nullptr, "voxel_size"); - RNA_def_property_range(prop, 0.0001f, FLT_MAX); + RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0.0001, 2, 0.1, 3); RNA_def_property_ui_scale_type(prop, PROP_SCALE_LOG); RNA_def_property_ui_text(prop, @@ -8172,6 +8174,8 @@ static void rna_def_modifier_mesh_to_volume(BlenderRNA *brna) prop, "Resolution Mode", "Mode for how the desired voxel size is specified"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* NOTE: allow zero (which skips computation), to avoid zero clamping + * to a small value which is likely to run out of memory, see: #130526. */ prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text( prop, "Voxel Size", "Smaller values result in a higher resolution output"); @@ -8336,6 +8340,8 @@ static void rna_def_modifier_volume_to_mesh(BlenderRNA *brna) prop, "Resolution Mode", "Mode for how the desired voxel size is specified"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* NOTE: allow zero (which skips computation), to avoid zero clamping + * to a small value which is likely to run out of memory, see: #130526. */ prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text( prop, "Voxel Size", "Smaller values result in a higher resolution output"); diff --git a/source/blender/modifiers/intern/MOD_remesh.cc b/source/blender/modifiers/intern/MOD_remesh.cc index 281a7300a4e..b0536ae3927 100644 --- a/source/blender/modifiers/intern/MOD_remesh.cc +++ b/source/blender/modifiers/intern/MOD_remesh.cc @@ -127,7 +127,7 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4]) output->curface++; } -static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, Mesh *mesh) +static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { using namespace blender; RemeshModifierData *rmd; @@ -142,6 +142,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, if (rmd->mode == MOD_REMESH_VOXEL) { /* OpenVDB modes. */ if (rmd->voxel_size == 0.0f) { + BKE_modifier_set_error(ctx->object, md, "Zero voxel size cannot be solved"); return nullptr; } result = BKE_mesh_remesh_voxel(mesh, rmd->voxel_size, rmd->adaptivity, 0.0f); @@ -150,6 +151,11 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, } } else { + if (rmd->scale == 0.0f) { + BKE_modifier_set_error(ctx->object, md, "Zero scale cannot be solved"); + return nullptr; + } + /* Dualcon modes. */ init_dualcon_mesh(&input, mesh); From e8ebbce9c54f2f0dd238b64c2548c3d28bc5ed98 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Jan 2025 19:57:23 +1100 Subject: [PATCH 21/46] Cleanup: update naming for dualcon: rename loop corner_verts These weren't the equivalent of MLoop's even with the old naming this was misleading, especially `DualConInput::mloop`. --- intern/dualcon/dualcon.h | 6 +++--- intern/dualcon/intern/dualcon_c_api.cpp | 10 +++++----- source/blender/modifiers/intern/MOD_remesh.cc | 17 ++++++++--------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/intern/dualcon/dualcon.h b/intern/dualcon/dualcon.h index f442fc7e647..53d7a7b313c 100644 --- a/intern/dualcon/dualcon.h +++ b/intern/dualcon/dualcon.h @@ -15,10 +15,10 @@ typedef float (*DualConCo)[3]; typedef unsigned int (*DualConTri)[3]; -typedef unsigned int *DualConLoop; +typedef unsigned int *DualConCornerVerts; typedef struct DualConInput { - DualConLoop mloop; + DualConCornerVerts corner_verts; DualConCo co; int co_stride; @@ -28,7 +28,7 @@ typedef struct DualConInput { int tri_stride; int tottri; - int loop_stride; + int corner_verts_stride; float min[3], max[3]; } DualConInput; diff --git a/intern/dualcon/intern/dualcon_c_api.cpp b/intern/dualcon/intern/dualcon_c_api.cpp index 29c14180980..10399247bea 100644 --- a/intern/dualcon/intern/dualcon_c_api.cpp +++ b/intern/dualcon/intern/dualcon_c_api.cpp @@ -26,8 +26,8 @@ static void veccopy(float dst[3], const float src[3]) #define GET_CO(_mesh, _n) (*(DualConCo)(((char *)(_mesh)->co) + ((_n) * (_mesh)->co_stride))) -#define GET_LOOP(_mesh, _n) \ - (*(DualConLoop)(((char *)(_mesh)->mloop) + ((_n) * (_mesh)->loop_stride))) +#define GET_CORNER_VERT(_mesh, _n) \ + (*(DualConCornerVerts)(((char *)(_mesh)->corner_verts) + ((_n) * (_mesh)->corner_verts_stride))) class DualConInputReader : public ModelReader { private: @@ -80,9 +80,9 @@ class DualConInputReader : public ModelReader { Triangle *t = new Triangle(); const unsigned int *tr = GET_TRI(input_mesh, curtri); - veccopy(t->vt[0], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[0]))); - veccopy(t->vt[1], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[1]))); - veccopy(t->vt[2], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[2]))); + veccopy(t->vt[0], GET_CO(input_mesh, GET_CORNER_VERT(input_mesh, tr[0]))); + veccopy(t->vt[1], GET_CO(input_mesh, GET_CORNER_VERT(input_mesh, tr[1]))); + veccopy(t->vt[2], GET_CO(input_mesh, GET_CORNER_VERT(input_mesh, tr[2]))); curtri++; diff --git a/source/blender/modifiers/intern/MOD_remesh.cc b/source/blender/modifiers/intern/MOD_remesh.cc index b0536ae3927..1ca1b5c3236 100644 --- a/source/blender/modifiers/intern/MOD_remesh.cc +++ b/source/blender/modifiers/intern/MOD_remesh.cc @@ -61,8 +61,8 @@ static void init_dualcon_mesh(DualConInput *input, Mesh *mesh) input->co_stride = sizeof(blender::float3); input->totco = mesh->verts_num; - input->mloop = (DualConLoop)mesh->corner_verts().data(); - input->loop_stride = sizeof(int); + input->corner_verts = (DualConCornerVerts)mesh->corner_verts().data(); + input->corner_verts_stride = sizeof(int); input->corner_tris = (DualConTri)mesh->corner_tris().data(); input->tri_stride = sizeof(blender::int3); @@ -130,14 +130,8 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4]) static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { using namespace blender; - RemeshModifierData *rmd; - DualConOutput *output; - DualConInput input; + RemeshModifierData *rmd = (RemeshModifierData *)md; Mesh *result; - DualConFlags flags = DualConFlags(0); - DualConMode mode = DualConMode(0); - - rmd = (RemeshModifierData *)md; if (rmd->mode == MOD_REMESH_VOXEL) { /* OpenVDB modes. */ @@ -156,6 +150,11 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh return nullptr; } + DualConOutput *output; + DualConInput input; + DualConFlags flags = DualConFlags(0); + DualConMode mode = DualConMode(0); + /* Dualcon modes. */ init_dualcon_mesh(&input, mesh); From c749f6c3769eb05af4494bcded9e363caa1657c1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Jan 2025 10:02:22 +0100 Subject: [PATCH 22/46] Cleanup: Remove unnecessary usage of Boost in the build system * Some libraries like Alembic and OpenColorIO for a long time removed header dependencies on Boost. * No need to have BOOST_LIBRARIES anymore, only BOOST_PYTHON_LIBRARIES is a direct dependency through USD headers. * OpenVDB is no longer a static library, no need to link its dependencies. Pull Request: https://projects.blender.org/blender/blender/pulls/133424 --- CMakeLists.txt | 27 ------------------- .../cmake/platform/platform_apple.cmake | 4 +-- .../cmake/platform/platform_unix.cmake | 13 +-------- .../cmake/platform/platform_win32.cmake | 3 +-- intern/cycles/cmake/macros.cmake | 1 - intern/opencolorio/CMakeLists.txt | 9 ------- source/blender/io/alembic/CMakeLists.txt | 12 --------- .../blender/io/grease_pencil/CMakeLists.txt | 6 ----- source/blender/io/usd/CMakeLists.txt | 1 - source/blender/render/hydra/CMakeLists.txt | 1 - 10 files changed, 3 insertions(+), 74 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f22f8b4a22..7153b6340e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,13 +567,6 @@ Try to link with static libraries, as much as possible, \ to make blender more portable across distributions" OFF ) - if(WITH_STATIC_LIBS) - option(WITH_BOOST_ICU "\ -Boost uses ICU library (required for linking with static Boost built with libicu)." - OFF - ) - mark_as_advanced(WITH_BOOST_ICU) - endif() endif() # Misc @@ -1513,16 +1506,6 @@ endif() # ----------------------------------------------------------------------------- # Common Checks for Compatible Options -if(WITH_INTERNATIONAL) - if(NOT WITH_BOOST) - message( - FATAL_ERROR - "Internationalization requires WITH_BOOST, the library may not have been found. " - "Configure BOOST or disable WITH_INTERNATIONAL" - ) - endif() -endif() - # Enable SIMD support if detected by `test_sse_support()` or `test_neon_support()`. # if(WITH_CPU_SIMD) @@ -1627,19 +1610,9 @@ if(WITH_OPENVDB) ${OPENEXR_INCLUDE_DIRS} ) - list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES}) - if(WITH_OPENVDB_BLOSC) list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB_BLOSC) - # Even when `WITH_OPENVDB_BLOSC` is set, `FindBlosc.cmake` isn't running. - # As this might be used at some point, check the libraries are defined. - if(DEFINED BLOSC_LIBRARIES) - list(APPEND OPENVDB_LIBRARIES ${BLOSC_LIBRARIES}) - endif() - list(APPEND OPENVDB_LIBRARIES ${ZLIB_LIBRARIES}) endif() - - list(APPEND OPENVDB_LIBRARIES ${BOOST_LIBRARIES} ${TBB_LIBRARIES}) endif() # ----------------------------------------------------------------------------- diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 7d6f0cdde7d..c83f6370174 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -262,11 +262,9 @@ if(WITH_BOOST) set(Boost_NO_WARN_NEW_VERSIONS ON) find_package(Boost COMPONENTS ${_boost_FIND_COMPONENTS}) - # Boost Python is separate to avoid linking Python into tests that don't need it. - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + # Boost Python is the only library Blender directly depends on, though USD headers. if(WITH_USD AND USD_PYTHON_SUPPORT) set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY}) - list(REMOVE_ITEM BOOST_LIBRARIES ${BOOST_PYTHON_LIBRARIES}) endif() set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) set(BOOST_DEFINITIONS) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 66dee945388..8112ce0e4c8 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -475,7 +475,6 @@ if(WITH_BOOST) if(WITH_USD AND USD_PYTHON_SUPPORT) list(APPEND __boost_packages python${PYTHON_VERSION_NO_DOTS}) endif() - list(APPEND __boost_packages system) set(Boost_NO_WARN_NEW_VERSIONS ON) find_package(Boost 1.48 COMPONENTS ${__boost_packages}) if(NOT Boost_FOUND) @@ -486,27 +485,17 @@ if(WITH_BOOST) find_package(Boost 1.48 COMPONENTS ${__boost_packages}) endif() unset(__boost_packages) - if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) - find_package(IcuLinux) - endif() mark_as_advanced(Boost_DIR) # why doesn't boost do this? mark_as_advanced(Boost_INCLUDE_DIR) # why doesn't boost do this? endif() - # Boost Python is separate to avoid linking Python into tests that don't need it. - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + # Boost Python is the only library Blender directly depends on, though USD headers. if(WITH_USD AND USD_PYTHON_SUPPORT) set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY}) - list(REMOVE_ITEM BOOST_LIBRARIES ${BOOST_PYTHON_LIBRARIES}) endif() set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") - - if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) - find_package(IcuLinux) - list(APPEND BOOST_LIBRARIES ${ICU_LIBRARIES}) - endif() endif() add_bundled_libraries(boost/lib) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 1f1d8c926a5..a06766b4af2 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -696,8 +696,8 @@ if(WITH_BOOST) set(BOOST_DEBUG_POSTFIX "vc142-mt-gd-x64-${BOOST_VERSION}") set(BOOST_PREFIX "lib") endif() - set(BOOST_LIBRARIES) if(EXISTS ${BOOST_34_TRIGGER_FILE}) + # Boost Python is the only library Blender directly depends on, though USD headers. if(WITH_USD) set(BOOST_PYTHON_LIBRARIES debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python${_PYTHON_VERSION_NO_DOTS}-${BOOST_DEBUG_POSTFIX}.lib @@ -707,7 +707,6 @@ if(WITH_BOOST) endif() else() # we found boost using find_package set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) endif() diff --git a/intern/cycles/cmake/macros.cmake b/intern/cycles/cmake/macros.cmake index 1bb7283c723..348ae3b3709 100644 --- a/intern/cycles/cmake/macros.cmake +++ b/intern/cycles/cmake/macros.cmake @@ -146,7 +146,6 @@ macro(cycles_external_libraries_append libraries) ${OPENEXR_LIBRARIES} ${OPENEXR_LIBRARIES} # For circular dependencies between libs. ${PUGIXML_LIBRARIES} - ${BOOST_LIBRARIES} ${PYTHON_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index 10d2cefe800..d3eada1ddc1 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -48,15 +48,6 @@ if(WITH_OPENCOLORIO) ${OPENCOLORIO_LIBRARIES} ) - if(WIN32) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) - endif() - set(GLSL_SRC gpu_shader_display_transform_vert.glsl gpu_shader_display_transform_frag.glsl diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt index 0bfe03278a1..441cfd8bd5d 100644 --- a/source/blender/io/alembic/CMakeLists.txt +++ b/source/blender/io/alembic/CMakeLists.txt @@ -15,12 +15,6 @@ set(INC_SYS ${OPENEXR_INCLUDE_DIRS} ) -if(WITH_BOOST) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) -endif() - set(SRC intern/abc_axis_conversion.cc intern/abc_customdata.cc @@ -95,12 +89,6 @@ set(LIB PRIVATE bf::windowmanager ) -if(WITH_BOOST) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) -endif() - blender_add_lib(bf_io_alembic "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") if(WITH_GTESTS) diff --git a/source/blender/io/grease_pencil/CMakeLists.txt b/source/blender/io/grease_pencil/CMakeLists.txt index 0d2be5e38bb..67fdc38e343 100644 --- a/source/blender/io/grease_pencil/CMakeLists.txt +++ b/source/blender/io/grease_pencil/CMakeLists.txt @@ -72,10 +72,4 @@ if(WITH_HARU) add_definitions(-DWITH_HARU) endif() -if(WITH_BOOST) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) -endif() - blender_add_lib(bf_io_grease_pencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt index cc1a1e4052e..abd02523c34 100644 --- a/source/blender/io/usd/CMakeLists.txt +++ b/source/blender/io/usd/CMakeLists.txt @@ -206,7 +206,6 @@ set(LIB ) list(APPEND LIB - ${BOOST_LIBRARIES} ${BOOST_PYTHON_LIBRARIES} ${PYTHON_LIBRARIES} ${USD_LIBRARIES} diff --git a/source/blender/render/hydra/CMakeLists.txt b/source/blender/render/hydra/CMakeLists.txt index d1c4ccc85eb..955661ee0e0 100644 --- a/source/blender/render/hydra/CMakeLists.txt +++ b/source/blender/render/hydra/CMakeLists.txt @@ -67,7 +67,6 @@ set(INC_SYS set(LIB ${Epoxy_LIBRARIES} ${PYTHON_LIBRARIES} - ${BOOST_LIBRARIES} ${USD_LIBRARIES} ${TBB_LIBRARIES} PRIVATE bf::blenkernel From 446b2a983df58e2623fb2c90450b3cc603491f7c Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Wed, 22 Jan 2025 10:43:09 +0100 Subject: [PATCH 23/46] Fix: Variable referenced in UI code without being assigned Mistake in d4d046a67334b7aacf85b5e7267b95dda10c76b2 Right now python error is triggered with empty material slot. Pull Request: https://projects.blender.org/blender/blender/pulls/133287 --- scripts/startup/bl_ui/properties_material_gpencil.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/properties_material_gpencil.py b/scripts/startup/bl_ui/properties_material_gpencil.py index 976823d6f23..ba0dcec463e 100644 --- a/scripts/startup/bl_ui/properties_material_gpencil.py +++ b/scripts/startup/bl_ui/properties_material_gpencil.py @@ -46,8 +46,12 @@ class GPENCIL_UL_matslots(UIList): def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index): slot = item ma = slot.material - if (ma is not None) and (ma.grease_pencil is not None): - gpcolor = ma.grease_pencil + + if ma is None: + return + + if (gpcolor := ma.grease_pencil) is None: + return if self.layout_type in {'DEFAULT', 'COMPACT'}: row = layout.row(align=True) From e98b45beb1c6eb3eb475ffed80c98b6780b72947 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Jan 2025 10:49:39 +0100 Subject: [PATCH 24/46] Fix: Cycles CPU render wrong with latest OSL 1.14 --- intern/cycles/kernel/osl/types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/intern/cycles/kernel/osl/types.h b/intern/cycles/kernel/osl/types.h index d81833a5582..e25900701ec 100644 --- a/intern/cycles/kernel/osl/types.h +++ b/intern/cycles/kernel/osl/types.h @@ -17,7 +17,11 @@ CCL_NAMESPACE_BEGIN /* Strings are represented by their hashes on the GPU. */ using DeviceString = size_t; #elif defined(OPENIMAGEIO_USTRING_H) +# if OSL_LIBRARY_VERSION_CODE >= 11400 +using DeviceString = ustringhash; +# else using DeviceString = ustring; +# endif #else using DeviceString = const char *; #endif From 7a0a173d3961b795c8e3837a173c635db92c22b6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Jan 2025 11:19:02 +0100 Subject: [PATCH 25/46] Fix: Missed case of OCIO luminance coefficients in EEVEE Following up on #133368. Thanks Omar for spotting this. Pull Request: https://projects.blender.org/blender/blender/pulls/133400 --- ...gpu_shader_compositor_type_conversion.glsl | 2 +- source/blender/gpu/intern/gpu_codegen.cc | 38 +++++++++++++------ .../gpu/shaders/gpu_shader_codegen_lib.glsl | 4 +- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl b/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl index eaa344916e1..a45db4dba5a 100644 --- a/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl +++ b/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl @@ -84,7 +84,7 @@ vec4 color_to_vector(vec4 value) * Those should have the same interface and names as the macros in gpu_shader_codegen_lib.glsl * since the GPUMaterial compiler inserts those hard coded names. */ -float float_from_vec4(vec4 vector) +float float_from_vec4(vec4 vector, vec3 luminance_coefficients) { return dot(vector.rgb, vec3(1.0)) / 3.0; } diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 5cccf067f0e..a6dd3ae5060 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -18,6 +18,7 @@ #include "BLI_hash_mm2a.hh" #include "BLI_link_utils.h" #include "BLI_listbase.h" +#include "BLI_span.hh" #include "BLI_string.h" #include "BLI_threads.h" #include "BLI_time.h" @@ -26,6 +27,8 @@ #include "BKE_cryptomatte.hh" #include "BKE_material.hh" +#include "IMB_colormanagement.hh" + #include "GPU_capabilities.hh" #include "GPU_context.hh" #include "GPU_material.hh" @@ -232,21 +235,18 @@ static std::ostream &operator<<(std::ostream &stream, const GPUOutput *output) return stream << SRC_NAME("out", output, outputs, "tmp") << output->id; } -/* Trick type to change overload and keep a somewhat nice syntax. */ -struct GPUConstant : public GPUInput {}; - /* Print data constructor (i.e: vec2(1.0f, 1.0f)). */ -static std::ostream &operator<<(std::ostream &stream, const GPUConstant *input) +static std::ostream &operator<<(std::ostream &stream, const blender::Span &span) { - stream << input->type << "("; - for (int i = 0; i < input->type; i++) { + stream << (eGPUType)span.size() << "("; + /* Use uint representation to allow exact same bit pattern even if NaN. This is + * because we can pass UINTs as floats for constants. */ + const blender::Span uint_span = span.cast(); + for (const uint32_t &element : uint_span) { char formatted_float[32]; - /* Use uint representation to allow exact same bit pattern even if NaN. This is because we can - * pass UINTs as floats for constants. */ - const uint32_t *uint_vec = reinterpret_cast(input->vec); - SNPRINTF(formatted_float, "uintBitsToFloat(%uu)", uint_vec[i]); + SNPRINTF(formatted_float, "uintBitsToFloat(%uu)", element); stream << formatted_float; - if (i < input->type - 1) { + if (&element != &uint_span.last()) { stream << ", "; } } @@ -254,6 +254,15 @@ static std::ostream &operator<<(std::ostream &stream, const GPUConstant *input) return stream; } +/* Trick type to change overload and keep a somewhat nice syntax. */ +struct GPUConstant : public GPUInput {}; + +static std::ostream &operator<<(std::ostream &stream, const GPUConstant *input) +{ + stream << blender::Span(input->vec, input->type); + return stream; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -532,6 +541,13 @@ void GPUCodegen::node_serialize(std::stringstream &eval_ss, const GPUNode *node) } if (from != to) { + /* Special case that needs luminance coefficients as argument. */ + if (from == GPU_VEC4 && to == GPU_FLOAT) { + float coefficients[3]; + IMB_colormanagement_get_luminance_coefficients(coefficients); + eval_ss << ", " << blender::Span(coefficients, 3); + } + eval_ss << ")"; } break; diff --git a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl index d140521231c..03899ee3bdb 100644 --- a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl @@ -103,8 +103,8 @@ vec4 tangent_get(vec4 attr, mat3 normalmat) #endif -/* Assumes GPU_VEC4 is color data. So converting to luminance like cycles. */ -#define float_from_vec4(v) dot(v.rgb, vec3(0.2126, 0.7152, 0.0722)) +/* Assumes GPU_VEC4 is color data, special case that needs luminance coefficients from OCIO. */ +#define float_from_vec4(v, luminance_coefficients) dot(v.rgb, luminance_coefficients) #define float_from_vec3(v) ((v.r + v.g + v.b) * (1.0 / 3.0)) #define float_from_vec2(v) v.r From 517aa5bfe24f975b3261c8a3e9aeba461d3412ea Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 22 Jan 2025 12:14:51 +0100 Subject: [PATCH 26/46] Fix #113760: Knife Tool: wrong red point after undo After confirming a cut, the tool goes into `MODE_IDLE`. In `knifetool_undo`, the `KnifePosData` `prev` (drawn as the "red point" in question in `knifetool_draw`) was only set to the `KnifeUndoFrame` pos when we are in `MODE_DRAGGING` though -- this is now changed to also be done for `MODE_IDLE`. NOTE: it might be questionable to even draw this bigger red dot once a cut is confirmed (will attach another small diff to the PR that does this) Pull Request: https://projects.blender.org/blender/blender/pulls/133430 --- source/blender/editors/mesh/editmesh_knife.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_knife.cc b/source/blender/editors/mesh/editmesh_knife.cc index ba7ea3532b5..5aad6232fad 100644 --- a/source/blender/editors/mesh/editmesh_knife.cc +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -3862,7 +3862,7 @@ static void knifetool_undo(KnifeTool_OpData *kcd) } } - if (kcd->mode == MODE_DRAGGING) { + if (ELEM(kcd->mode, MODE_DRAGGING, MODE_IDLE)) { /* Restore kcd->prev. */ kcd->prev = undo->pos; } From 9d5a4756caac149e1d3c84c1f916d2aa535915ad Mon Sep 17 00:00:00 2001 From: Nika Kutsniashvili Date: Wed, 22 Jan 2025 12:57:46 +0100 Subject: [PATCH 27/46] UI: Use gizmo theme colors for knife tool overlay Knife Tool overlays were using NURBS theme colors, make it use gizmo colors instead. More details and screenshots in the PR. Fixes #126867 Pull Request: https://projects.blender.org/blender/blender/pulls/133395 --- source/blender/editors/mesh/editmesh_knife.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.cc b/source/blender/editors/mesh/editmesh_knife.cc index 5aad6232fad..3af7969a2c1 100644 --- a/source/blender/editors/mesh/editmesh_knife.cc +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -3918,14 +3918,14 @@ static void knife_init_colors(KnifeColors *colors) /* Possible BMESH_TODO: add explicit themes or calculate these by * figuring out contrasting colors with grid / edges / verts * a la UI_make_axis_color. */ - UI_GetThemeColorType3ubv(TH_NURB_VLINE, SPACE_VIEW3D, colors->line); - UI_GetThemeColorType3ubv(TH_NURB_ULINE, SPACE_VIEW3D, colors->edge); - UI_GetThemeColorType3ubv(TH_NURB_SEL_ULINE, SPACE_VIEW3D, colors->edge_extra); - UI_GetThemeColorType3ubv(TH_HANDLE_SEL_VECT, SPACE_VIEW3D, colors->curpoint); - UI_GetThemeColorType3ubv(TH_HANDLE_SEL_VECT, SPACE_VIEW3D, colors->curpoint_a); + UI_GetThemeColorType3ubv(TH_GIZMO_PRIMARY, SPACE_VIEW3D, colors->line); + UI_GetThemeColorType3ubv(TH_GIZMO_A, SPACE_VIEW3D, colors->edge); + UI_GetThemeColorType3ubv(TH_GIZMO_B, SPACE_VIEW3D, colors->edge_extra); + UI_GetThemeColorType3ubv(TH_GIZMO_SECONDARY, SPACE_VIEW3D, colors->curpoint); + UI_GetThemeColorType3ubv(TH_GIZMO_SECONDARY, SPACE_VIEW3D, colors->curpoint_a); colors->curpoint_a[3] = 102; - UI_GetThemeColorType3ubv(TH_ACTIVE_SPLINE, SPACE_VIEW3D, colors->point); - UI_GetThemeColorType3ubv(TH_ACTIVE_SPLINE, SPACE_VIEW3D, colors->point_a); + UI_GetThemeColorType3ubv(TH_VERTEX, SPACE_VIEW3D, colors->point); + UI_GetThemeColorType3ubv(TH_VERTEX, SPACE_VIEW3D, colors->point_a); colors->point_a[3] = 102; UI_GetThemeColorType3ubv(TH_AXIS_X, SPACE_VIEW3D, colors->xaxis); From 8620f0286a43e2a35562bb4c96e871296606b92e Mon Sep 17 00:00:00 2001 From: YimingWu Date: Wed, 22 Jan 2025 13:00:01 +0100 Subject: [PATCH 28/46] Fix #133414: Sequencer: Ensure valid UTF-8 sequence when pasting text `TextVars::text` is only 512 bytes and does not include string ending byte, and `sequencer_text_edit_paste_exec` uses a very simple truncation that didn't guarantee valid UTF-8 sequence at the end. This is now fixed by using `BLI_str_utf8_invalid_strip` after truncating the string. Pull Request: https://projects.blender.org/blender/blender/pulls/133416 --- .../space_sequencer/sequencer_text_edit.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_text_edit.cc b/source/blender/editors/space_sequencer/sequencer_text_edit.cc index ab8210bec27..fcf44fc84d4 100644 --- a/source/blender/editors/space_sequencer/sequencer_text_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_text_edit.cc @@ -820,16 +820,23 @@ static int sequencer_text_edit_paste_exec(bContext *C, wmOperator * /*op*/) } const int max_str_len = sizeof(data->text) - (BLI_strnlen(data->text, sizeof(data->text)) + 1); - clipboard_len = std::min(clipboard_len, max_str_len); + + /* Maximum bytes that can be filled into `data->text`. */ + const int fillable_len = std::min(clipboard_len, max_str_len); + + /* Truncated string could contain invalid utf-8 sequence, thus ensure the length inserted is + * always valid. */ + size_t valid_str_len; + const int extra_offset = BLI_strnlen_utf8_ex(clipboard_buf, fillable_len, &valid_str_len); const seq::CharInfo cur_char = character_at_cursor_offset_get(text, data->cursor_offset); char *cursor_addr = const_cast(cur_char.str_ptr); const size_t move_str_len = BLI_strnlen(cursor_addr, sizeof(data->text)) + 1; - std::memmove(cursor_addr + clipboard_len, cursor_addr, move_str_len); - std::memcpy(cursor_addr, clipboard_buf, clipboard_len); + std::memmove(cursor_addr + valid_str_len, cursor_addr, move_str_len); + std::memcpy(cursor_addr, clipboard_buf, valid_str_len); - data->cursor_offset += BLI_strlen_utf8(clipboard_buf); + data->cursor_offset += extra_offset; MEM_freeN(clipboard_buf); text_editing_update(C); From 7177dca600fe0369e1ceda492475faaf861ec09f Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 22 Jan 2025 14:05:59 +0100 Subject: [PATCH 29/46] Fix: Incorrect interface/tooltip translation check These panel header labels should be translated when the interface is translated but they checked for tooltip translation instead. Pull Request: https://projects.blender.org/blender/blender/pulls/133412 --- .../nodes/geometry/nodes/node_geo_attribute_capture.cc | 2 +- source/blender/nodes/geometry/nodes/node_geo_bake.cc | 4 ++-- .../geometry/nodes/node_geo_foreach_geometry_element.cc | 6 +++--- .../blender/nodes/geometry/nodes/node_geo_index_switch.cc | 2 +- source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc | 3 ++- source/blender/nodes/geometry/nodes/node_geo_repeat.cc | 2 +- source/blender/nodes/geometry/nodes/node_geo_simulation.cc | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index bd8ceb46405..161fa7a2c4a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -77,7 +77,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) uiItemR(layout, ptr, "domain", UI_ITEM_NONE, "", ICON_NONE); if (uiLayout *panel = uiLayoutPanel( - C, layout, "capture_attribute_items", false, TIP_("Capture Items"))) + C, layout, "capture_attribute_items", false, IFACE_("Capture Items"))) { socket_items::ui::draw_items_list_with_operators( C, panel, tree, node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_bake.cc b/source/blender/nodes/geometry/nodes/node_geo_bake.cc index a1e6945aece..685790d06d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bake.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bake.cc @@ -135,7 +135,7 @@ static void draw_bake_items(const bContext *C, uiLayout *layout, PointerRNA node bNode &node = *static_cast(node_ptr.data); NodeGeometryBake &storage = node_storage(node); - if (uiLayout *panel = uiLayoutPanel(C, layout, "bake_items", false, TIP_("Bake Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "bake_items", false, IFACE_("Bake Items"))) { socket_items::ui::draw_items_list_with_operators(C, panel, tree, node); socket_items::ui::draw_active_item_props( tree, node, [&](PointerRNA *item_ptr) { @@ -879,7 +879,7 @@ void draw_data_blocks(const bContext *C, uiLayout *layout, PointerRNA &bake_rna) bake_rna.owner_id, &RNA_NodesModifierBakeDataBlocks, bake_rna.data); if (uiLayout *panel = uiLayoutPanel( - C, layout, "data_block_references", true, TIP_("Data-Block References"))) + C, layout, "data_block_references", true, IFACE_("Data-Block References"))) { uiTemplateList(panel, C, diff --git a/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc b/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc index c0954b74929..8ed2f77ab06 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc @@ -50,7 +50,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no auto &storage = *static_cast(output_node.storage); if (is_zone_input_node) { - if (uiLayout *panel = uiLayoutPanel(C, layout, "input", false, TIP_("Input Fields"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "input", false, IFACE_("Input Fields"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); socket_items::ui::draw_active_item_props( @@ -62,7 +62,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no } } else { - if (uiLayout *panel = uiLayoutPanel(C, layout, "main_items", false, TIP_("Main Geometry"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "main_items", false, IFACE_("Main Geometry"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); socket_items::ui::draw_active_item_props( @@ -73,7 +73,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no }); } if (uiLayout *panel = uiLayoutPanel( - C, layout, "generation_items", false, TIP_("Generated Geometry"))) + C, layout, "generation_items", false, IFACE_("Generated Geometry"))) { socket_items::ui::draw_items_list_with_operators< ForeachGeometryElementGenerationItemsAccessor>(C, panel, ntree, output_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc index 93795095966..31852a007d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc @@ -70,7 +70,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { bNode &node = *static_cast(ptr->data); NodeIndexSwitch &storage = node_storage(node); - if (uiLayout *panel = uiLayoutPanel(C, layout, "index_switch_items", false, TIP_("Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "index_switch_items", false, IFACE_("Items"))) { uiItemO(panel, IFACE_("Add Item"), ICON_ADD, "node.index_switch_item_add"); uiLayout *col = uiLayoutColumn(panel, false); for (const int i : IndexRange(storage.items_num)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc index a57c910cc31..44070d7d82a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc @@ -361,7 +361,8 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) uiItemR(layout, ptr, "data_type", UI_ITEM_NONE, "", ICON_NONE); - if (uiLayout *panel = uiLayoutPanel(C, layout, "menu_switch_items", false, TIP_("Menu Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "menu_switch_items", false, IFACE_("Menu Items"))) + { socket_items::ui::draw_items_list_with_operators( C, panel, tree, node); socket_items::ui::draw_active_item_props( diff --git a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc index a2e93c02328..9698e5c8786 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc @@ -48,7 +48,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no PointerRNA output_node_ptr = RNA_pointer_create( current_node_ptr->owner_id, &RNA_Node, &output_node); - if (uiLayout *panel = uiLayoutPanel(C, layout, "repeat_items", false, TIP_("Repeat Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "repeat_items", false, IFACE_("Repeat Items"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); socket_items::ui::draw_active_item_props( diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc index 0f75647e948..fc1237fe07d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc @@ -199,7 +199,7 @@ static void draw_simulation_state(const bContext *C, bNode &output_node) { if (uiLayout *panel = uiLayoutPanel( - C, layout, "simulation_state_items", false, TIP_("Simulation State"))) + C, layout, "simulation_state_items", false, IFACE_("Simulation State"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); From 19e9092cb64764183e83569ff631be16babdd399 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Wed, 22 Jan 2025 15:11:22 +0200 Subject: [PATCH 30/46] Cleanup: Remove check for SSE4.1 in denoise node Blender now has a minimum requirement of 4.2, so no need to check for SSE4.2 support in the denoise node. --- .../composite/nodes/node_composite_denoise.cc | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index 8e0864276af..04b9579eb87 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -62,13 +62,6 @@ static void node_composit_buts_denoise(uiLayout *layout, bContext * /*C*/, Point { #ifndef WITH_OPENIMAGEDENOISE uiItemL(layout, RPT_("Disabled, built without OpenImageDenoise"), ICON_ERROR); -#else - /* Always supported through Accelerate framework BNNS on macOS. */ -# ifndef __APPLE__ - if (!BLI_cpu_support_sse42()) { - uiItemL(layout, RPT_("Disabled, CPU with SSE4.2 is required"), ICON_ERROR); - } -# endif #endif uiItemL(layout, IFACE_("Prefilter:"), ICON_NONE); @@ -297,19 +290,13 @@ class DenoiseOperation : public NodeOperation { } #endif /* WITH_OPENIMAGEDENOISE */ - /* OIDN can be disabled as a build option, so check WITH_OPENIMAGEDENOISE. Additionally, it is - * only supported at runtime for CPUs that supports SSE4.1, except for MacOS where it is always - * supported through the Accelerate framework BNNS on macOS. */ + /* OIDN can be disabled as a build option, so check WITH_OPENIMAGEDENOISE. */ bool is_oidn_supported() { -#ifndef WITH_OPENIMAGEDENOISE - return false; -#else -# ifdef __APPLE__ +#ifdef WITH_OPENIMAGEDENOISE return true; -# else - return BLI_cpu_support_sse42(); -# endif +#else + return false; #endif } }; From 549c724f78b00b40d4a6a3e10488bc189f8afa18 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Wed, 22 Jan 2025 16:15:21 +0200 Subject: [PATCH 31/46] Revert "Cleanup: Remove check for SSE4.1 in denoise node" This reverts commit 19e9092cb64764183e83569ff631be16babdd399. The minimum requirement is for builds that Blender officially provides. We still need to maintain code for none SSE builds. --- .../composite/nodes/node_composite_denoise.cc | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index 04b9579eb87..8e0864276af 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -62,6 +62,13 @@ static void node_composit_buts_denoise(uiLayout *layout, bContext * /*C*/, Point { #ifndef WITH_OPENIMAGEDENOISE uiItemL(layout, RPT_("Disabled, built without OpenImageDenoise"), ICON_ERROR); +#else + /* Always supported through Accelerate framework BNNS on macOS. */ +# ifndef __APPLE__ + if (!BLI_cpu_support_sse42()) { + uiItemL(layout, RPT_("Disabled, CPU with SSE4.2 is required"), ICON_ERROR); + } +# endif #endif uiItemL(layout, IFACE_("Prefilter:"), ICON_NONE); @@ -290,13 +297,19 @@ class DenoiseOperation : public NodeOperation { } #endif /* WITH_OPENIMAGEDENOISE */ - /* OIDN can be disabled as a build option, so check WITH_OPENIMAGEDENOISE. */ + /* OIDN can be disabled as a build option, so check WITH_OPENIMAGEDENOISE. Additionally, it is + * only supported at runtime for CPUs that supports SSE4.1, except for MacOS where it is always + * supported through the Accelerate framework BNNS on macOS. */ bool is_oidn_supported() { -#ifdef WITH_OPENIMAGEDENOISE - return true; -#else +#ifndef WITH_OPENIMAGEDENOISE return false; +#else +# ifdef __APPLE__ + return true; +# else + return BLI_cpu_support_sse42(); +# endif #endif } }; From c0e881cebf6eb7aac66e25d58df4435e33d32daf Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 22 Jan 2025 15:25:25 +0100 Subject: [PATCH 32/46] Sculpt: avoid adding ".sculpt_mask" attributes in certain cases Mask layers were added (unnecessarily) in these cases: - calling `Mask Slice` without having a mask even (now return `OPERATOR_CANCELLED` early) - calling `Mask Extract` without having a mask even (now return `OPERATOR_CANCELLED` early) - `Extract Face Set` was also adding a mask layer (only because both extracts used `geometry_extract_apply`), moved mask specific stuff into `paint_mask_extract_exec` (see above also) Came up in !123888 Pull Request: https://projects.blender.org/blender/blender/pulls/133435 --- .../blender/editors/mesh/editmesh_mask_extract.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_mask_extract.cc b/source/blender/editors/mesh/editmesh_mask_extract.cc index d5021a21fd5..afcd5da35c0 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.cc +++ b/source/blender/editors/mesh/editmesh_mask_extract.cc @@ -87,8 +87,6 @@ static int geometry_extract_apply(bContext *C, blender::ed::sculpt_paint::object_sculpt_mode_exit(C, depsgraph); - BKE_sculpt_mask_layers_ensure(&depsgraph, bmain, ob, nullptr); - /* Ensures that deformation from sculpt mode is taken into account before duplicating the mesh to * extract the geometry. */ CTX_data_ensure_evaluated_depsgraph(C); @@ -279,6 +277,12 @@ static void geometry_extract_tag_face_set(BMesh *bm, GeometryExtractParams *para static int paint_mask_extract_exec(bContext *C, wmOperator *op) { + Object *ob = CTX_data_active_object(C); + Mesh *mesh = static_cast(ob->data); + if (!mesh->attributes().contains(".sculpt_mask")) { + return OPERATOR_CANCELLED; + } + GeometryExtractParams params; params.mask_threshold = RNA_float_get(op->ptr, "mask_threshold"); params.num_smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations"); @@ -462,14 +466,16 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op) Main &bmain = *CTX_data_main(C); Object &ob = *CTX_data_active_object(C); View3D *v3d = CTX_wm_view3d(C); + Mesh *mesh = static_cast(ob.data); - BKE_sculpt_mask_layers_ensure(nullptr, nullptr, &ob, nullptr); + if (!mesh->attributes().contains(".sculpt_mask")) { + return OPERATOR_CANCELLED; + } bool create_new_object = RNA_boolean_get(op->ptr, "new_object"); bool fill_holes = RNA_boolean_get(op->ptr, "fill_holes"); float mask_threshold = RNA_float_get(op->ptr, "mask_threshold"); - Mesh *mesh = static_cast(ob.data); Mesh *new_mesh = (Mesh *)BKE_id_copy(&bmain, &mesh->id); /* Undo crashes when new object is created in the middle of a sculpt, see #87243. */ From 053d817a754308212d5e62fc9613ef72799c6b08 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Wed, 22 Jan 2025 22:27:22 +0800 Subject: [PATCH 33/46] Fix (unreported): Assert when right clicking on image editor tools When right clicking on any of the image editor tool buttons, `WM_keymap_guess_from_context` would be called but lack of `space_type` will cause `WM_keymap_find_all` to return `nullptr`. Assigning it to `SPACE_IMAGE` fixes the issue. --- source/blender/windowmanager/intern/wm_keymap_utils.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.cc b/source/blender/windowmanager/intern/wm_keymap_utils.cc index 50611aa334d..a7dabbb8ad6 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.cc +++ b/source/blender/windowmanager/intern/wm_keymap_utils.cc @@ -168,6 +168,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) else if (sl->spacetype == SPACE_IMAGE) { const SpaceImage *sima = (SpaceImage *)sl; const eSpaceImage_Mode mode = eSpaceImage_Mode(sima->mode); + space_type = SPACE_IMAGE; switch (mode) { case SI_MODE_VIEW: km_id = "Image"; From e31077ca4c462b172c138b5bea640bb879c05a43 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Jan 2025 15:50:19 +0100 Subject: [PATCH 34/46] Fix #132148: Assert using rendered animation playback Don't close file handle twice. --- source/blender/windowmanager/intern/wm_playanim.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index c7fcc1bb152..cf656945005 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -134,7 +134,6 @@ static bool buffer_from_filepath(const char *filepath, size_read); } else { - close(file); *r_size = size; if (r_mem) { *r_mem = mem; From 14facb987e36d4e8629e392e889c75977b2d15be Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Jan 2025 15:54:41 +0100 Subject: [PATCH 35/46] Fix #132367: Cycles tiled render cancel still does slow denoise Read the tiles back from disk, but don't run denoiser. Pull Request: https://projects.blender.org/blender/blender/pulls/133443 --- intern/cycles/integrator/path_trace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp index 6ea925f371e..e924220f83a 100644 --- a/intern/cycles/integrator/path_trace.cpp +++ b/intern/cycles/integrator/path_trace.cpp @@ -1047,7 +1047,7 @@ void PathTrace::process_full_buffer_from_disk(string_view filename) render_state_.has_denoised_result = false; - if (denoise_params.use && denoiser_) { + if (denoise_params.use && denoiser_ && !progress_->get_cancel()) { progress_set_status(layer_view_name, "Denoising"); /* If GPU should be used is not based on file metadata. */ From a704d47a04795c71b6a5a9fd13a20800f1cb19fc Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 22 Jan 2025 10:32:03 -0500 Subject: [PATCH 36/46] Fix #133429: Bevel modifier crash with empty mesh Attribute domain interpolation would fail in this case. Instead of checking for that, just add an empty check at the modifier entry point. --- source/blender/modifiers/intern/MOD_bevel.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/modifiers/intern/MOD_bevel.cc b/source/blender/modifiers/intern/MOD_bevel.cc index 2c67b309f19..4a8463d2d46 100644 --- a/source/blender/modifiers/intern/MOD_bevel.cc +++ b/source/blender/modifiers/intern/MOD_bevel.cc @@ -110,6 +110,9 @@ static std::string ensure_weight_attribute_meta_data(Mesh &mesh, static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { using namespace blender; + if (mesh->verts_num == 0) { + return mesh; + } Mesh *result; BMesh *bm; BMIter iter; From 20bd132703a49feadb7d8578caf8efe93a3d4392 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Wed, 22 Jan 2025 17:18:37 +0100 Subject: [PATCH 37/46] Fix: Overlay-Next: Jagged wireframes when Overlay AA is disabled Fixes the issue described in https://projects.blender.org/blender/blender/issues/132895#issuecomment-1390739. Pull Request: https://projects.blender.org/blender/blender/pulls/133446 --- .../engines/overlay/shaders/overlay_antialiasing_frag.glsl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl index 03b65e94d62..175e59af39d 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl @@ -100,6 +100,11 @@ void main() float dist_raw = texelFetch(lineTex, center_texel, 0).b; float dist = decode_line_dist(dist_raw); + if (!doSmoothLines && dist <= 1.0f) { + /* No expansion or AA should be applied. */ + return; + } + /* TODO: Optimization: use textureGather. */ vec4 neightbor_col0 = texelFetchOffset(colorTex, center_texel, 0, ivec2(1, 0)); vec4 neightbor_col1 = texelFetchOffset(colorTex, center_texel, 0, ivec2(-1, 0)); From ef8808d9908b6453764bf70def84ee3161652da7 Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Wed, 22 Jan 2025 18:19:39 +0100 Subject: [PATCH 38/46] Cleanup: Compositor: Ghost data of a node storage Since 4cf7fc3b3a4d032f0c0db632a46d40806e906cf1 (where a storage handling being added) a render layer node never has persist storage data. And even more, some code of node update do use storage field as temporal variables for a callback so no any data can live forever in this place. No one copy/initialize/free callback of the node also does not deal with node storage. And compositor code also don't know about node storage since use different data from a node (id and custom1 fields). Pull Request: https://projects.blender.org/blender/blender/pulls/132717 --- source/blender/blenkernel/intern/node.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 5593f57aad1..6b0243151e7 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1155,7 +1155,6 @@ void node_tree_blend_read_data(BlendDataReader *reader, ID *owner_id, bNodeTree break; } case CMP_NODE_IMAGE: - case CMP_NODE_R_LAYERS: case CMP_NODE_VIEWER: { ImageUser *iuser = static_cast(node->storage); iuser->scene = nullptr; From 8435c030619ce2513256b4900d62cd280ec89a21 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 22 Jan 2025 18:43:27 +0100 Subject: [PATCH 39/46] Fix missing header in materialX code. Fairly weird, debug builds were fine, but release ones with clang 19 and mold failed at linking step, complaining about misisng `bNode::output_sockets()` symbol. Guess debug config somehow pulls this symbol from somewhere else? --- source/blender/nodes/shader/materialx/node_graph.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/nodes/shader/materialx/node_graph.cc b/source/blender/nodes/shader/materialx/node_graph.cc index c8a270a2b16..088baaf4773 100644 --- a/source/blender/nodes/shader/materialx/node_graph.cc +++ b/source/blender/nodes/shader/materialx/node_graph.cc @@ -9,6 +9,8 @@ #include "BLI_hash.hh" #include "BLI_string_utils.hh" +#include "BKE_node_runtime.hh" + #include "node_graph.h" namespace blender::nodes::materialx { From d54a7bcb115c2a06d7f93a7c0e952860c0a2d95a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 22 Jan 2025 12:50:01 -0500 Subject: [PATCH 40/46] Cleanup: Use reinterpret_cast instead of two static casts --- source/blender/draw/intern/draw_color_management.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/blender/draw/intern/draw_color_management.cc b/source/blender/draw/intern/draw_color_management.cc index 193324e9d7b..e9697927b61 100644 --- a/source/blender/draw/intern/draw_color_management.cc +++ b/source/blender/draw/intern/draw_color_management.cc @@ -108,13 +108,11 @@ static eDRWColorManagementType drw_color_management_type_get(Main *bmain, if (space_data) { switch (space_data->spacetype) { case SPACE_IMAGE: { - const SpaceImage *sima = static_cast( - static_cast(space_data)); + const SpaceImage *sima = reinterpret_cast(space_data); return drw_color_management_type_for_space_image(*sima); } case SPACE_NODE: { - const SpaceNode *snode = static_cast( - static_cast(space_data)); + const SpaceNode *snode = reinterpret_cast(space_data); return drw_color_management_type_for_space_node(*bmain, *snode); } } From 7c657e250e5c60cf3192c26a7d142034db835c34 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Wed, 22 Jan 2025 11:12:11 -0700 Subject: [PATCH 41/46] make.bat: remove 2019pre support and update help 2019 no longer has a preview track, so support for it can safely be removed. The help also incorrectly advertised asan as a clang only feature, which is no longer true as msvc supports it these days. --- build_files/windows/parse_arguments.cmd | 3 --- build_files/windows/show_help.cmd | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd index 2b5ee28ab77..d0f6d232d0f 100644 --- a/build_files/windows/parse_arguments.cmd +++ b/build_files/windows/parse_arguments.cmd @@ -54,9 +54,6 @@ if NOT "%1" == "" ( set BUILD_ARCH=arm64 ) else if "%1" == "2019" ( set BUILD_VS_YEAR=2019 - ) else if "%1" == "2019pre" ( - set BUILD_VS_YEAR=2019 - set VSWHERE_ARGS=-prerelease ) else if "%1" == "2019b" ( set BUILD_VS_YEAR=2019 set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd index 8178c9162b0..6ad1adb8c1b 100644 --- a/build_files/windows/show_help.cmd +++ b/build_files/windows/show_help.cmd @@ -25,7 +25,6 @@ echo - debug ^(Build an unoptimized debuggable build^) echo - packagename [newname] ^(override default cpack package name^) echo - builddir [newdir] ^(override default build folder^) echo - 2019 ^(build with visual studio 2019^) -echo - 2019pre ^(build with visual studio 2019 pre-release^) echo - 2019b ^(build with visual studio 2019 Build Tools^) echo - 2022 ^(build with visual studio 2022^) echo - 2022pre ^(build with visual studio 2022 pre-release^) @@ -39,6 +38,6 @@ echo. echo Experimental options echo - with_gpu_tests ^(enable both the render and draw gpu test suites including EEVEE, Workbench, Grease Pencil, draw manager and GPU backends^) echo - clang ^(enable building with clang^) -echo - asan ^(enable asan when building with clang^) +echo - asan ^(enable asan^) echo - ninja ^(enable building with ninja instead of msbuild^) echo. From 0b38b3b2b127c513fa86f2f0c6ade55051228449 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 22 Jan 2025 19:19:42 +0100 Subject: [PATCH 42/46] UI: Status Bar Display for GPENCIL_OT_annotate Simplify the status bar display for "Annotation Draw" Pull Request: https://projects.blender.org/blender/blender/pulls/133402 --- .../editors/gpencil_legacy/annotate_paint.cc | 48 +++++-------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/source/blender/editors/gpencil_legacy/annotate_paint.cc b/source/blender/editors/gpencil_legacy/annotate_paint.cc index e1615f27a0d..62b7ea83b08 100644 --- a/source/blender/editors/gpencil_legacy/annotate_paint.cc +++ b/source/blender/editors/gpencil_legacy/annotate_paint.cc @@ -31,6 +31,7 @@ #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" +#include "UI_resources.hh" #include "UI_view2d.hh" #include "ED_clip.hh" @@ -1949,62 +1950,39 @@ static void annotation_draw_cursor_set(tGPsdata *p) /* update UI indicators of status, including cursor and header prints */ static void annotation_draw_status_indicators(bContext *C, tGPsdata *p) { + WorkspaceStatus status(C); + /* header prints */ switch (p->status) { case GP_STATUS_PAINTING: switch (p->paintmode) { case GP_PAINTMODE_DRAW_POLY: - /* Provide usage tips, since this is modal, and unintuitive without hints */ - ED_workspace_status_text( - C, - IFACE_("Annotation Create Poly: LMB click to place next stroke vertex | " - "ESC/Enter to end (or click outside this area)")); - break; - default: - /* Do nothing - the others are self explanatory, exit quickly once the mouse is - * released Showing any text would just be annoying as it would flicker. - */ + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Place Next Stroke Vertex"), ICON_MOUSE_LMB); break; - } - break; - - case GP_STATUS_IDLING: - /* print status info */ - switch (p->paintmode) { case GP_PAINTMODE_ERASER: - ED_workspace_status_text(C, - IFACE_("Annotation Eraser: Hold and drag LMB or RMB to erase | " - "ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Erase"), ICON_MOUSE_LMB); break; case GP_PAINTMODE_DRAW_STRAIGHT: - ED_workspace_status_text(C, - IFACE_("Annotation Line Draw: Hold and drag LMB to draw | " - "ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Draw"), ICON_MOUSE_LMB); break; case GP_PAINTMODE_DRAW: - ED_workspace_status_text(C, - IFACE_("Annotation Freehand Draw: Hold and drag LMB to draw | " - "E/ESC/Enter to end (or click outside this area)")); - break; - case GP_PAINTMODE_DRAW_POLY: - ED_workspace_status_text( - C, - IFACE_("Annotation Create Poly: LMB click to place next stroke vertex | " - "ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Draw"), ICON_MOUSE_LMB); break; default: /* unhandled future cases */ - ED_workspace_status_text( - C, IFACE_("Annotation Session: ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); break; } break; + case GP_STATUS_IDLING: case GP_STATUS_ERROR: case GP_STATUS_DONE: case GP_STATUS_CAPTURE: - /* clear status string */ - ED_workspace_status_text(C, nullptr); break; } } From efadb938f0c2642c8f329f0b709d1bcb67909c6b Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 22 Jan 2025 19:24:38 +0100 Subject: [PATCH 43/46] Fix #132422: Crash when opening UV editor from shader editor Fixes: #132422, #133288. `ED_area_init()` is called when the editor in an area changes, this also changes the available regions. That means, region polling needs to be executed. The crash was happening because that wasn't the case, and the asset shelf region was initialized before the polling was executed, which allocates region data in the `on_poll_success()` callback. Also had to pass context to `ED_area_init()`, which is an annoyance, but should be fine. Similar functions like `ED_area_exit()` take it too. Pull Request: https://projects.blender.org/blender/blender/pulls/133388 --- source/blender/editors/include/ED_screen.hh | 2 +- source/blender/editors/screen/area.cc | 15 ++-- source/blender/editors/screen/screen_edit.cc | 73 +++++++++++++------ .../blender/editors/screen/screen_intern.hh | 2 + source/blender/editors/screen/screen_ops.cc | 4 +- .../space_sequencer/space_sequencer.cc | 5 +- 6 files changed, 66 insertions(+), 35 deletions(-) diff --git a/source/blender/editors/include/ED_screen.hh b/source/blender/editors/include/ED_screen.hh index 162cdc10fce..0bfce6ac0e4 100644 --- a/source/blender/editors/include/ED_screen.hh +++ b/source/blender/editors/include/ED_screen.hh @@ -210,7 +210,7 @@ void ED_area_and_region_types_init(ScrArea *area); /** * Called in screen_refresh, or screens_init, also area size changes. */ -void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area); +void ED_area_init(bContext *C, const wmWindow *win, ScrArea *area); void ED_area_exit(bContext *C, ScrArea *area); blender::StringRefNull ED_area_name(const ScrArea *area); int ED_area_icon(const ScrArea *area); diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 12bbca98e6a..6a0539c3c4b 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -976,7 +976,7 @@ void ED_workspace_status_text(bContext *C, const char *str) /* ************************************************************ */ -static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area) +static void area_azone_init(const wmWindow *win, const bScreen *screen, ScrArea *area) { /* reinitialize entirely, regions and full-screen add azones too */ BLI_freelistN(&area->actionzones); @@ -2046,8 +2046,9 @@ void ED_area_and_region_types_init(ScrArea *area) } } -void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area) +void ED_area_init(bContext *C, const wmWindow *win, ScrArea *area) { + wmWindowManager *wm = CTX_wm_manager(C); WorkSpace *workspace = WM_window_get_active_workspace(win); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); const Scene *scene = WM_window_get_active_scene(win); @@ -2065,6 +2066,8 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area) /* area sizes */ area_calc_totrct(area, &window_rect); + area_regions_poll(C, screen, area); + /* region rect sizes */ rcti rect = area->totrct; rcti overlap_rect = rect; @@ -2249,7 +2252,7 @@ void ED_region_visibility_change_update_ex( } if (do_init) { - ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), area); + ED_area_init(C, CTX_wm_window(C), area); ED_area_tag_redraw(area); } } @@ -2577,8 +2580,8 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) ED_area_data_copy(tmp, sa1, false); ED_area_data_copy(sa1, sa2, true); ED_area_data_copy(sa2, tmp, true); - ED_area_init(CTX_wm_manager(C), win, sa1); - ED_area_init(CTX_wm_manager(C), win, sa2); + ED_area_init(C, win, sa1); + ED_area_init(C, win, sa2); BKE_screen_area_free(tmp); MEM_delete(tmp); @@ -2694,7 +2697,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi region_align_info_to_area(area, region_align_info); } - ED_area_init(CTX_wm_manager(C), win, area); + ED_area_init(C, win, area); /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(win); diff --git a/source/blender/editors/screen/screen_edit.cc b/source/blender/editors/screen/screen_edit.cc index 79bc4f241f4..bba18e5f341 100644 --- a/source/blender/editors/screen/screen_edit.cc +++ b/source/blender/editors/screen/screen_edit.cc @@ -699,40 +699,67 @@ static bool region_poll(const bContext *C, } /** - * \return true if any region polling state changed, and a screen refresh is needed. + * \return true if any region polling state changed, and an area re-init is needed. */ -static bool screen_regions_poll(bContext *C, wmWindow *win, const bScreen *screen) +bool area_regions_poll(bContext *C, const bScreen *screen, ScrArea *area) { - wmWindow *prev_win = CTX_wm_window(C); + bScreen *prev_screen = CTX_wm_screen(C); ScrArea *prev_area = CTX_wm_area(C); ARegion *prev_region = CTX_wm_region(C); - CTX_wm_window_set(C, win); + CTX_wm_screen_set(C, const_cast(screen)); + CTX_wm_area_set(C, area); bool any_changed = false; - ED_screen_areas_iter (win, screen, area) { - CTX_wm_area_set(C, area); + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + const int old_region_flag = region->flag; - LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { - const int old_region_flag = region->flag; + region->flag &= ~RGN_FLAG_POLL_FAILED; + + CTX_wm_region_set(C, region); + if (region_poll(C, screen, area, region) == false) { + region->flag |= RGN_FLAG_POLL_FAILED; + } + else if (region->runtime->type && region->runtime->type->on_poll_success) { + region->runtime->type->on_poll_success(C, region); + } - region->flag &= ~RGN_FLAG_POLL_FAILED; + if (old_region_flag != region->flag) { + any_changed = true; - CTX_wm_region_set(C, region); - if (region_poll(C, screen, area, region) == false) { - region->flag |= RGN_FLAG_POLL_FAILED; - } - else if (region->runtime->type && region->runtime->type->on_poll_success) { - region->runtime->type->on_poll_success(C, region); - } + /* Enforce complete re-init. */ + region->v2d.flag &= ~V2D_IS_INIT; - if (old_region_flag != region->flag) { - any_changed = true; + const bool is_hidden = region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_POLL_FAILED); + /* Don't re-init areas, caller is expected to handle that. In fact, this code might actually + * run as part of #ED_area_init(). */ + const bool do_init = false; + ED_region_visibility_change_update_ex(C, area, region, is_hidden, do_init); + } + } - /* Enforce complete re-init. */ - region->v2d.flag &= ~V2D_IS_INIT; - ED_region_visibility_change_update(C, area, region); - } + CTX_wm_screen_set(C, prev_screen); + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); + + return any_changed; +} + +/** + * \return true if any region polling state changed, and a screen refresh is needed. + */ +static bool screen_regions_poll(bContext *C, wmWindow *win, const bScreen *screen) +{ + wmWindow *prev_win = CTX_wm_window(C); + ScrArea *prev_area = CTX_wm_area(C); + ARegion *prev_region = CTX_wm_region(C); + + CTX_wm_window_set(C, win); + + bool any_changed = false; + ED_screen_areas_iter (win, screen, area) { + if (area_regions_poll(C, screen, area)) { + any_changed = true; } } @@ -785,7 +812,7 @@ static void screen_refresh_if_needed(bContext *C, wmWindowManager *wm, wmWindow ED_screen_areas_iter (win, screen, area) { /* Set space-type and region callbacks, calls init() */ /* Sets sub-windows for regions, adds handlers. */ - ED_area_init(wm, win, area); + ED_area_init(C, win, area); } /* wake up animtimer */ diff --git a/source/blender/editors/screen/screen_intern.hh b/source/blender/editors/screen/screen_intern.hh index df5d0415b30..96de9aa1924 100644 --- a/source/blender/editors/screen/screen_intern.hh +++ b/source/blender/editors/screen/screen_intern.hh @@ -143,6 +143,8 @@ bool screen_area_close(bContext *C, bScreen *screen, ScrArea *area); void screen_area_spacelink_add(const Scene *scene, ScrArea *area, eSpace_Type space_type); AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); +bool area_regions_poll(bContext *C, const bScreen *screen, ScrArea *area); + /* `screen_geometry.cc` */ int screen_geom_area_height(const ScrArea *area); diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 90dca276277..1feab9aeef3 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -6279,7 +6279,7 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running else { if (rgi->hidden) { rgi->region->flag |= rgi->hidden; - ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), rgi->area); + ED_area_init(C, CTX_wm_window(C), rgi->area); } /* area decoration needs redraw in end */ ED_area_tag_redraw(rgi->area); @@ -6307,7 +6307,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe /* blend in, reinitialize regions because it got unhidden */ if (rgi->hidden == 0) { - ED_area_init(wm, win, area); + ED_area_init(C, win, area); } else { ED_region_visibility_change_update_ex(C, area, region, true, false); diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index 7cf9ed81d4d..4147779bcbe 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -220,8 +220,7 @@ static void sequencer_init(wmWindowManager * /*wm*/, ScrArea *area) static void sequencer_refresh(const bContext *C, ScrArea *area) { - wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *window = CTX_wm_window(C); + const wmWindow *window = CTX_wm_window(C); SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first; ARegion *region_main = sequencer_find_region(area, RGN_TYPE_WINDOW); ARegion *region_preview = sequencer_find_region(area, RGN_TYPE_PREVIEW); @@ -272,7 +271,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) } if (view_changed) { - ED_area_init(wm, window, area); + ED_area_init(const_cast(C), window, area); ED_area_tag_redraw(area); } } From e07cd2b9826094d67b017f30a6d368b40376fd96 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 22 Jan 2025 19:37:38 +0100 Subject: [PATCH 44/46] Cleanup: Remove unused and transitive includes in draw module Especially through DRW_render.hh, there were a lot of unnecessary includes almost everywhere in the module. This typically makes dependencies less explicit and slows down compile times, so switch to including what files actual use. Pull Request: https://projects.blender.org/blender/blender/pulls/133450 --- source/blender/blenkernel/BKE_mesh.h | 7 +-- source/blender/draw/DRW_engine.hh | 4 -- .../engines/compositor/compositor_engine.cc | 2 + .../draw/engines/eevee_next/eevee_camera.cc | 9 +-- .../draw/engines/eevee_next/eevee_camera.hh | 2 + .../eevee_next/eevee_depth_of_field.cc | 3 +- .../draw/engines/eevee_next/eevee_engine.cc | 4 +- .../draw/engines/eevee_next/eevee_film.cc | 4 +- .../draw/engines/eevee_next/eevee_instance.cc | 10 +++- .../draw/engines/eevee_next/eevee_instance.hh | 7 +++ .../engines/eevee_next/eevee_lightprobe.hh | 2 + .../eevee_next/eevee_lightprobe_sphere.hh | 7 +-- .../eevee_next/eevee_lightprobe_volume.cc | 3 +- .../draw/engines/eevee_next/eevee_lookdev.cc | 3 + .../draw/engines/eevee_next/eevee_material.cc | 3 +- .../draw/engines/eevee_next/eevee_material.hh | 5 ++ .../engines/eevee_next/eevee_motion_blur.cc | 9 ++- .../draw/engines/eevee_next/eevee_pipeline.cc | 2 +- .../draw/engines/eevee_next/eevee_raytrace.cc | 5 +- .../draw/engines/eevee_next/eevee_sampling.cc | 1 + .../draw/engines/eevee_next/eevee_shader.cc | 2 + .../draw/engines/eevee_next/eevee_shadow.cc | 4 +- .../draw/engines/eevee_next/eevee_sync.cc | 7 +-- .../draw/engines/eevee_next/eevee_velocity.cc | 1 + .../draw/engines/eevee_next/eevee_view.cc | 3 +- .../draw/engines/eevee_next/eevee_volume.cc | 3 +- .../draw/engines/external/external_engine.cc | 14 ++--- .../engines/gpencil/gpencil_cache_utils.cc | 11 ++-- .../draw/engines/gpencil/gpencil_draw_data.cc | 5 +- .../draw/engines/gpencil/gpencil_engine.h | 4 +- .../draw/engines/gpencil/gpencil_engine_c.cc | 15 ++--- .../draw/engines/gpencil/gpencil_render.cc | 4 +- .../draw/engines/gpencil/gpencil_shader_c.cc | 2 + .../draw/engines/gpencil/gpencil_shader_fx.cc | 2 +- .../draw/engines/image/image_drawing_mode.cc | 2 + .../draw/engines/image/image_engine.cc | 15 +---- .../draw/engines/overlay/overlay_armature.cc | 6 +- .../overlay/overlay_next_attribute_text.hh | 4 +- .../overlay/overlay_next_attribute_viewer.hh | 1 + .../overlay/overlay_next_background.hh | 4 ++ .../engines/overlay/overlay_next_engine.cc | 14 +---- .../overlay/overlay_next_grease_pencil.hh | 5 ++ .../engines/overlay/overlay_next_instance.cc | 2 - .../engines/overlay/overlay_next_light.hh | 4 ++ .../overlay/overlay_next_mode_transfer.hh | 3 + .../engines/overlay/overlay_next_origin.hh | 2 + .../engines/overlay/overlay_next_paint.hh | 2 + .../engines/overlay/overlay_next_private.hh | 4 ++ .../engines/overlay/overlay_next_shape.cc | 2 + .../draw/engines/select/select_engine.cc | 7 ++- .../draw/engines/select/select_instance.cc | 2 +- .../draw/engines/select/select_private.hh | 1 + .../engines/workbench/workbench_effect_dof.cc | 3 +- .../engines/workbench/workbench_engine.cc | 10 +++- .../engines/workbench/workbench_materials.cc | 3 +- .../engines/workbench/workbench_private.hh | 2 + .../engines/workbench/workbench_resources.cc | 5 ++ .../engines/workbench/workbench_shadow.cc | 2 + .../draw/engines/workbench/workbench_state.cc | 9 +-- .../engines/workbench/workbench_volume.cc | 3 + source/blender/draw/intern/DRW_gpu_wrapper.hh | 2 - source/blender/draw/intern/DRW_render.hh | 55 ++++++------------- source/blender/draw/intern/draw_cache.cc | 8 +-- source/blender/draw/intern/draw_cache.hh | 2 + .../blender/draw/intern/draw_cache_extract.hh | 7 +++ .../draw/intern/draw_cache_extract_mesh.cc | 6 -- .../draw_cache_extract_mesh_render_data.cc | 7 --- source/blender/draw/intern/draw_cache_impl.hh | 8 ++- .../draw/intern/draw_cache_impl_curve.cc | 6 +- .../draw/intern/draw_cache_impl_curves.cc | 3 +- .../intern/draw_cache_impl_grease_pencil.cc | 2 +- .../draw/intern/draw_cache_impl_lattice.cc | 2 - .../draw/intern/draw_cache_impl_mesh.cc | 20 +------ .../draw/intern/draw_cache_impl_particles.cc | 2 - .../draw/intern/draw_cache_impl_pointcloud.cc | 4 +- .../intern/draw_cache_impl_subdivision.cc | 6 +- .../draw/intern/draw_cache_impl_volume.cc | 7 +-- .../blender/draw/intern/draw_cache_inline.hh | 1 - .../draw/intern/draw_color_management.cc | 10 ++-- source/blender/draw/intern/draw_common.cc | 8 +-- source/blender/draw/intern/draw_curves.cc | 2 - source/blender/draw/intern/draw_debug.cc | 6 +- source/blender/draw/intern/draw_debug.hh | 4 ++ source/blender/draw/intern/draw_hair.cc | 7 +-- .../blender/draw/intern/draw_instance_data.cc | 15 +---- source/blender/draw/intern/draw_manager.cc | 4 -- source/blender/draw/intern/draw_manager_c.cc | 13 +++-- source/blender/draw/intern/draw_manager_c.hh | 7 ++- .../draw/intern/draw_manager_profiling.cc | 3 +- .../draw/intern/draw_manager_shader.cc | 13 ----- .../blender/draw/intern/draw_manager_text.cc | 2 +- source/blender/draw/intern/draw_pointcloud.cc | 7 --- source/blender/draw/intern/draw_resource.cc | 7 +-- source/blender/draw/intern/draw_resource.hh | 1 - source/blender/draw/intern/draw_sculpt.cc | 7 ++- source/blender/draw/intern/draw_sculpt.hh | 9 ++- .../blender/draw/intern/draw_select_buffer.cc | 9 ++- source/blender/draw/intern/draw_shader.cc | 5 -- source/blender/draw/intern/draw_view.cc | 2 + source/blender/draw/intern/draw_view.hh | 1 - source/blender/draw/intern/draw_view_c.cc | 9 ++- source/blender/draw/intern/draw_view_data.cc | 3 - source/blender/draw/intern/draw_volume.cc | 4 +- .../intern/mesh_extractors/extract_mesh.cc | 3 - .../extract_mesh_ibo_lines_adjacency.cc | 1 - .../extract_mesh_ibo_points.cc | 2 - .../extract_mesh_vbo_attributes.cc | 3 - .../extract_mesh_vbo_edituv_stretch_area.cc | 2 - .../extract_mesh_vbo_sculpt_data.cc | 3 - .../mesh_extractors/extract_mesh_vbo_tan.cc | 3 - .../extract_mesh_vbo_weights.cc | 1 - 111 files changed, 272 insertions(+), 338 deletions(-) diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 3444892c63c..b722d85e8d5 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -7,10 +7,9 @@ * \ingroup bke */ +#include + #include "BLI_array.hh" -#include "BLI_compiler_attrs.h" -#include "BLI_compiler_compat.h" -#include "BLI_utildefines.h" #include "DNA_mesh_types.h" @@ -34,7 +33,7 @@ struct Object; struct Scene; /* TODO: Move to `BKE_mesh_types.hh` when possible. */ -enum eMeshBatchDirtyMode { +enum eMeshBatchDirtyMode : int8_t { BKE_MESH_BATCH_DIRTY_ALL = 0, BKE_MESH_BATCH_DIRTY_SELECT, BKE_MESH_BATCH_DIRTY_SELECT_PAINT, diff --git a/source/blender/draw/DRW_engine.hh b/source/blender/draw/DRW_engine.hh index 37eb1cb1c51..1f0b5d62abb 100644 --- a/source/blender/draw/DRW_engine.hh +++ b/source/blender/draw/DRW_engine.hh @@ -8,10 +8,6 @@ #pragma once -#include "BLI_sys_types.h" /* for bool */ - -#include "DNA_object_enums.h" - struct ARegion; struct DRWData; struct DRWInstanceDataList; diff --git a/source/blender/draw/engines/compositor/compositor_engine.cc b/source/blender/draw/engines/compositor/compositor_engine.cc index b62e10e5860..f7e327a22ff 100644 --- a/source/blender/draw/engines/compositor/compositor_engine.cc +++ b/source/blender/draw/engines/compositor/compositor_engine.cc @@ -34,6 +34,8 @@ #include "GPU_context.hh" #include "GPU_texture.hh" +#include "draw_view_data.hh" + #include "compositor_engine.h" /* Own include. */ namespace blender::draw::compositor_engine { diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.cc b/source/blender/draw/engines/eevee_next/eevee_camera.cc index 3ded28650ca..8bb37196b62 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.cc +++ b/source/blender/draw/engines/eevee_next/eevee_camera.cc @@ -6,21 +6,16 @@ * \ingroup eevee */ -#include +#include "BLI_bounds.hh" #include "DRW_render.hh" -#include "BLI_bounds.hh" - #include "DNA_camera_types.h" #include "DNA_view3d_types.h" #include "BKE_camera.h" -#include "DEG_depsgraph_query.hh" - -#include "ED_view3d.hh" - +#include "RE_engine.h" #include "RE_pipeline.h" #include "render_types.h" diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.hh b/source/blender/draw/engines/eevee_next/eevee_camera.hh index e7dc0053cea..65320297c68 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.hh +++ b/source/blender/draw/engines/eevee_next/eevee_camera.hh @@ -8,6 +8,8 @@ * \ingroup eevee */ +#include "BLI_math_matrix.h" + #include "eevee_shader_shared.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc index 196741b4224..9c5501c84f2 100644 --- a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc +++ b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc @@ -24,7 +24,8 @@ #include "GPU_platform.hh" #include "GPU_texture.hh" -#include "GPU_uniform_buffer.hh" + +#include "draw_manager_profiling.hh" #include "eevee_camera.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_engine.cc b/source/blender/draw/engines/eevee_next/eevee_engine.cc index 262dc2f20e7..4e7277e5025 100644 --- a/source/blender/draw/engines/eevee_next/eevee_engine.cc +++ b/source/blender/draw/engines/eevee_next/eevee_engine.cc @@ -2,10 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_global.hh" #include "BLI_rect.h" -#include "GPU_capabilities.hh" #include "GPU_framebuffer.hh" #include "ED_screen.hh" @@ -17,6 +15,8 @@ #include "eevee_engine.h" /* Own include. */ +#include "draw_view_data.hh" + #include "eevee_instance.hh" using namespace blender; diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 834070bc4b1..74b73cd5baa 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -17,14 +17,16 @@ #include "BLI_set.hh" #include "BKE_compositor.hh" +#include "BKE_scene.hh" -#include "GPU_debug.hh" #include "GPU_framebuffer.hh" #include "GPU_texture.hh" #include "DRW_render.hh" #include "RE_pipeline.h" +#include "draw_view_data.hh" + #include "eevee_film.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index 786336f24dc..8a568c1e8c9 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -8,17 +8,22 @@ * An instance contains all structures needed to do a complete render. */ -#include - #include "BKE_global.hh" #include "BKE_object.hh" + #include "BLI_rect.h" +#include "BLI_time.h" + #include "BLT_translation.hh" + #include "DEG_depsgraph_query.hh" + #include "DNA_ID.h" #include "DNA_lightprobe_types.h" #include "DNA_modifier_types.h" + #include "IMB_imbuf_types.hh" + #include "RE_pipeline.h" #include "eevee_engine.h" @@ -27,6 +32,7 @@ #include "DNA_particle_types.h" #include "draw_common.hh" +#include "draw_view_data.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.hh b/source/blender/draw/engines/eevee_next/eevee_instance.hh index 920baf18c7c..4c870c74ba3 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.hh +++ b/source/blender/draw/engines/eevee_next/eevee_instance.hh @@ -12,9 +12,16 @@ #include +#include "BLI_string.h" + +#include "BLT_translation.hh" + #include "BKE_object.hh" + #include "DEG_depsgraph.hh" + #include "DNA_lightprobe_types.h" + #include "DRW_render.hh" #include "eevee_ambient_occlusion.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh b/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh index e11af602459..8884defc94c 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh @@ -15,6 +15,8 @@ #include "BLI_bit_vector.hh" #include "BLI_map.hh" +#include "DNA_world_types.h" + #include "eevee_defines.hh" #include "eevee_sync.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh b/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh index c34865d5d31..515877a62fb 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh @@ -8,14 +8,11 @@ #pragma once +#include "DNA_world_types.h" + #include "eevee_lightprobe.hh" #include "eevee_shader_shared.hh" -#include "BKE_cryptomatte.hh" - -extern "C" { -} - namespace blender::eevee { class Instance; diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc index 408da2c196f..fa27765ed32 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc @@ -8,9 +8,8 @@ #include "BKE_lightprobe.h" #include "GPU_capabilities.hh" -#include "GPU_debug.hh" -#include "BLI_math_rotation.hh" +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc index ed0958c2897..4aa40f68a95 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc @@ -18,6 +18,9 @@ #include "GPU_material.hh" +#include "draw_cache.hh" +#include "draw_view_data.hh" + #include "eevee_instance.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_material.cc b/source/blender/draw/engines/eevee_next/eevee_material.cc index 67f842c5de3..074503fa94d 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.cc +++ b/source/blender/draw/engines/eevee_next/eevee_material.cc @@ -15,8 +15,9 @@ #include "NOD_shader.h" -#include "eevee_instance.hh" +#include "draw_cache.hh" +#include "eevee_instance.hh" #include "eevee_material.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_material.hh b/source/blender/draw/engines/eevee_next/eevee_material.hh index 3e689dba5bf..3c0d82707db 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.hh +++ b/source/blender/draw/engines/eevee_next/eevee_material.hh @@ -8,6 +8,8 @@ #pragma once +#include "DNA_material_types.h" + #include "DRW_render.hh" #include "BLI_map.hh" @@ -16,6 +18,9 @@ #include "eevee_sync.hh" +struct bNodeSocketValueFloat; +struct bNodeSocketValueRGBA; + namespace blender::eevee { class Instance; diff --git a/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc b/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc index 5875f21aa30..d725b746fbb 100644 --- a/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc +++ b/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc @@ -6,15 +6,14 @@ * \ingroup eevee */ -// #include "BLI_map.hh" #include "BKE_colortools.hh" -#include "DEG_depsgraph_query.hh" + +#include "RE_engine.h" + +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" #include "eevee_motion_blur.hh" -// #include "eevee_sampling.hh" -// #include "eevee_shader_shared.hh" -// #include "eevee_velocity.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 324ea1a5157..9d2b02d0373 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -17,7 +17,7 @@ #include "eevee_pipeline.hh" #include "eevee_shadow.hh" -#include +#include "draw_manager_profiling.hh" #include "draw_common.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc index ca216c94037..1105312bbf2 100644 --- a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc +++ b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc @@ -8,10 +8,7 @@ * The ray-tracing module class handles ray generation, scheduling, tracing and denoising. */ -#include -#include - -#include "BKE_global.hh" +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_sampling.cc b/source/blender/draw/engines/eevee_next/eevee_sampling.cc index 0624c54e1cc..a72c3455a5a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sampling.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sampling.cc @@ -9,6 +9,7 @@ */ #include "BKE_colortools.hh" +#include "BKE_scene.hh" #include "BLI_rand.h" diff --git a/source/blender/draw/engines/eevee_next/eevee_shader.cc b/source/blender/draw/engines/eevee_next/eevee_shader.cc index 563a934d94c..1e788a3698d 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shader.cc @@ -11,6 +11,8 @@ #include "GPU_capabilities.hh" +#include "BKE_material.hh" + #include "gpu_shader_create_info.hh" #include "eevee_shader.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_shadow.cc b/source/blender/draw/engines/eevee_next/eevee_shadow.cc index df74f37481e..1d96336cb52 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shadow.cc @@ -8,14 +8,14 @@ * The shadow module manages shadow update tagging & shadow rendering. */ -#include "BKE_global.hh" #include "BLI_math_matrix.hh" #include "GPU_compute.hh" #include "eevee_instance.hh" +#include "draw_cache.hh" #include "draw_debug.hh" -#include +#include "draw_manager_profiling.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.cc b/source/blender/draw/engines/eevee_next/eevee_sync.cc index c37f9d2f116..563358756ec 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sync.cc @@ -8,20 +8,15 @@ * Converts the different renderable object types to drawcalls. */ -#include "eevee_engine.h" - -#include "BKE_gpencil_legacy.h" -#include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" -#include "DEG_depsgraph_query.hh" #include "DNA_curves_types.h" -#include "DNA_gpencil_legacy_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" #include "DNA_pointcloud_types.h" #include "DNA_volume_types.h" +#include "draw_cache.hh" #include "draw_common.hh" #include "draw_sculpt.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index 17fdebef400..21cf4a0ea68 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -19,6 +19,7 @@ #include "DNA_particle_types.h" #include "DNA_rigidbody_types.h" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_view.cc b/source/blender/draw/engines/eevee_next/eevee_view.cc index babb8281695..7dcdfc57187 100644 --- a/source/blender/draw/engines/eevee_next/eevee_view.cc +++ b/source/blender/draw/engines/eevee_next/eevee_view.cc @@ -15,9 +15,10 @@ * its type. Passes are shared between views. */ -#include "BKE_global.hh" #include "DRW_render.hh" +#include "draw_manager_profiling.hh" + #include "eevee_instance.hh" #include "eevee_view.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_volume.cc b/source/blender/draw/engines/eevee_next/eevee_volume.cc index 3ee66bc74c0..98299a82ea8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_volume.cc @@ -10,10 +10,9 @@ * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ -#include "DNA_volume_types.h" #include "GPU_capabilities.hh" -#include "draw_common.hh" +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" #include "eevee_pipeline.hh" diff --git a/source/blender/draw/engines/external/external_engine.cc b/source/blender/draw/engines/external/external_engine.cc index 9968fc37248..0fb18cf8a91 100644 --- a/source/blender/draw/engines/external/external_engine.cc +++ b/source/blender/draw/engines/external/external_engine.cc @@ -12,29 +12,27 @@ #include "DRW_engine.hh" #include "DRW_render.hh" -#include "DNA_modifier_types.h" +#include "BLI_string.h" + +#include "BLT_translation.hh" + #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BKE_object.hh" -#include "BKE_particle.h" -#include "BKE_screen.hh" - #include "ED_image.hh" #include "ED_screen.hh" -#include "GPU_batch.hh" #include "GPU_debug.hh" #include "GPU_matrix.hh" -#include "GPU_shader.hh" #include "GPU_state.hh" -#include "GPU_viewport.hh" #include "RE_engine.h" #include "RE_pipeline.h" #include "draw_command.hh" #include "draw_view.hh" +#include "draw_view_data.hh" + #include "external_engine.h" /* own include */ /* Shaders */ diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc index ec5f8cf12b8..73cafeed7a8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc @@ -9,28 +9,25 @@ #include "DRW_engine.hh" #include "DRW_render.hh" -#include "ED_gpencil_legacy.hh" #include "ED_view3d.hh" -#include "DNA_gpencil_legacy_types.h" -#include "DNA_view3d_types.h" +#include "DNA_material_types.h" -#include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" -#include "BKE_lib_id.hh" +#include "BKE_material.hh" #include "BKE_object.hh" +#include "BLI_ghash.h" #include "BLI_hash.h" #include "BLI_link_utils.h" #include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_math_vector.hh" #include "BLI_memblock.h" #include "gpencil_engine.h" -#include "draw_cache_impl.hh" - #include "DEG_depsgraph.hh" #include "UI_resources.hh" diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc index 73d93c6bf23..19ba43f27c9 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc @@ -9,11 +9,12 @@ #include "DRW_render.hh" #include "DNA_light_types.h" +#include "DNA_material_types.h" #include "BKE_image.hh" +#include "BKE_material.hh" -#include "BLI_hash.h" -#include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_memblock.h" #include "GPU_uniform_buffer.hh" diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 0306fc03c14..b14fb68b8b9 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -8,18 +8,16 @@ #pragma once -#include "DNA_gpencil_legacy_types.h" - #include "DRW_render.hh" #include "BLI_bitmap.h" -#include "BLI_bounds.hh" #include "BKE_grease_pencil.hh" #include "GPU_batch.hh" #include "draw_pass.hh" +#include "draw_view_data.hh" #define GP_LIGHT diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index df609c1cac5..7f8e8bf5b6c 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -8,33 +8,34 @@ #include "DRW_engine.hh" #include "DRW_render.hh" +#include "BKE_context.hh" #include "BKE_curves.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" -#include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" -#include "BKE_lib_id.hh" -#include "BKE_main.hh" +#include "BKE_material.hh" #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_shader_fx.h" #include "BKE_camera.h" -#include "BKE_global.hh" /* for G.debug */ -#include "BLI_link_utils.h" #include "BLI_listbase.h" #include "BLI_memblock.h" #include "BLI_virtual_array.hh" +#include "BLT_translation.hh" + #include "DNA_camera_types.h" -#include "DNA_gpencil_legacy_types.h" +#include "DNA_material_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "DNA_world_types.h" #include "GPU_texture.hh" #include "GPU_uniform_buffer.hh" +#include "draw_cache.hh" #include "draw_manager.hh" #include "draw_view.hh" @@ -46,7 +47,7 @@ #include "ED_screen.hh" #include "ED_view3d.hh" -#include "UI_resources.hh" +#include "draw_manager_profiling.hh" /* *********** FUNCTIONS *********** */ diff --git a/source/blender/draw/engines/gpencil/gpencil_render.cc b/source/blender/draw/engines/gpencil/gpencil_render.cc index 968b0b3c044..dd1d5486358 100644 --- a/source/blender/draw/engines/gpencil/gpencil_render.cc +++ b/source/blender/draw/engines/gpencil/gpencil_render.cc @@ -5,16 +5,16 @@ /** \file * \ingroup draw */ +#include "BLI_math_matrix.h" #include "BLI_rect.h" #include "DRW_render.hh" #include "BKE_object.hh" -#include "DNA_gpencil_legacy_types.h" - #include "DEG_depsgraph_query.hh" +#include "RE_engine.h" #include "RE_pipeline.h" #include "IMB_imbuf_types.hh" diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_c.cc b/source/blender/draw/engines/gpencil/gpencil_shader_c.cc index 006a870c916..65cbe313542 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_c.cc @@ -7,6 +7,8 @@ */ #include "DRW_render.hh" +#include "BLI_string.h" + #include "gpencil_engine.h" extern "C" char datatoc_gpencil_common_lib_glsl[]; diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc index e4bbda4410f..51e79fa418f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc @@ -13,7 +13,7 @@ #include "BKE_gpencil_legacy.h" #include "BLI_link_utils.h" -#include "BLI_memblock.h" +#include "BLI_math_matrix.h" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/image/image_drawing_mode.cc b/source/blender/draw/engines/image/image_drawing_mode.cc index dd5373482e7..d42acac9351 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.cc +++ b/source/blender/draw/engines/image/image_drawing_mode.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "draw_view_data.hh" + #include "image_drawing_mode.hh" #include "image_instance.hh" #include "image_shader.hh" diff --git a/source/blender/draw/engines/image/image_engine.cc b/source/blender/draw/engines/image/image_engine.cc index 8aedd0581ec..7994a09f282 100644 --- a/source/blender/draw/engines/image/image_engine.cc +++ b/source/blender/draw/engines/image/image_engine.cc @@ -10,30 +10,21 @@ #include "DRW_render.hh" -#include -#include +#include "BLT_translation.hh" +#include "BKE_context.hh" #include "BKE_image.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "DNA_camera_types.h" -#include "DNA_screen_types.h" - -#include "IMB_imbuf.hh" -#include "IMB_imbuf_types.hh" - #include "ED_image.hh" -#include "GPU_batch.hh" +#include "draw_view_data.hh" #include "image_drawing_mode.hh" #include "image_engine.h" #include "image_instance.hh" -#include "image_private.hh" #include "image_shader.hh" -#include "image_space_image.hh" -#include "image_space_node.hh" namespace blender::image_engine { diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 6e17d76b0a8..eaa7d081091 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -15,12 +15,12 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_view3d_types.h" #include "DRW_render.hh" #include "BLI_listbase_wrapper.hh" #include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_math_matrix_types.hh" #include "BLI_math_rotation.h" #include "BLI_utildefines.h" @@ -28,9 +28,7 @@ #include "BKE_action.hh" #include "BKE_armature.hh" #include "BKE_deform.hh" -#include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" #include "DEG_depsgraph_query.hh" @@ -42,11 +40,11 @@ #include "UI_resources.hh" +#include "draw_cache.hh" #include "draw_common_c.hh" #include "draw_manager_text.hh" #include "overlay_next_armature.hh" -#include "overlay_private.hh" #include "draw_cache_impl.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh b/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh index 586b59426d9..203c4ab6fad 100644 --- a/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh +++ b/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh @@ -7,16 +7,16 @@ */ #include "BLI_math_quaternion_types.hh" +#include "BLI_string.h" #include "DNA_curve_types.h" +#include "DNA_pointcloud_types.h" #include "BKE_attribute.hh" #include "BKE_curves.hh" #include "BKE_duplilist.hh" #include "BKE_geometry_set.hh" #include "BKE_instances.hh" -#include "BKE_mesh.hh" -#include "BKE_pointcloud.hh" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh b/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh index fb5883673f9..7b7b679ed41 100644 --- a/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh +++ b/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh @@ -14,6 +14,7 @@ #include "DNA_curve_types.h" #include "DNA_pointcloud_types.h" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_background.hh b/source/blender/draw/engines/overlay/overlay_next_background.hh index c679bf35728..a08d25a96af 100644 --- a/source/blender/draw/engines/overlay/overlay_next_background.hh +++ b/source/blender/draw/engines/overlay/overlay_next_background.hh @@ -8,6 +8,10 @@ #pragma once +#include "DNA_world_types.h" + +#include "draw_cache.hh" + #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_engine.cc b/source/blender/draw/engines/overlay/overlay_next_engine.cc index 94d2bae7c4c..4719f5012a7 100644 --- a/source/blender/draw/engines/overlay/overlay_next_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_next_engine.cc @@ -11,19 +11,7 @@ #include "DRW_engine.hh" #include "DRW_render.hh" -#include "DEG_depsgraph_query.hh" - -#include "ED_view3d.hh" - -#include "UI_interface.hh" - -#include "BKE_duplilist.hh" -#include "BKE_object.hh" -#include "BKE_paint.hh" - -#include "GPU_capabilities.hh" - -#include "DNA_space_types.h" +#include "BLT_translation.hh" #include "draw_manager.hh" #include "overlay_next_instance.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh b/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh index b9d0e964559..1b91a6bb6cc 100644 --- a/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh +++ b/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh @@ -9,14 +9,19 @@ #pragma once #include "BLI_bounds.hh" +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" #include "BKE_curves.hh" #include "BKE_grease_pencil.hh" +#include "BKE_material.hh" #include "BKE_object.hh" +#include "DNA_material_types.h" + #include "ED_grease_pencil.hh" +#include "draw_cache.hh" #include "draw_manager_text.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_instance.cc b/source/blender/draw/engines/overlay/overlay_next_instance.cc index 96e36012029..520ee3011f8 100644 --- a/source/blender/draw/engines/overlay/overlay_next_instance.cc +++ b/source/blender/draw/engines/overlay/overlay_next_instance.cc @@ -12,8 +12,6 @@ #include "BKE_paint.hh" -#include "draw_debug.hh" - #include "overlay_next_instance.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_light.hh b/source/blender/draw/engines/overlay/overlay_next_light.hh index d882d72fbf2..3cf5734c403 100644 --- a/source/blender/draw/engines/overlay/overlay_next_light.hh +++ b/source/blender/draw/engines/overlay/overlay_next_light.hh @@ -8,6 +8,10 @@ #pragma once +#include "DNA_light_types.h" + +#include "BLI_math_matrix.h" + #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh b/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh index 39b2d62597d..9002d957bba 100644 --- a/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh +++ b/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh @@ -8,8 +8,11 @@ #pragma once +#include "BLI_time.h" + #include "BKE_paint.hh" +#include "draw_cache.hh" #include "draw_sculpt.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_origin.hh b/source/blender/draw/engines/overlay/overlay_next_origin.hh index d7c3d002a9a..12db3635fb4 100644 --- a/source/blender/draw/engines/overlay/overlay_next_origin.hh +++ b/source/blender/draw/engines/overlay/overlay_next_origin.hh @@ -8,6 +8,8 @@ #pragma once +#include "BKE_layer.hh" + #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_paint.hh b/source/blender/draw/engines/overlay/overlay_next_paint.hh index 025834d42d7..0a0fbf9bca7 100644 --- a/source/blender/draw/engines/overlay/overlay_next_paint.hh +++ b/source/blender/draw/engines/overlay/overlay_next_paint.hh @@ -10,9 +10,11 @@ #include "BKE_image.hh" #include "BKE_paint.hh" +#include "BKE_scene.hh" #include "DEG_depsgraph_query.hh" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_private.hh b/source/blender/draw/engines/overlay/overlay_next_private.hh index 623d1101048..4a3deb961cd 100644 --- a/source/blender/draw/engines/overlay/overlay_next_private.hh +++ b/source/blender/draw/engines/overlay/overlay_next_private.hh @@ -8,11 +8,14 @@ #pragma once +#include "BKE_context.hh" #include "BKE_movieclip.h" #include "BKE_object.hh" #include "BLI_function_ref.hh" +#include "DNA_world_types.h" + #include "GPU_matrix.hh" #include "DRW_gpu_wrapper.hh" @@ -20,6 +23,7 @@ #include "UI_resources.hh" #include "draw_manager.hh" #include "draw_pass.hh" +#include "draw_view_data.hh" #include "gpu_shader_create_info.hh" #include "../select/select_instance.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_shape.cc b/source/blender/draw/engines/overlay/overlay_next_shape.cc index e59a9c8fe43..2a3a887ea4f 100644 --- a/source/blender/draw/engines/overlay/overlay_next_shape.cc +++ b/source/blender/draw/engines/overlay/overlay_next_shape.cc @@ -6,6 +6,8 @@ * \ingroup overlay */ +#include "draw_cache.hh" + #include "overlay_next_private.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/select/select_engine.cc b/source/blender/draw/engines/select/select_engine.cc index 650e176cb79..7b3cefe7e4e 100644 --- a/source/blender/draw/engines/select/select_engine.cc +++ b/source/blender/draw/engines/select/select_engine.cc @@ -8,16 +8,19 @@ * Engine for drawing a selection map where the pixels indicate the selection indices. */ -#include "DNA_screen_types.h" +#include "BLI_math_matrix.h" + +#include "BLT_translation.hh" #include "ED_view3d.hh" -#include "UI_resources.hh" +#include "RE_engine.h" #include "DRW_engine.hh" #include "DRW_select_buffer.hh" #include "draw_cache_impl.hh" +#include "draw_common_c.hh" #include "draw_manager_c.hh" #include "select_engine.hh" diff --git a/source/blender/draw/engines/select/select_instance.cc b/source/blender/draw/engines/select/select_instance.cc index 350ae7112d1..da39453ed44 100644 --- a/source/blender/draw/engines/select/select_instance.cc +++ b/source/blender/draw/engines/select/select_instance.cc @@ -8,7 +8,7 @@ #include "DRW_render.hh" -#include "GPU_capabilities.hh" +#include "BLT_translation.hh" #include "select_engine.hh" diff --git a/source/blender/draw/engines/select/select_private.hh b/source/blender/draw/engines/select/select_private.hh index 5e74f430c90..7b2c4a0fb24 100644 --- a/source/blender/draw/engines/select/select_private.hh +++ b/source/blender/draw/engines/select/select_private.hh @@ -12,6 +12,7 @@ #include "draw_manager.hh" #include "draw_pass.hh" +#include "draw_view_data.hh" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 45a0760f9cd..2bf66b4f7a2 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -20,7 +20,8 @@ #include "workbench_private.hh" #include "BKE_camera.h" -#include "DEG_depsgraph_query.hh" + +#include "draw_manager_profiling.hh" namespace blender::workbench { /** diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 9d37a76219d..56350f0909c 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -7,24 +7,30 @@ #include "DNA_fluid_types.h" #include "BKE_editmesh.hh" +#include "BKE_material.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" #include "BKE_particle.h" -#include "BKE_report.hh" #include "DEG_depsgraph_query.hh" +#include "DNA_windowmanager_types.h" #include "ED_paint.hh" #include "ED_view3d.hh" -#include "GPU_capabilities.hh" +#include "BLT_translation.hh" #include "IMB_imbuf_types.hh" +#include "RE_engine.h" +#include "RE_pipeline.h" + +#include "draw_cache.hh" #include "draw_common.hh" #include "draw_sculpt.hh" +#include "draw_view_data.hh" #include "workbench_private.hh" diff --git a/source/blender/draw/engines/workbench/workbench_materials.cc b/source/blender/draw/engines/workbench/workbench_materials.cc index bc7d0a283c7..8909f9539bf 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.cc +++ b/source/blender/draw/engines/workbench/workbench_materials.cc @@ -4,11 +4,12 @@ #include "workbench_private.hh" +#include "BLI_ghash.h" #include "BLI_hash.h" #include "BLI_math_color.h" /* get_image */ -#include "BKE_node.hh" #include "BKE_node_legacy_types.hh" +#include "DNA_material_types.h" #include "DNA_node_types.h" #include "ED_uvedit.hh" /* get_image */ diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 7ad5caac835..cdf86a0eb20 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_context.hh" + #include "DNA_camera_types.h" #include "DRW_render.hh" #include "draw_manager.hh" diff --git a/source/blender/draw/engines/workbench/workbench_resources.cc b/source/blender/draw/engines/workbench/workbench_resources.cc index dc479befeca..3170fa4056a 100644 --- a/source/blender/draw/engines/workbench/workbench_resources.cc +++ b/source/blender/draw/engines/workbench/workbench_resources.cc @@ -3,10 +3,15 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "../eevee_next/eevee_lut.hh" /* TODO: find somewhere to share blue noise Table. */ + #include "BKE_studiolight.h" + +#include "BLI_math_matrix.h" #include "BLI_math_rotation.h" + #include "IMB_imbuf_types.hh" +#include "draw_common_c.hh" #include "workbench_private.hh" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 59a92d165dd..2257230064d 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -19,6 +19,8 @@ #include "DRW_render.hh" #include "GPU_compute.hh" +#include "draw_cache.hh" + #include "workbench_private.hh" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_state.cc b/source/blender/draw/engines/workbench/workbench_state.cc index d0348c83c5f..1b75970343b 100644 --- a/source/blender/draw/engines/workbench/workbench_state.cc +++ b/source/blender/draw/engines/workbench/workbench_state.cc @@ -5,18 +5,19 @@ #include "workbench_private.hh" #include "BKE_camera.h" +#include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_mesh_types.hh" -#include "BKE_modifier.hh" -#include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" -#include "BKE_particle.h" #include "DEG_depsgraph_query.hh" -#include "DNA_fluid_types.h" + +#include "DNA_world_types.h" + #include "ED_paint.hh" #include "ED_view3d.hh" + #include "GPU_capabilities.hh" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_volume.cc b/source/blender/draw/engines/workbench/workbench_volume.cc index b1cb909495f..e91aa170a29 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.cc +++ b/source/blender/draw/engines/workbench/workbench_volume.cc @@ -2,6 +2,9 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "draw_cache.hh" +#include "draw_common_c.hh" + #include "workbench_private.hh" #include "BKE_volume.hh" diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 2402b6bfe64..f5a5fdefde3 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -57,8 +57,6 @@ * Simple wrapper to #GPUFramebuffer that can be moved. */ -#include "DRW_render.hh" - #include "MEM_guardedalloc.h" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/DRW_render.hh b/source/blender/draw/intern/DRW_render.hh index 8c019733472..04a8e1825b8 100644 --- a/source/blender/draw/intern/DRW_render.hh +++ b/source/blender/draw/intern/DRW_render.hh @@ -10,45 +10,9 @@ #pragma once -#include "BLI_listbase.h" -#include "BLI_math_matrix.h" -#include "BLI_string.h" +#include "DNA_object_enums.h" -#include "BKE_context.hh" -#include "BKE_layer.hh" -#include "BKE_material.hh" -#include "BKE_scene.hh" - -#include "BLT_translation.hh" - -#include "DNA_light_types.h" -#include "DNA_material_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_world_types.h" - -#include "GPU_framebuffer.hh" #include "GPU_material.hh" -#include "GPU_primitive.hh" -#include "GPU_shader.hh" -#include "GPU_storage_buffer.hh" -#include "GPU_texture.hh" -#include "GPU_uniform_buffer.hh" - -#include "draw_cache.hh" -#include "draw_common_c.hh" -#include "draw_view_c.hh" - -#include "draw_debug_c.hh" -#include "draw_manager_profiling.hh" -#include "draw_state.hh" -#include "draw_view_data.hh" - -#include "MEM_guardedalloc.h" - -#include "RE_engine.h" - -#include "DEG_depsgraph.hh" /* Uncomment to track unused resource bindings. */ // #define DRW_UNUSED_RESOURCE_TRACKING @@ -62,16 +26,29 @@ namespace blender::gpu { class Batch; } +struct ARegion; +struct bContext; +struct Depsgraph; +struct DefaultFramebufferList; +struct DefaultTextureList; +struct DupliObject; struct GPUMaterial; struct GPUShader; struct GPUTexture; struct GPUUniformBuf; struct Object; struct ParticleSystem; -struct RenderEngineType; -struct bContext; struct rcti; +struct RegionView3D; +struct RenderEngine; +struct RenderEngineType; +struct RenderLayer; +struct RenderResult; +struct SpaceLink; struct TaskGraph; +struct View3D; +struct ViewLayer; +struct World; namespace blender::draw { class TextureFromPool; } // namespace blender::draw diff --git a/source/blender/draw/intern/draw_cache.cc b/source/blender/draw/intern/draw_cache.cc index 792cc9d5500..cea7a7d2922 100644 --- a/source/blender/draw/intern/draw_cache.cc +++ b/source/blender/draw/intern/draw_cache.cc @@ -11,7 +11,6 @@ #include "DNA_grease_pencil_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" -#include "DNA_meta_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" @@ -21,17 +20,18 @@ #include "UI_resources.hh" +#include "BLI_ghash.h" +#include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" +#include "BKE_material.hh" #include "BKE_object.hh" -#include "BKE_paint.hh" #include "GPU_batch.hh" #include "GPU_batch_utils.hh" #include "GPU_capabilities.hh" -#include "MEM_guardedalloc.h" - #include "draw_cache.hh" #include "draw_cache_impl.hh" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/draw_cache.hh b/source/blender/draw/intern/draw_cache.hh index 0f52fb4e142..cbea353bb9a 100644 --- a/source/blender/draw/intern/draw_cache.hh +++ b/source/blender/draw/intern/draw_cache.hh @@ -9,10 +9,12 @@ #pragma once #include "BLI_math_matrix_types.hh" +#include "BLI_span.hh" #include "BKE_volume_grid_fwd.hh" struct GPUMaterial; +struct GPUTexture; namespace blender::gpu { class Batch; class VertBuf; diff --git a/source/blender/draw/intern/draw_cache_extract.hh b/source/blender/draw/intern/draw_cache_extract.hh index 59bca0629a6..b89fe8febe0 100644 --- a/source/blender/draw/intern/draw_cache_extract.hh +++ b/source/blender/draw/intern/draw_cache_extract.hh @@ -8,9 +8,12 @@ #pragma once +#include "BLI_array.hh" #include "BLI_math_matrix_types.hh" #include "BLI_utildefines.h" +#include "DNA_view3d_enums.h" + #include "GPU_shader.hh" #include "draw_attributes.hh" @@ -19,7 +22,11 @@ namespace blender::gpu { class Batch; class IndexBuf; } // namespace blender::gpu +struct Mesh; +struct Object; +struct Scene; struct TaskGraph; +struct ToolSettings; namespace blender::draw { diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index 7d5cf8ef288..7e0c0abd139 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -7,17 +7,11 @@ * * \brief Extraction of Mesh data into VBO to feed to GPU. */ -#include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" -#include "BLI_array.hh" #include "BLI_task.h" -#include "BLI_vector.hh" - -#include "BKE_editmesh.hh" -#include "BKE_object.hh" #include "GPU_capabilities.hh" diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index 42512da8186..78902d1c211 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -8,13 +8,9 @@ * \brief Extraction of Mesh data into VBO to feed to GPU. */ -#include "MEM_guardedalloc.h" - #include "BLI_array.hh" #include "BLI_array_utils.hh" #include "BLI_enumerable_thread_specific.hh" -#include "BLI_index_mask.hh" -#include "BLI_math_matrix.h" #include "BLI_task.hh" #include "BLI_virtual_array.hh" @@ -23,11 +19,8 @@ #include "BKE_editmesh_cache.hh" #include "BKE_material.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" -#include "GPU_batch.hh" - #include "ED_mesh.hh" #include "mesh_extractors/extract_mesh.hh" diff --git a/source/blender/draw/intern/draw_cache_impl.hh b/source/blender/draw/intern/draw_cache_impl.hh index 8b26b894d6c..b13323c6da8 100644 --- a/source/blender/draw/intern/draw_cache_impl.hh +++ b/source/blender/draw/intern/draw_cache_impl.hh @@ -8,6 +8,10 @@ #pragma once +#include + +#include "BLI_span.hh" + struct GPUMaterial; namespace blender::gpu { class Batch; @@ -23,11 +27,13 @@ struct Curve; struct Curves; struct Lattice; struct Mesh; +struct Object; +struct Scene; struct PointCloud; struct Volume; struct GreasePencil; -#include "BKE_mesh.h" +enum eMeshBatchDirtyMode : int8_t; namespace blender::draw { diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc index dd38f48f155..9c89a98f287 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.cc +++ b/source/blender/draw/intern/draw_cache_impl_curve.cc @@ -10,27 +10,25 @@ #include "MEM_guardedalloc.h" -#include "BLI_array.hh" #include "BLI_color.hh" #include "BLI_listbase.h" #include "BLI_math_rotation.h" -#include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" #include "BLI_utildefines.h" #include "DNA_curve_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_curve.hh" #include "BKE_curves.hh" -#include "BKE_displist.h" #include "BKE_geometry_set.hh" #include "BKE_object_types.hh" #include "BKE_vfont.hh" #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_material.hh" #include "GPU_texture.hh" #include "UI_resources.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 73703bbe54b..1f2166a92a6 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -15,16 +15,15 @@ #include "BLI_array_utils.hh" #include "BLI_listbase.h" #include "BLI_math_base.h" -#include "BLI_math_matrix.hh" #include "BLI_math_vector.hh" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" +#include "BLI_string.h" #include "BLI_task.hh" #include "BLI_utildefines.h" #include "DNA_curves_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc index 7e06fe4a8d0..489fe283d97 100644 --- a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc @@ -10,7 +10,6 @@ #include "BKE_attribute.hh" #include "BKE_curves.hh" -#include "BKE_deform.hh" #include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" @@ -28,6 +27,7 @@ #include "GPU_batch.hh" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "../engines/gpencil/gpencil_defines.h" diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.cc b/source/blender/draw/intern/draw_cache_impl_lattice.cc index 93f9578df30..8b5b61f0adb 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.cc +++ b/source/blender/draw/intern/draw_cache_impl_lattice.cc @@ -10,13 +10,11 @@ #include "MEM_guardedalloc.h" -#include "BLI_math_vector.h" #include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_lattice_types.h" #include "DNA_meshdata_types.h" -#include "DNA_userdef_types.h" #include "BKE_deform.hh" #include "BKE_lattice.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index 3cc123a5e7e..ddb499b72db 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -8,23 +8,15 @@ * \brief Mesh API for render engines */ -#include #include #include "MEM_guardedalloc.h" -#include "BLI_bitmap.h" -#include "BLI_buffer.h" #include "BLI_index_range.hh" #include "BLI_listbase.h" -#include "BLI_map.hh" -#include "BLI_math_bits.h" -#include "BLI_math_vector.h" #include "BLI_span.hh" -#include "BLI_string.h" #include "BLI_string_ref.hh" #include "BLI_task.h" -#include "BLI_utildefines.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" @@ -32,14 +24,9 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_deform.hh" #include "BKE_editmesh.hh" -#include "BKE_editmesh_cache.hh" -#include "BKE_editmesh_tangent.hh" +#include "BKE_material.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" -#include "BKE_mesh_tangent.hh" -#include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" #include "BKE_paint.hh" @@ -48,16 +35,11 @@ #include "atomic_ops.h" -#include "bmesh.hh" - #include "GPU_batch.hh" #include "GPU_material.hh" #include "DRW_render.hh" -#include "ED_mesh.hh" -#include "ED_uvedit.hh" - #include "draw_cache_extract.hh" #include "draw_cache_inline.hh" #include "draw_subdivision.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_particles.cc b/source/blender/draw/intern/draw_cache_impl_particles.cc index 0f988455b5b..7f484823027 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.cc +++ b/source/blender/draw/intern/draw_cache_impl_particles.cc @@ -13,7 +13,6 @@ #include "MEM_guardedalloc.h" #include "BLI_alloca.h" -#include "BLI_ghash.h" #include "BLI_math_color.h" #include "BLI_math_vector.h" #include "BLI_string.h" @@ -35,7 +34,6 @@ #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_context.hh" #include "GPU_material.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index 7c939bca113..e7106ce81a6 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -12,10 +12,8 @@ #include "MEM_guardedalloc.h" +#include "BLI_color.hh" #include "BLI_listbase.h" -#include "BLI_math_base.h" -#include "BLI_math_color.hh" -#include "BLI_math_vector.h" #include "BLI_task.hh" #include "BLI_utildefines.h" diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 286c47cc0fe..d4557266331 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -12,9 +12,7 @@ #include "BKE_editmesh.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" -#include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_eval.hh" #include "BKE_subdiv_foreach.hh" @@ -22,9 +20,7 @@ #include "BKE_subdiv_modifier.hh" #include "BLI_linklist.h" -#include "BLI_string.h" -#include "BLI_string_utils.hh" -#include "BLI_time.h" +#include "BLI_threads.h" #include "BLI_virtual_array.hh" #include "DRW_engine.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_volume.cc b/source/blender/draw/intern/draw_cache_impl_volume.cc index 9e9c600355e..d0adcf23ff8 100644 --- a/source/blender/draw/intern/draw_cache_impl_volume.cc +++ b/source/blender/draw/intern/draw_cache_impl_volume.cc @@ -13,12 +13,11 @@ #include "MEM_guardedalloc.h" #include "BLI_listbase.h" -#include "BLI_math_base.h" #include "BLI_math_matrix.hh" -#include "BLI_math_vector.h" +#include "BLI_string.h" #include "BLI_utildefines.h" -#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_volume_types.h" #include "BKE_global.hh" @@ -30,8 +29,6 @@ #include "GPU_capabilities.hh" #include "GPU_texture.hh" -#include "DEG_depsgraph_query.hh" - #include "DRW_render.hh" #include "draw_cache.hh" /* own include */ diff --git a/source/blender/draw/intern/draw_cache_inline.hh b/source/blender/draw/intern/draw_cache_inline.hh index dbe8ab283ea..20c89953942 100644 --- a/source/blender/draw/intern/draw_cache_inline.hh +++ b/source/blender/draw/intern/draw_cache_inline.hh @@ -9,7 +9,6 @@ #pragma once #include "GPU_batch.hh" -#include "MEM_guardedalloc.h" /* Common */ // #define DRW_DEBUG_MESH_CACHE_REQUEST diff --git a/source/blender/draw/intern/draw_color_management.cc b/source/blender/draw/intern/draw_color_management.cc index e9697927b61..6f60d58cc9a 100644 --- a/source/blender/draw/intern/draw_color_management.cc +++ b/source/blender/draw/intern/draw_color_management.cc @@ -6,20 +6,18 @@ * \ingroup draw */ -#include "draw_manager_c.hh" +#include "GPU_viewport.hh" -#include "DRW_render.hh" +#include "BLI_string.h" -#include "GPU_batch.hh" -#include "GPU_framebuffer.hh" -#include "GPU_matrix.hh" -#include "GPU_texture.hh" +#include "DRW_render.hh" #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "BKE_colortools.hh" #include "BKE_image.hh" +#include "BKE_scene.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/draw/intern/draw_common.cc b/source/blender/draw/intern/draw_common.cc index f1743965fad..475f8ec9c88 100644 --- a/source/blender/draw/intern/draw_common.cc +++ b/source/blender/draw/intern/draw_common.cc @@ -6,20 +6,20 @@ * \ingroup draw */ +#include "DNA_texture_types.h" +#include "DNA_view3d_types.h" #include "DRW_render.hh" -#include "GPU_matrix.hh" -#include "GPU_shader.hh" #include "GPU_texture.hh" +#include "GPU_uniform_buffer.hh" #include "UI_resources.hh" #include "BLI_index_range.hh" #include "BLI_math_color.h" +#include "BLI_math_vector.h" #include "BKE_colorband.hh" -#include "BKE_global.hh" -#include "BKE_object.hh" #include "draw_common_c.hh" diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index d2669f571ab..5de672af2e0 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -8,7 +8,6 @@ * \brief Contains procedural GPU hair drawing methods. */ -#include "BLI_string_utils.hh" #include "BLI_utildefines.h" #include "DNA_curves_types.h" @@ -19,7 +18,6 @@ #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_compute.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" diff --git a/source/blender/draw/intern/draw_debug.cc b/source/blender/draw/intern/draw_debug.cc index f171e965f7c..c6d6e689148 100644 --- a/source/blender/draw/intern/draw_debug.cc +++ b/source/blender/draw/intern/draw_debug.cc @@ -9,10 +9,9 @@ */ #include "BKE_object.hh" -#include "BLI_link_utils.h" +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" #include "GPU_batch.hh" -#include "GPU_capabilities.hh" #include "GPU_debug.hh" #include "draw_debug.hh" @@ -21,9 +20,6 @@ #include "draw_shader.hh" #include "draw_shader_shared.hh" -#include -#include - #if defined(_DEBUG) || defined(WITH_DRAW_DEBUG) # define DRAW_DEBUG #else diff --git a/source/blender/draw/intern/draw_debug.hh b/source/blender/draw/intern/draw_debug.hh index a935c0dc5be..3ce97a2ca26 100644 --- a/source/blender/draw/intern/draw_debug.hh +++ b/source/blender/draw/intern/draw_debug.hh @@ -17,7 +17,11 @@ #include "BLI_math_vector_types.hh" #include "BLI_vector.hh" + #include "DNA_object_types.h" + +#include "draw_shader_shared.hh" + #include "DRW_gpu_wrapper.hh" namespace blender::draw { diff --git a/source/blender/draw/intern/draw_hair.cc b/source/blender/draw/intern/draw_hair.cc index 6e675da3bea..b39680afa81 100644 --- a/source/blender/draw/intern/draw_hair.cc +++ b/source/blender/draw/intern/draw_hair.cc @@ -10,11 +10,9 @@ #include "DRW_render.hh" -#include "BLI_string_utils.hh" -#include "BLI_utildefines.h" +#include "BLI_math_matrix.h" #include "DNA_collection_types.h" -#include "DNA_customdata_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" @@ -22,8 +20,6 @@ #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_compute.hh" -#include "GPU_context.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" @@ -31,6 +27,7 @@ #include "DRW_gpu_wrapper.hh" +#include "draw_common_c.hh" #include "draw_hair_private.hh" #include "draw_manager.hh" #include "draw_shader.hh" diff --git a/source/blender/draw/intern/draw_instance_data.cc b/source/blender/draw/intern/draw_instance_data.cc index d192ad595fd..0a188b17a92 100644 --- a/source/blender/draw/intern/draw_instance_data.cc +++ b/source/blender/draw/intern/draw_instance_data.cc @@ -16,24 +16,13 @@ */ #include "draw_instance_data.hh" -#include "draw_manager_c.hh" #include "DRW_engine.hh" #include "DRW_render.hh" /* For DRW_shgroup_get_instance_count() */ -#include "GPU_material.hh" - -#include "DNA_particle_types.h" - -#include "BKE_duplilist.hh" - -#include "RNA_access.hh" -#include "RNA_path.hh" - -#include "BLI_bitmap.h" -#include "BLI_memblock.h" +#include "BLI_listbase.h" #include "BLI_mempool.h" -#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" struct DRWInstanceData { diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index 41b51af199d..4eb8da24b2a 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -6,21 +6,17 @@ * \ingroup draw */ -#include "BKE_global.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" #include "BLI_math_base.h" #include "GPU_compute.hh" -#include "draw_debug.hh" #include "draw_defines.hh" #include "draw_manager.hh" #include "draw_manager_c.hh" #include "draw_pass.hh" #include "draw_shader.hh" -#include -#include namespace blender::draw { diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index d72e9316075..e9b8afb791a 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -10,9 +10,8 @@ #include "CLG_log.h" -#include "BLI_alloca.h" #include "BLI_listbase.h" -#include "BLI_memblock.h" +#include "BLI_math_matrix.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_task.h" @@ -31,6 +30,7 @@ #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.h" #include "BKE_lattice.hh" +#include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_mball.hh" #include "BKE_mesh.hh" @@ -41,9 +41,9 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_pointcloud.hh" +#include "BKE_scene.hh" #include "BKE_screen.hh" #include "BKE_subdiv_modifier.hh" -#include "BKE_viewer_path.hh" #include "BKE_volume.hh" #include "DNA_camera_types.h" @@ -59,7 +59,6 @@ #include "GPU_capabilities.hh" #include "GPU_framebuffer.hh" -#include "GPU_immediate.hh" #include "GPU_matrix.hh" #include "GPU_platform.hh" #include "GPU_shader_shared.hh" @@ -76,14 +75,16 @@ #include "WM_api.hh" #include "wm_window.hh" +#include "draw_cache.hh" #include "draw_color_management.hh" +#include "draw_common_c.hh" #include "draw_manager_c.hh" #include "draw_manager_profiling.hh" -#include "draw_manager_testing.hh" #include "draw_manager_text.hh" #include "draw_shader.hh" #include "draw_subdivision.hh" #include "draw_texture_pool.hh" +#include "draw_view_c.hh" /* only for callbacks */ #include "draw_cache_impl.hh" @@ -102,6 +103,8 @@ #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "BLI_time.h" + #include "DRW_select_buffer.hh" static CLG_LogRef LOG = {"draw.manager"}; diff --git a/source/blender/draw/intern/draw_manager_c.hh b/source/blender/draw/intern/draw_manager_c.hh index 24f28516615..51a8bdc5ff7 100644 --- a/source/blender/draw/intern/draw_manager_c.hh +++ b/source/blender/draw/intern/draw_manager_c.hh @@ -20,17 +20,18 @@ #include "GPU_context.hh" #include "GPU_framebuffer.hh" #include "GPU_shader.hh" -#include "GPU_uniform_buffer.hh" #include "GPU_viewport.hh" #include "draw_instance_data.hh" -#include "draw_shader_shared.hh" struct DRWDebugModule; struct DRWTexturePool; struct DRWUniformChunk; +struct DRWViewData; +struct DRWTextStore; struct DupliObject; struct Object; +struct Mesh; namespace blender::draw { struct CurvesUniformBufPool; struct DRW_Attributes; @@ -39,6 +40,7 @@ class CurveRefinePass; class View; } // namespace blender::draw struct GPUMaterial; +struct GSet; /** Use draw manager to call GPU_select, see: #DRW_draw_select_loop */ #define USE_GPU_SELECT @@ -57,7 +59,6 @@ struct GPUMaterial; #define USE_PROFILE #ifdef USE_PROFILE -# include "BLI_time.h" # define PROFILE_TIMER_FALLOFF 0.04 diff --git a/source/blender/draw/intern/draw_manager_profiling.cc b/source/blender/draw/intern/draw_manager_profiling.cc index 46417141f58..627ad43f0fc 100644 --- a/source/blender/draw/intern/draw_manager_profiling.cc +++ b/source/blender/draw/intern/draw_manager_profiling.cc @@ -8,8 +8,6 @@ #include -#include "BLI_listbase.h" -#include "BLI_rect.h" #include "BLI_string.h" #include "BKE_global.hh" @@ -26,6 +24,7 @@ #include "UI_resources.hh" #include "draw_manager_profiling.hh" +#include "draw_view_data.hh" #define MAX_TIMER_NAME 32 #define MAX_NESTED_TIMER 8 diff --git a/source/blender/draw/intern/draw_manager_shader.cc b/source/blender/draw/intern/draw_manager_shader.cc index 1631b7195f4..f5779a0eee8 100644 --- a/source/blender/draw/intern/draw_manager_shader.cc +++ b/source/blender/draw/intern/draw_manager_shader.cc @@ -7,30 +7,17 @@ */ #include "DNA_material_types.h" -#include "DNA_object_types.h" #include "DNA_world_types.h" -#include "BLI_dynstr.h" -#include "BLI_listbase.h" -#include "BLI_map.hh" -#include "BLI_string_utils.hh" #include "BLI_threads.h" #include "BLI_time.h" -#include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_main.hh" - #include "DEG_depsgraph_query.hh" #include "GPU_capabilities.hh" #include "GPU_material.hh" -#include "GPU_shader.hh" #include "WM_api.hh" -#include "WM_types.hh" - -#include "wm_window.hh" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 2a196c98cb3..18e93ee9851 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_math_color.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" @@ -35,7 +36,6 @@ #include "GPU_matrix.hh" #include "GPU_state.hh" -#include "ED_screen.hh" #include "ED_view3d.hh" #include "UI_interface.hh" diff --git a/source/blender/draw/intern/draw_pointcloud.cc b/source/blender/draw/intern/draw_pointcloud.cc index 3dad271ba41..4d489d2351f 100644 --- a/source/blender/draw/intern/draw_pointcloud.cc +++ b/source/blender/draw/intern/draw_pointcloud.cc @@ -6,23 +6,16 @@ * \ingroup draw */ -#include "BLI_string_utils.hh" -#include "BLI_utildefines.h" - #include "DNA_pointcloud_types.h" #include "GPU_batch.hh" -#include "GPU_capabilities.hh" -#include "GPU_compute.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" #include "GPU_vertex_buffer.hh" -#include "DRW_gpu_wrapper.hh" #include "DRW_render.hh" -#include "draw_attributes.hh" #include "draw_cache_impl.hh" #include "draw_common.hh" #include "draw_common_c.hh" diff --git a/source/blender/draw/intern/draw_resource.cc b/source/blender/draw/intern/draw_resource.cc index 40c1e9b4261..c983909a89e 100644 --- a/source/blender/draw/intern/draw_resource.cc +++ b/source/blender/draw/intern/draw_resource.cc @@ -6,13 +6,10 @@ * \ingroup draw */ -#include "DNA_particle_types.h" -#include "RNA_access.hh" -#include "RNA_path.hh" -#include "RNA_types.hh" +#include "BKE_duplilist.hh" +#include "GPU_material.hh" #include "draw_handle.hh" -#include "draw_manager.hh" #include "draw_shader_shared.hh" /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 4ab7f1e7da5..25ca9e916ce 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -26,7 +26,6 @@ #include "DNA_object_types.h" #include "draw_handle.hh" -#include "draw_manager.hh" #include "draw_shader_shared.hh" /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_sculpt.cc b/source/blender/draw/intern/draw_sculpt.cc index 20e905fdd38..52e2d289b86 100644 --- a/source/blender/draw/intern/draw_sculpt.cc +++ b/source/blender/draw/intern/draw_sculpt.cc @@ -8,14 +8,19 @@ #include "draw_sculpt.hh" +#include "DNA_mesh_types.h" #include "draw_attributes.hh" +#include "draw_view.hh" #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_mesh_types.hh" +#include "BKE_object.hh" #include "BKE_paint.hh" +#include "BLI_math_matrix.hh" + #include "DRW_pbvh.hh" +#include "DRW_render.hh" namespace blender::draw { diff --git a/source/blender/draw/intern/draw_sculpt.hh b/source/blender/draw/intern/draw_sculpt.hh index 69e6d9216c6..1ea3f391e17 100644 --- a/source/blender/draw/intern/draw_sculpt.hh +++ b/source/blender/draw/intern/draw_sculpt.hh @@ -8,7 +8,14 @@ #pragma once -#include "draw_manager.hh" +#include "BLI_math_vector_types.hh" +#include "BLI_vector.hh" + +struct GPUMaterial; +struct Object; +namespace blender::gpu { +class Batch; +} namespace blender::draw { diff --git a/source/blender/draw/intern/draw_select_buffer.cc b/source/blender/draw/intern/draw_select_buffer.cc index 3b0d311dd48..8adb01ef56d 100644 --- a/source/blender/draw/intern/draw_select_buffer.cc +++ b/source/blender/draw/intern/draw_select_buffer.cc @@ -8,25 +8,30 @@ * Utilities to read id buffer created in select_engine. */ +#include + #include "MEM_guardedalloc.h" #include "BLI_array_utils.h" #include "BLI_bitmap.h" #include "BLI_bitmap_draw_2d.h" +#include "BLI_math_matrix.h" #include "BLI_rect.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_view3d_types.h" +#include "GPU_framebuffer.hh" #include "GPU_select.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" #include "DRW_engine.hh" +#include "DRW_render.hh" #include "DRW_select_buffer.hh" -#include "draw_manager_c.hh" - #include "../engines/select/select_engine.hh" using blender::int2; diff --git a/source/blender/draw/intern/draw_shader.cc b/source/blender/draw/intern/draw_shader.cc index 22ebffdd4c1..4513d13576a 100644 --- a/source/blender/draw/intern/draw_shader.cc +++ b/source/blender/draw/intern/draw_shader.cc @@ -8,12 +8,7 @@ #include "DRW_render.hh" -#include "BLI_dynstr.h" -#include "BLI_string_utils.hh" - #include "GPU_batch.hh" -#include "GPU_index_buffer.hh" -#include "GPU_vertex_buffer.hh" #include "draw_shader.hh" diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc index b32e31f4188..ab19cedf1dc 100644 --- a/source/blender/draw/intern/draw_view.cc +++ b/source/blender/draw/intern/draw_view.cc @@ -7,7 +7,9 @@ */ #include "BLI_math_geom.h" +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" + #include "GPU_compute.hh" #include "GPU_debug.hh" diff --git a/source/blender/draw/intern/draw_view.hh b/source/blender/draw/intern/draw_view.hh index c6a869707b9..9632960f656 100644 --- a/source/blender/draw/intern/draw_view.hh +++ b/source/blender/draw/intern/draw_view.hh @@ -17,7 +17,6 @@ * setting `drw_view_id` accordingly. */ -#include "DNA_view3d_types.h" #include "DRW_gpu_wrapper.hh" #include "GPU_matrix.hh" diff --git a/source/blender/draw/intern/draw_view_c.cc b/source/blender/draw/intern/draw_view_c.cc index 446bcbbf758..27714ee33ab 100644 --- a/source/blender/draw/intern/draw_view_c.cc +++ b/source/blender/draw/intern/draw_view_c.cc @@ -14,7 +14,6 @@ #include "DNA_view3d_types.h" #include "ED_screen.hh" -#include "ED_util.hh" #include "ED_view3d.hh" #include "GPU_debug.hh" @@ -34,9 +33,13 @@ #include "BKE_paint.hh" #include "BKE_screen.hh" -#include "view3d_intern.hh" +#include "DRW_engine.hh" +#include "DRW_render.hh" + +#include "draw_cache.hh" +#include "draw_view_c.hh" -#include "draw_manager_c.hh" +#include "view3d_intern.hh" /* ******************** region info ***************** */ diff --git a/source/blender/draw/intern/draw_view_data.cc b/source/blender/draw/intern/draw_view_data.cc index 4be0028b6dd..57d0e8b3b41 100644 --- a/source/blender/draw/intern/draw_view_data.cc +++ b/source/blender/draw/intern/draw_view_data.cc @@ -10,14 +10,11 @@ #include "BLI_vector.hh" -#include "GPU_capabilities.hh" #include "GPU_viewport.hh" #include "DRW_gpu_wrapper.hh" #include "DRW_render.hh" -#include "draw_instance_data.hh" - #include "draw_manager_text.hh" #include "draw_manager.hh" diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index b3415175b0d..eb9300ee1a3 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -14,7 +14,8 @@ #include "DNA_fluid_types.h" #include "DNA_volume_types.h" -#include "BKE_fluid.h" +#include "BLI_string.h" + #include "BKE_global.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" @@ -23,6 +24,7 @@ #include "GPU_material.hh" +#include "draw_cache.hh" #include "draw_common_c.hh" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh.cc index 8bf0b6a3ac0..833df94f369 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh.cc @@ -8,10 +8,7 @@ * \brief Extraction of Mesh data into VBO to feed to GPU. */ -#include "MEM_guardedalloc.h" - #include "DNA_meshdata_types.h" -#include "DNA_object_types.h" #include "ED_uvedit.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc index fddc24efd8b..e70d55adc9f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc @@ -8,7 +8,6 @@ #include "BLI_map.hh" #include "BLI_ordered_edge.hh" -#include "BLI_vector.hh" #include "BKE_editmesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc index 7cc1fe7862a..aab6c40ae2b 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc @@ -6,8 +6,6 @@ * \ingroup draw */ -#include "BLI_array_utils.hh" - #include "GPU_index_buffer.hh" #include "draw_subdivision.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index 04daab3e41d..8cf3332b123 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -6,10 +6,7 @@ * \ingroup draw */ -#include "MEM_guardedalloc.h" - #include "BLI_array_utils.hh" -#include "BLI_math_vector_types.hh" #include "BLI_string.h" #include "BKE_attribute.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc index 84f406187bc..b3e088cac9f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc @@ -8,8 +8,6 @@ #include "BLI_math_vector_types.hh" -#include "MEM_guardedalloc.h" - #include "BKE_attribute.hh" #include "BKE_mesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc index 1919347f673..10fb18dd69c 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc @@ -6,10 +6,7 @@ * \ingroup draw */ -#include "MEM_guardedalloc.h" - #include "BLI_array_utils.hh" -#include "BLI_string.h" #include "BKE_attribute.hh" #include "BKE_mesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc index 14fd5c267cb..bc0df880b08 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc @@ -6,11 +6,8 @@ * \ingroup draw */ -#include "MEM_guardedalloc.h" - #include "BLI_string.h" -#include "BKE_editmesh.hh" #include "BKE_editmesh_tangent.hh" #include "BKE_mesh.hh" #include "BKE_mesh_tangent.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc index a8b87bf4780..b4ca93c4d4f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc @@ -11,7 +11,6 @@ #include "BLI_array_utils.hh" #include "BKE_deform.hh" -#include "BKE_mesh.hh" #include "draw_subdivision.hh" #include "extract_mesh.hh" From 62a0350f6d18780a358e4d90be43f407d664d202 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 22 Jan 2025 20:24:54 +0100 Subject: [PATCH 45/46] Fix #91223: Draw Non-Object Active Items in Text Hi In the Outliner, draw the text of active collections, scenes, and view layers in "text highlight" color, by default a brighter white than the regular items. This helps differentiate the active ones a bit better and also allows them to be themed separately. Pull Request: https://projects.blender.org/blender/blender/pulls/133390 --- source/blender/editors/space_outliner/outliner_draw.cc | 8 ++++++++ source/blender/editors/space_outliner/outliner_select.cc | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 79469867481..2b123cabb83 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -3380,11 +3380,19 @@ static void outliner_draw_tree_element(uiBlock *block, /* Active items like camera or material. */ icon_bgcolor[3] = 0.2f; active = OL_DRAWSEL_ACTIVE; + if (te->idcode == ID_SCE) { + UI_GetThemeColor3ubv(TH_TEXT_HI, text_color); + text_color[3] = 255; + } } } } else { active = tree_element_type_active_state_get(tvc, te, tselem); + if (active != OL_DRAWSEL_NONE) { + UI_GetThemeColor3ubv(TH_TEXT_HI, text_color); + text_color[3] = 255; + } } /* Active circle. */ diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index 34dede0f276..dc6e38f1803 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -995,11 +995,6 @@ static eOLDrawState tree_element_posechannel_state_get(const Object *ob_pose, static eOLDrawState tree_element_viewlayer_state_get(const ViewLayer *view_layer, const TreeElement *te) { - /* paranoia check */ - if (te->idcode != ID_SCE) { - return OL_DRAWSEL_NONE; - } - const ViewLayer *te_view_layer = static_cast(te->directdata); if (view_layer == te_view_layer) { From b24d8822ef1f95741f2a6849a73fcbe55e45d709 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Wed, 22 Jan 2025 21:05:26 +0100 Subject: [PATCH 46/46] Build: Add config print for WITH_AUDASPACE and WITH_OPENSUBDIV This commit adds two entries into the "Build Options:" CMake print to assist in verifying configuration both locally and on the buildbot. Pull Request: https://projects.blender.org/blender/blender/pulls/133409 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7153b6340e5..4829b599412 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2739,6 +2739,7 @@ if(FIRST_RUN) info_cfg_option(WITH_OPENCOLLADA) info_cfg_option(WITH_OPENCOLORIO) info_cfg_option(WITH_OPENIMAGEDENOISE) + info_cfg_option(WITH_OPENSUBDIV) info_cfg_option(WITH_OPENVDB) info_cfg_option(WITH_POTRACE) info_cfg_option(WITH_PUGIXML) @@ -2781,6 +2782,7 @@ if(FIRST_RUN) info_cfg_option(WITH_IMAGE_OPENJPEG) info_cfg_text("Audio:") + info_cfg_option(WITH_AUDASPACE) info_cfg_option(WITH_CODEC_FFMPEG) info_cfg_option(WITH_CODEC_SNDFILE) info_cfg_option(WITH_COREAUDIO)