Grease Pencil: Sculpt Tools Will Revert Back to Add After One Use of Subtract #115313

Closed
opened 2023-11-23 18:59:28 +01:00 by Weston-Meade · 12 comments

System Information
Operating system: Microsoft Windows 11 Home
Graphics card: NVIDIA GeForce RTX 3060 Ti

Blender Version
Broken: 4.0.0 (As shown on splash screen and downloaded from the main website)
Worked: 3.6.6 Stable

Short description of error
When manually switching a sculpt tool from +add to -subtract (As in pressing the GUI button, rather than using the CTRL key), the tool will automatically switch back to +add after using it one time.

(I have tested this on the 4.1.0 Alpha with both my own settings configs and factory default settings with the same result)

Exact steps for others to reproduce the error
Open a 2D Animation file or create a new one.
Draw a stroke of any thickness.
Go into sculpt mode.
Change the tool to any tool that has an alternate mode (+ -) and set the mode to the subtract mode.
Sculpt the stroke once, if it does not change back immediately try sculpting the stroke one more time.

**System Information** Operating system: Microsoft Windows 11 Home Graphics card: NVIDIA GeForce RTX 3060 Ti **Blender Version** Broken: 4.0.0 (As shown on splash screen and downloaded from the main website) Worked: 3.6.6 Stable **Short description of error** When manually switching a sculpt tool from +add to -subtract (As in pressing the GUI button, rather than using the CTRL key), the tool will automatically switch back to +add after using it one time. (I have tested this on the 4.1.0 Alpha with both my own settings configs and factory default settings with the same result) **Exact steps for others to reproduce the error** Open a 2D Animation file or create a new one. Draw a stroke of any thickness. Go into sculpt mode. Change the tool to any tool that has an alternate mode (+ -) and set the mode to the subtract mode. Sculpt the stroke once, if it does not change back immediately try sculpting the stroke one more time.
Weston-Meade added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-11-23 18:59:29 +01:00
Contributor

I also have that

I also have that
Member

Hi, thanks for the report. Can confirm the regression, checking.

Hi, thanks for the report. Can confirm the regression, checking.
Member
Caused by 325acb51dfce14421f83a40c338bde22f8602861 @JacquesLucke @antoniov ^
Member

Guess I found the fix.

Guess I found the fix.
Pratik Borhade self-assigned this 2023-11-24 11:21:49 +01:00
Member

The root problem here seems to be that BrushGpencilSettings.sculpt_flag is a mess. It's used with e.g. BRUSH_DIR_IN (from eBrushFlags), with GP_SCULPT_FLAG_TMP_INVERT (from eGP_Sculpt_Flag) and GP_SCULPT_FLAGMODE_APPLY_THICKNESS (from eGP_Sculpt_Mode_Flag).

This caused the issue in the C++ conversion, because of the newly added ENUM_OPERATORS(eGP_Sculpt_Flag, GP_SCULPT_FLAG_TMP_INVERT). The problem is that the passed max value is not actually the max value, even though it looks like it should based on the code.

The fix would be to pass the actual max value into the ENUM_OPERATORS macro. Since the max value is not obvious right now, I'd like to ask @antoniov to look into this.

The root problem here seems to be that `BrushGpencilSettings.sculpt_flag` is a mess. It's used with e.g. `BRUSH_DIR_IN` (from `eBrushFlags`), with `GP_SCULPT_FLAG_TMP_INVERT` (from `eGP_Sculpt_Flag`) and `GP_SCULPT_FLAGMODE_APPLY_THICKNESS` (from `eGP_Sculpt_Mode_Flag`). This caused the issue in the C++ conversion, because of the newly added `ENUM_OPERATORS(eGP_Sculpt_Flag, GP_SCULPT_FLAG_TMP_INVERT)`. The problem is that the passed max value is not actually the max value, even though it looks like it should based on the code. The fix would be to pass the actual max value into the `ENUM_OPERATORS` macro. Since the max value is not obvious right now, I'd like to ask @antoniov to look into this.
Member

Following diff fixes the problem:
Below bitwise operation was giving wrong answer after clearing the flag so I tried explicit casting.
But I don't quite understand why we require explicit casting here, shouldn't enum be implicitly treated as int in this operation?

diff --git a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc
index b79b41dd5a1..7bd6555333b 100644
--- a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc
+++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc
@@ -1338,7 +1338,7 @@ static void gpencil_sculpt_brush_exit(bContext *C, wmOperator *op)
   ED_workspace_status_text(C, nullptr);

   /* disable temp invert flag */
-  gso->brush->gpencil_settings->sculpt_flag &= ~GP_SCULPT_FLAG_TMP_INVERT;
+  gso->brush->gpencil_settings->sculpt_flag &= ~static_cast<int>(GP_SCULPT_FLAG_TMP_INVERT);

   /* Update geometry data for tagged strokes. */
   gpencil_update_geometry(gso->gpd);
Following diff fixes the problem: Below bitwise operation was giving wrong answer after clearing the flag so I tried explicit casting. But I don't quite understand why we require explicit casting here, shouldn't enum be implicitly treated as int in this operation? ``` diff --git a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc index b79b41dd5a1..7bd6555333b 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc @@ -1338,7 +1338,7 @@ static void gpencil_sculpt_brush_exit(bContext *C, wmOperator *op) ED_workspace_status_text(C, nullptr); /* disable temp invert flag */ - gso->brush->gpencil_settings->sculpt_flag &= ~GP_SCULPT_FLAG_TMP_INVERT; + gso->brush->gpencil_settings->sculpt_flag &= ~static_cast<int>(GP_SCULPT_FLAG_TMP_INVERT); /* Update geometry data for tagged strokes. */ gpencil_update_geometry(gso->gpd); ```
Member

Oh @JacquesLucke already commented, didn't notice that

Oh @JacquesLucke already commented, didn't notice that
Pratik Borhade removed their assignment 2023-11-24 11:39:38 +01:00
Member

Your fix should work as well, but I think it would be better to fix the root cause of the bug.

Your fix should work as well, but I think it would be better to fix the root cause of the bug.
Member

@antoniov Could you look into this. It seems like right now there is sculpt_flag and sculpt_mode_flag, but sometimes sculpt_flag is using flags from eGP_Sculpt_Mode_Flag or eBrushFlags. There should be some consistency here.

@antoniov Could you look into this. It seems like right now there is `sculpt_flag` and `sculpt_mode_flag`, but sometimes `sculpt_flag` is using flags from `eGP_Sculpt_Mode_Flag` or `eBrushFlags`. There should be some consistency here.

I'm really sorry, but right now I'm very busy working on several personal projects and I don't have the time or energy to dedicate myself to fixing Blender bugs.

I'm really sorry, but right now I'm very busy working on several personal projects and I don't have the time or energy to dedicate myself to fixing Blender bugs.
Falk David added this to the Grease Pencil project 2024-03-08 12:21:32 +01:00

Any update here? Would be good to have a solution for 4.1, even if the root cause isn't fixed.

Any update here? Would be good to have a solution for 4.1, even if the root cause isn't fixed.
Member

@ThomasDinges working on it :)

@ThomasDinges working on it :)
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-03-12 14:23:06 +01: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 project
No Assignees
7 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#115313
No description provided.