Fix #111490: paint radius set to 1 (shift-smoothing but brush missing) #111516

Merged
Philipp Oeser merged 5 commits from lichtwerk/blender:111490 into main 2023-08-29 13:44:42 +02:00
Member

This affected sculpt, vertex- and weightpaint.

So attempting to (temporarily) switching to the smooth/blur tools from
another tool using the "Shift" shortcut can fail if the corresponding
smooth/blur brush is not found/missing [which was the case in the report
because the brush was deleted].

In this case, brushes dont really get switched, but blender would still
try to cache the size (because the smooth/blur brush temporarily uses
the same size as the previous brush) of the smooth brush in
StrokeCache (see smooth_brush_toggle_on). Then in
smooth_brush_toggle_off it was assumed brushes were actually switched
and the (non-existing) size of the (missing) smooth brush was applied to
the actual brush.

Now restructure code a bit so in the case of a missing brush we can
early out (without affecting the actual brush then).

This affected sculpt, vertex- and weightpaint. So attempting to (temporarily) switching to the smooth/blur tools from another tool using the "Shift" shortcut can fail if the corresponding smooth/blur brush is not found/missing [which was the case in the report because the brush was deleted]. In this case, brushes dont really get switched, but blender would still try to cache the size (because the smooth/blur brush temporarily uses the same size as the previous brush) of the smooth brush in `StrokeCache` (see `smooth_brush_toggle_on`). Then in `smooth_brush_toggle_off` it was assumed brushes were actually switched and the (non-existing) size of the (missing) smooth brush was applied to the **actual** brush. Now restructure code a bit so in the case of a missing brush we can early out (without affecting the **actual** brush then).
Philipp Oeser added 1 commit 2023-08-25 12:45:25 +02:00
98823b6c16 Fix #111490: paint radius set to 1 (shift-smoothing but brush missing)
This affected sculpt, vertex- and weightpaint.

So attempting to (temporarily) switching to the smooth/blur tools from
another tool using the "Shift" shortcut can fail if the corresponding
smooth/blur brush is not found/missing [which was the case in the report
because the brush was deleted].

In this case, brushes dont really get switched, but blender would still
try to cache the size (because the smooth/blur brush temporarily uses
the same size as the previous brush) of the smooth brush in
`StrokeCache` (see `smooth_brush_toggle_on`). Then in
`smooth_brush_toggle_off` it was assumed brushes were actually switched
and the (non-existing) size of the (missing) smooth brush was applied to
the **actual** brush.

Now restructure code a bit so in the case of a missing brush we can
early out (without affecting the **actual** brush then).
Philipp Oeser added this to the Sculpt, Paint & Texture project 2023-08-25 12:45:33 +02:00
Philipp Oeser requested review from Sergey Sharybin 2023-08-25 12:45:44 +02:00
Philipp Oeser requested review from Julien Kaspar 2023-08-25 12:45:51 +02:00
Author
Member

Alternatively, we could enforce a default smooth brush to be created? (just like using the smooth tool would do if you try to use it with the corresponding brush missing)

Alternatively, we could enforce a default smooth brush to be created? (just like using the smooth tool would do if you try to use it with the corresponding brush missing)

I am not sure crating a brush which was explicitly delete is more expected behavior.

To keep things simple we can just stick to fixing the originally intended behavior.
Either I'm missing something, or moving BKE_brush_size_set(scene, brush, cache->saved_smooth_size); inside if (brush) {, so that we do not restore anything unless brush is restored.

I am not sure crating a brush which was explicitly delete is more expected behavior. To keep things simple we can just stick to fixing the originally intended behavior. Either I'm missing something, or moving `BKE_brush_size_set(scene, brush, cache->saved_smooth_size);` inside `if (brush) {`, so that we do not restore anything unless brush is restored.
Sergey Sharybin reviewed 2023-08-25 15:38:52 +02:00
@ -4402,0 +4400,4 @@
* same, see comments for eBrushVertexPaintTool & eBrushWeightPaintTool. */
/* If the smooth brush is missing, brush was not switched/affected in smooth_brush_toggle_on().
*/
if (!BKE_paint_toolslots_brush_get(paint, SCULPT_TOOL_SMOOTH)) {

It feels a bit redundant to be checking both BKE_paint_toolslots_brush_get(paint, SCULPT_TOOL_SMOOTH) and if (brush) {.

perhaps foo_on should clear saved_active_brush_name if the brush is not found, and here move BKE_brush_size_set(scene, brush, cache->saved_smooth_size); inside of the if (brush) {.

It feels a bit redundant to be checking both `BKE_paint_toolslots_brush_get(paint, SCULPT_TOOL_SMOOTH)` and `if (brush) {`. perhaps foo_on should clear `saved_active_brush_name` if the brush is not found, and here move `BKE_brush_size_set(scene, brush, cache->saved_smooth_size);` inside of the `if (brush) {`.
Author
Member

done

done
lichtwerk marked this conversation as resolved
Philipp Oeser added 1 commit 2023-08-25 16:49:03 +02:00

On a code side I think it is fine.
But I am curious what Julien thinks of the warning report.

On a code side I think it is fine. But I am curious what Julien thinks of the warning report.
Member

Built and tried out the patch. Not getting any warning message. But the brush radius issue is fixed.

But in theory I'm fine with this. For the brush asset support we'll need to rework this but that can wait.

Built and tried out the patch. Not getting any warning message. But the brush radius issue is fixed. But in theory I'm fine with this. For the brush asset support we'll need to rework this but that can wait.
Author
Member

Built and tried out the patch. Not getting any warning message. But the brush radius issue is fixed.

But in theory I'm fine with this. For the brush asset support we'll need to rework this but that can wait.

It prints to the console only.

So anyone dares to give green light?

> Built and tried out the patch. Not getting any warning message. But the brush radius issue is fixed. > > But in theory I'm fine with this. For the brush asset support we'll need to rework this but that can wait. It prints to the console only. So anyone dares to give green light?

It prints to the console only.

Ah, somehow it seemed to be using reports. Not sure why it seemed that way.

We should be using CLOG_WARN instead of printf("WARNING").
But I also not really sure how important that is. Console is not something artists are keeping an eye on.

> It prints to the console only. Ah, somehow it seemed to be using reports. Not sure why it seemed that way. We should be using `CLOG_WARN` instead of `printf("WARNING")`. But I also not really sure how important that is. Console is not something artists are keeping an eye on.
Philipp Oeser added 1 commit 2023-08-28 14:45:44 +02:00
Sergey Sharybin approved these changes 2023-08-28 15:15:56 +02:00
Sergey Sharybin left a comment
Owner

Thanks for the update!

I was mainly doing careful reading, and the logic seems fine. Make sure you've tested the change after latest i[dates and push it! :)

Thanks for the update! I was mainly doing careful reading, and the logic seems fine. Make sure you've tested the change after latest i[dates and push it! :)
Philipp Oeser added 1 commit 2023-08-29 13:33:36 +02:00
Author
Member

Thanks for the update!

I was mainly doing careful reading, and the logic seems fine. Make sure you've tested the change after latest i[dates and push it! :)

Well, sculpt mode crashes atm, in main as well, but this has almost certainly nothing to do with this patch, will dare pushing it anyways

> Thanks for the update! > > I was mainly doing careful reading, and the logic seems fine. Make sure you've tested the change after latest i[dates and push it! :) Well, sculpt mode crashes atm, in main as well, but this has almost certainly nothing to do with this patch, will dare pushing it anyways
Philipp Oeser added 1 commit 2023-08-29 13:42:58 +02:00
Philipp Oeser merged commit cc01bb83f6 into main 2023-08-29 13:44:42 +02:00
Philipp Oeser deleted branch 111490 2023-08-29 13:44:46 +02:00
Sign in to join this conversation.
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 Assignees
3 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#111516
No description provided.