Fix #107011: Boolean Modifier Overlap Threshold property issue in UI when value is 0 #107466

Closed
Pratik Borhade wants to merge 3 commits from PratikPB2123/blender:fix-107011-overlap-threeshold into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Suppport for non-linear slider was added in e95f71bf15, 0447aedb96.
For startvalue 0, value generated by logarithmic scale is 0 in
ui_numedit_but_NUM() so value remain unchanged. Fix would be to
adjust the softmin/hardmin (as said in the commit message: 0447aedb96)
of this property.

This fix also avoids the assert hit at BLI_assert(value_step > 0.0f)
which happens when value is 0 and clicked on side-arrows.

Suppport for non-linear slider was added in e95f71bf15, 0447aedb96. For startvalue 0, value generated by logarithmic scale is 0 in `ui_numedit_but_NUM()` so value remain unchanged. Fix would be to adjust the softmin/hardmin (as said in the commit message: 0447aedb96) of this property. This fix also avoids the assert hit at `BLI_assert(value_step > 0.0f)` which happens when value is 0 and clicked on side-arrows.
Pratik Borhade added 1 commit 2023-04-29 15:20:33 +02:00
7a1b932049 Fix #107011: Boolean Modifier Overlap Threshold property issue in UI when value is 0
Suppport for non-linear slider was added in e95f71bf15, 0447aedb96.
For startvalue 0, value generated by logarithmic scale is 0 in
`ui_numedit_but_NUM()`. So the fix would to change softmin/hardmin (as
said in the commit message: 0447aedb96) of this property to its default value.

This fix also avoids the assert hit at `BLI_assert(value_step > 0.0f)`
which happens when value is 0 and clicked on side-arrows.
Pratik Borhade requested review from Campbell Barton 2023-04-29 15:20:55 +02:00
Pratik Borhade requested review from Henrik D. 2023-04-29 15:20:55 +02:00
Pratik Borhade added the
Module
Modeling
Interest
Modifiers
labels 2023-04-29 15:21:11 +02:00
Author
Member

Hi, any updates here? Feel free to commit alternative if this fix is incorrect.

Hi, any updates here? Feel free to commit alternative if this fix is incorrect.

Short term, this change could be reverted (for 3.6). In general I think its reasonable to support buttons with a value & soft-min of zero. Especially when zero is a valid value for those buttons.

This example patch shows how the log-precision for the click-step can be clamped by the UI precision (so the click-step is never smaller then the displayed precision).

A similar change could also be applied to button dragging, this kind of change needs to be made carefully so drag/click ... float & int buttons are handled consistently.

diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc
index a7648b61bd8..3a7f9641942 100644
--- a/source/blender/editors/interface/interface_handlers.cc
+++ b/source/blender/editors/interface/interface_handlers.cc
@@ -5492,9 +5492,12 @@ static int ui_do_but_NUM(
 
         double value_step;
         if (scale_type == PROP_SCALE_LOG) {
-          value_step = powf(10.0f,
-                            (roundf(log10f(data->value) + UI_PROP_SCALE_LOG_SNAP_OFFSET) - 1.0f) +
-                                log10f(number_but->step_size));
+          double precision = (roundf(log10f(data->value) + UI_PROP_SCALE_LOG_SNAP_OFFSET) - 1.0f) +
+                             log10f(number_but->step_size);
+          if (!isfinite(precision)) {
+            precision = -FLT_MAX; /* Happens when `data->value` is zero. */
+          }
+          value_step = powf(10.0f, std::max(precision, -number_but->precision));
         }
         else {
           value_step = double(number_but->step_size * UI_PRECISION_FLOAT_SCALE);
Short term, this change could be reverted (for 3.6). In general I think its reasonable to support buttons with a value & soft-min of zero. Especially when zero is a valid value for those buttons. This example patch shows how the log-precision for the click-step can be clamped by the UI precision (so the click-step is never smaller then the displayed precision). A similar change could also be applied to button dragging, this kind of change needs to be made carefully so drag/click ... float & int buttons are handled consistently. ```Diff diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index a7648b61bd8..3a7f9641942 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -5492,9 +5492,12 @@ static int ui_do_but_NUM( double value_step; if (scale_type == PROP_SCALE_LOG) { - value_step = powf(10.0f, - (roundf(log10f(data->value) + UI_PROP_SCALE_LOG_SNAP_OFFSET) - 1.0f) + - log10f(number_but->step_size)); + double precision = (roundf(log10f(data->value) + UI_PROP_SCALE_LOG_SNAP_OFFSET) - 1.0f) + + log10f(number_but->step_size); + if (!isfinite(precision)) { + precision = -FLT_MAX; /* Happens when `data->value` is zero. */ + } + value_step = powf(10.0f, std::max(precision, -number_but->precision)); } else { value_step = double(number_but->step_size * UI_PRECISION_FLOAT_SCALE); ```
Campbell Barton requested changes 2023-05-26 05:24:22 +02:00
Campbell Barton left a comment
Owner

Requesting changes as a zero minimum value can be supported.

Requesting changes as a zero minimum value can be supported.
Pratik Borhade added 2 commits 2023-05-28 15:07:21 +02:00
213af0058f Support zero minimum value for logarithmic scale
- Revert previous change of tweaking soft/hard limits
- Include change proposed by reviewer
- On click-dragging, property value was not incrementing because new
  `data->dragstartx` value is infinite/invalid (when startvalue=0). To
  fix this, pick max value between `startvalue` and `log_min`.
Campbell Barton approved these changes 2023-05-29 01:20:07 +02:00
Campbell Barton approved these changes 2023-05-29 01:44:00 +02:00
Author
Member

Thanks for reviewing and merging the PR :)

Thanks for reviewing and merging the PR :)
Pratik Borhade closed this pull request 2023-05-29 04:27:55 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107466
No description provided.