From f308e42d564f407224ef7a8569ae9e64e084402f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 3 Oct 2024 19:30:45 +0200 Subject: [PATCH 1/3] Fix: EEVEE: Volume Lightprobe: Division by zero if no object is visible If no object with valid bounds can be found, we simply abort the baking process. This avoid a division by zero during the view planes computation. --- .../draw/engines/eevee_next/eevee_lightprobe_volume.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 1997e210d74..4b14ea5220e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc @@ -932,8 +932,8 @@ void IrradianceBake::surfels_create(const Object &probe_object) capture_info_buf_.do_surfel_count = false; capture_info_buf_.do_surfel_output = false; - int neg_flt_max = int(0xFF7FFFFFu ^ 0x7FFFFFFFu); /* floatBitsToOrderedInt(-FLT_MAX) */ - int pos_flt_max = 0x7F7FFFFF; /* floatBitsToOrderedInt(FLT_MAX) */ + const int neg_flt_max = int(0xFF7FFFFFu ^ 0x7FFFFFFFu); /* floatBitsToOrderedInt(-FLT_MAX) */ + const int pos_flt_max = 0x7F7FFFFF; /* floatBitsToOrderedInt(FLT_MAX) */ capture_info_buf_.scene_bound_x_min = pos_flt_max; capture_info_buf_.scene_bound_y_min = pos_flt_max; capture_info_buf_.scene_bound_z_min = pos_flt_max; @@ -948,6 +948,12 @@ void IrradianceBake::surfels_create(const Object &probe_object) GPU_memory_barrier(GPU_BARRIER_BUFFER_UPDATE); capture_info_buf_.read(); + if (capture_info_buf_.scene_bound_x_min == pos_flt_max) { + /* No valid object has been found. */ + do_break_ = true; + return; + } + auto ordered_int_bits_to_float = [](int32_t int_value) -> float { int32_t float_bits = (int_value < 0) ? (int_value ^ 0x7FFFFFFF) : int_value; return *reinterpret_cast(&float_bits); From 3355ca38131be91f71c915af95819752c9ed7864 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 3 Oct 2024 19:42:49 +0200 Subject: [PATCH 2/3] UI: Increase width of asset shelf popup and clamp by window size Increasing the width of the popup makes it show more assets on the screen and reduces the need to scroll in bigger asset libraries. Plus, in a follow-up commit the size of previews will be increased so that there's more space to display the full name. Makes sense to increase the popup size together with that, so a similar amount of assets can remain visible still. Increasing the size means it's more likely to overflow the window, so this also makes sure the popup is clamped nicely by the window size. --- .../asset/intern/asset_shelf_popover.cc | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/asset/intern/asset_shelf_popover.cc b/source/blender/editors/asset/intern/asset_shelf_popover.cc index e57fdd5c9c2..976336a4539 100644 --- a/source/blender/editors/asset/intern/asset_shelf_popover.cc +++ b/source/blender/editors/asset/intern/asset_shelf_popover.cc @@ -180,18 +180,29 @@ static AssetShelfType *lookup_type_from_idname_in_context(const bContext *C) } constexpr int LEFT_COL_WIDTH_UNITS = 10; -constexpr int RIGHT_COL_WIDTH_UNITS = 30; -constexpr int LAYOUT_WIDTH_UNITS = LEFT_COL_WIDTH_UNITS + RIGHT_COL_WIDTH_UNITS; +constexpr int RIGHT_COL_WIDTH_UNITS_DEFAULT = 50; + +/** + * Ensure the popover width fits into the window: Clamp width by the window width, minus some + * padding. + */ +static int layout_width_units_clamped(const wmWindow *win) +{ + const int max_units_x = (win->sizex / UI_UNIT_X) - 2; + return std::min(LEFT_COL_WIDTH_UNITS + RIGHT_COL_WIDTH_UNITS_DEFAULT, max_units_x); +} static void popover_panel_draw(const bContext *C, Panel *panel) { + const wmWindow *win = CTX_wm_window(C); + const int layout_width_units = layout_width_units_clamped(win); AssetShelfType *shelf_type = lookup_type_from_idname_in_context(C); BLI_assert_msg(shelf_type != nullptr, "couldn't find asset shelf type from context"); const ARegion *region = CTX_wm_region_popup(C) ? CTX_wm_region_popup(C) : CTX_wm_region(C); uiLayout *layout = panel->layout; - uiLayoutSetUnitsX(layout, LAYOUT_WIDTH_UNITS); + uiLayoutSetUnitsX(layout, layout_width_units); AssetShelf *shelf = get_shelf_for_popup(*C, *shelf_type); if (!shelf) { @@ -224,7 +235,8 @@ static void popover_panel_draw(const bContext *C, Panel *panel) ICON_VIEWZOOM); uiLayout *asset_view_col = uiLayoutColumn(right_col, false); - uiLayoutSetUnitsX(asset_view_col, RIGHT_COL_WIDTH_UNITS); + BLI_assert((layout_width_units - LEFT_COL_WIDTH_UNITS) > 0); + uiLayoutSetUnitsX(asset_view_col, layout_width_units - LEFT_COL_WIDTH_UNITS); uiLayoutSetFixedSize(asset_view_col, true); build_asset_view(*asset_view_col, shelf->settings.asset_library_reference, *shelf, *C, *region); From a4d9a38c7037e5ae52a81e341b47ad4401c80183 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 3 Oct 2024 19:49:36 +0200 Subject: [PATCH 3/3] UI: Increase size of previews in asset shelf popups The asset previews were a little smaller than in comparable popups, leading to a lot of truncation in the asset names. Increasing the size mitigates this quite a bit, plus previews get more readable. 3355ca3813 increased the size of the popup so there's more space to put the now bigger previews in. Part of the brush assets followups: ihttps://projects.blender.org/blender/blender/issues/116337 --- source/blender/editors/asset/intern/asset_shelf_popover.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/asset/intern/asset_shelf_popover.cc b/source/blender/editors/asset/intern/asset_shelf_popover.cc index 976336a4539..934f80c0d61 100644 --- a/source/blender/editors/asset/intern/asset_shelf_popover.cc +++ b/source/blender/editors/asset/intern/asset_shelf_popover.cc @@ -71,6 +71,8 @@ static AssetShelf *get_shelf_for_popup(const bContext &C, AssetShelfType &shelf_ if (type_poll_for_popup(C, &shelf_type)) { AssetShelf *new_shelf = create_shelf_from_type(shelf_type); new_shelf->settings.display_flag |= ASSETSHELF_SHOW_NAMES; + /* Increased size of previews, to leave more space for the name. */ + new_shelf->settings.preview_size = ASSET_SHELF_PREVIEW_SIZE_DEFAULT; popup_shelves.append(new_shelf); return new_shelf; }