GPencil: Gradient weight paint tool #111133

Open
Sietse Brouwer wants to merge 12 commits from SietseB/blender:gp-weight-paint-gradient-tool into main

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

This patch adds the gradient tool to the weight paint tools in Grease Pencil.
The gradient tool follows the same logic as the weight gradient tool on
3D meshes. The gradient is drawn interactively in the viewport, shown by
a dotted line and the vertex weight colors on the stroke points changing
on the fly.

The user can:

  • choose between a linear and radial gradient
  • switch between adding/subtracting weight with shortcut 'D'
This patch adds the gradient tool to the weight paint tools in Grease Pencil. The gradient tool follows the same logic as the weight gradient tool on 3D meshes. The gradient is drawn interactively in the viewport, shown by a dotted line and the vertex weight colors on the stroke points changing on the fly. The user can: - choose between a linear and radial gradient - switch between adding/subtracting weight with shortcut 'D'
Sietse Brouwer added 5 commits 2023-08-15 13:14:35 +02:00
cd7404db5b Gpencil: gradient tool added to weight paint tools
This patch adds the gradient tool to the weight paint tools in Grease Pencil.
The gradient tool follows the same logic as the weight gradient tool on
3D meshes. The gradient is drawn interactively in the viewport, shown by
a dotted line and the vertex weight colors changing on the fly.

The user can:
- choose between a linear and radial gradient
- switch between adding/subtracting weight with shortcut 'D'
Sietse Brouwer added this to the Grease Pencil project 2023-08-15 13:14:56 +02:00
Sietse Brouwer requested review from Falk David 2023-08-15 13:15:12 +02:00

The gradient weight paint tool works really well, great job @SietseB !

The gradient weight paint tool works really well, great job @SietseB !
Sietse Brouwer added 3 commits 2023-08-17 21:27:45 +02:00
Sietse Brouwer added 3 commits 2023-12-12 13:57:28 +01:00
Falk David requested changes 2023-12-14 16:38:28 +01:00
Falk David left a comment
Member

I read through the patch and added some comments. It's a bit unfortunate, that this is all written more in a C-Style rather than utilizing C++ for e.g. memory managment benefits.

But there is a more important question here which is: can we still accept patches (especially larger ones) for grease pencil, while the grease pencil 3 migration is happening? Maybe one of the admins (e.g. @brecht ) can comment, on this.

I read through the patch and added some comments. It's a bit unfortunate, that this is all written more in a C-Style rather than utilizing C++ for e.g. memory managment benefits. But there is a more important question here which is: can we still accept patches (especially larger ones) for grease pencil, while the grease pencil 3 migration is happening? Maybe one of the admins (e.g. @brecht ) can comment, on this.
@ -160,1 +161,4 @@
settings = tool_settings.gpencil_weight_paint
# The brush of the gradient tool isn't automatically activated
# by the window manager, so we select it here manually.
tool = context.workspace.tools.from_space_view3d_mode(context.mode, create=False)
Member

Hm this doens't seem right. I suspect this is a problem with the keymap maybe.

Hm this doens't seem right. I suspect this is a problem with the keymap maybe.
Author
Member

The thing here is:

  • The gradient tool is not a brush tool (you don't paint with a circled brush cursor over vertices).
  • But it does need brush settings.

The weight gradient tool on 3D meshes has pretty erratic behaviour: it uses the brush settings of the last tool you used before the gradient tool. I'll upload a video demo of that in the main conversation.
I didn't want to copy that confusing behaviour for GP. So I came up with this: manually creating and activating brush settings, since the window manager can't take care of that.
I agree, the code isn't pretty. But bad UX is worse than less pretty code, IMHO.

The thing here is: - The gradient tool is not a _brush_ tool (you don't paint with a circled brush cursor over vertices). - But it does need _brush settings_. The weight gradient tool on 3D meshes has pretty erratic behaviour: it uses the brush settings of the last tool you used before the gradient tool. I'll upload a video demo of that in the main conversation. I didn't want to copy that confusing behaviour for GP. So I came up with this: manually creating and activating brush settings, since the window manager can't take care of that. I agree, the code isn't pretty. But bad UX is worse than less pretty code, IMHO.
@ -1520,0 +1524,4 @@
* by the window manager, so we select it here manually.
*/
bToolRef *tref = WM_toolsystem_ref_from_context(C);
if (tref && STREQ(tref->idname, "builtin.gradient")) {
Member

Same as above. This seems very hackish.

Same as above. This seems very hackish.
@ -1684,0 +2020,4 @@
tool_data->line_segment_len_sq = dot_v2v2(tool_data->line_segment, tool_data->line_segment);
tool_data->radius = sqrtf(tool_data->line_segment_len_sq);
if (tool_data->line_segment_len_sq == 0.0f) {
goto finally;
Member

No need for a goto here. Either creating a static function for the clean-up or just copying the code would be better.
Looks like you already have something similar: gpencil_weight_gradient_finish

No need for a `goto` here. Either creating a static function for the clean-up or just copying the code would be better. Looks like you already have something similar: `gpencil_weight_gradient_finish`
SietseB marked this conversation as resolved

@filedescriptor I think it's really a judgement for the grease pencil 3 team to make.

If you want to be strict and say, we only accept new operators for grease pencil 3 and will not change existing ones, or require anything to be at least implemented for both 2 and 3, then that's reasonable.

If you want to be more flexible, it seems reasonable too as long as it's limited to a few things that won't slow down the project overall much.

@filedescriptor I think it's really a judgement for the grease pencil 3 team to make. If you want to be strict and say, we only accept new operators for grease pencil 3 and will not change existing ones, or require anything to be at least implemented for both 2 and 3, then that's reasonable. If you want to be more flexible, it seems reasonable too as long as it's limited to a few things that won't slow down the project overall much.
Sietse Brouwer added 1 commit 2023-12-21 23:44:08 +01:00
Author
Member

Thanks for reviewing this odd duck in legacy style! When I wrote this PR, the file was plain .c, so no fancy C++ here indeed. I could rewrite it now, but I guess it's more efficient to spend that time and energy to the GPv3 version of all the weight paint tools? It's on my list to do that conversion (once it is clear how vertex weights are stored in the curve attributes). I will include this one then, of course.

Thanks for reviewing this odd duck in legacy style! When I wrote this PR, the file was plain `.c`, so no fancy C++ here indeed. I could rewrite it now, but I guess it's more efficient to spend that time and energy to the GPv3 version of all the weight paint tools? It's on my list to do that conversion (once it is clear how vertex weights are stored in the curve attributes). I will include this one then, of course.
Author
Member

Demo of the odd behaviour of the weight gradient tool on 3D meshes. It lacks its own settings.

Demo of the odd behaviour of the weight gradient tool on 3D meshes. It lacks its own settings. <video src="https://projects.blender.org/attachments/21f6bb32-cb80-4258-a930-bd6d240f237b" controls>
This pull request has changes conflicting with the target branch.
  • scripts/presets/keyconfig/keymap_data/blender_default.py
  • scripts/startup/bl_ui/space_view3d.py
  • source/blender/editors/gpencil_legacy/gpencil_intern.h
  • source/blender/editors/gpencil_legacy/gpencil_weight_paint.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u gp-weight-paint-gradient-tool:SietseB-gp-weight-paint-gradient-tool
git checkout SietseB-gp-weight-paint-gradient-tool
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
4 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#111133
No description provided.