GPv3: Set Uniform operator for Thickness and Opacity #114006

Merged
Antonio Vazquez merged 20 commits from antoniov/blender:GPv3_normalize into main 2023-11-08 16:19:10 +01:00

This operator has the same functionality that GPv2 version.

Note: The radius is set with the entry value. In GPv2 the radius
was relative to the stroke thickness. Maybe we need review this.

Related to #113991

This operator has the same functionality that GPv2 version. Note: The radius is set with the entry value. In GPv2 the radius was relative to the stroke thickness. Maybe we need review this. Related to #113991
Antonio Vazquez added 1 commit 2023-10-21 17:10:32 +02:00
0304809a16 GPv3: Normalize Stroke operator
This operator has the same functionality that GPv2 version.

Note: The radius is set with the entry value. In GPv2 the radius
was relative to the stroke thickness. Maybe we need review this.
Antonio Vazquez added this to the Grease Pencil project 2023-10-21 17:12:27 +02:00
Antonio Vazquez requested review from Falk David 2023-10-21 17:13:39 +02:00
Antonio Vazquez requested review from Matias Mendiola 2023-10-21 17:13:46 +02:00
Author
Member

@filedescriptor do you have a estimated date for the Undo? Now, check the operators is complex because the Undo is not working.

@filedescriptor do you have a estimated date for the Undo? Now, check the operators is complex because the Undo is not working.
Falk David requested changes 2023-10-21 17:26:07 +02:00
@ -951,0 +970,4 @@
{int(NormalizeMode::OPACITY),
"OPACITY",
0,
"OPacity",
Member

Typo: "Opacity"

Typo: `"Opacity"`
antoniov marked this conversation as resolved
@ -951,0 +1033,4 @@
}
else if (mode == NormalizeMode::OPACITY) {
opacities[point_i] = opacity;
CLAMP(opacities[point_i], 0.0f, 1.0f);
Member

Use math::clamp(...)

Use `math::clamp(...)`
Author
Member

Removed the line because the paramter is filtered already.

Removed the line because the paramter is filtered already.
antoniov marked this conversation as resolved
Antonio Vazquez added 1 commit 2023-10-21 23:44:54 +02:00
Antonio Vazquez added 1 commit 2023-10-21 23:46:19 +02:00
Member

Can we do changes suggested in #113991 (comment) ?
I'm not very confident about it but I guess it would avoid extra for loop of points there.

Can we do changes suggested in https://projects.blender.org/blender/blender/issues/113991#issuecomment-1049905 ? I'm not very confident about it but I guess it would avoid extra for loop of points there.
Antonio Vazquez added 1 commit 2023-10-22 10:23:24 +02:00
3572647f57 GPv3: Remove loop and replace with fill
Following Pratik Borhade advice, the loop
has been replaced with fill function.
Falk David approved these changes 2023-10-31 17:25:37 +01:00
Falk David left a comment
Member

There are some unrelated formatting changes that need to be resolved, but otherwise, this looks good.

There are some unrelated formatting changes that need to be resolved, but otherwise, this looks good.
Antonio Vazquez added 1 commit 2023-10-31 17:27:20 +01:00
Hans Goudey requested changes 2023-10-31 17:31:17 +01:00
@ -951,0 +1019,4 @@
}
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
selected_curves.foreach_index([&](const int curve_index) {
Member

Retrieve the attribute once outside of the loop, then affect it inside, without checking the mode.
Retrieving the attribute by name is very slow compared to everything else, and it also isn't threadsafe when retrieving with write access.

Retrieve the attribute once outside of the loop, then affect it inside, without checking the mode. Retrieving the attribute by name is very slow compared to everything else, and it also isn't threadsafe when retrieving with write access.
antoniov marked this conversation as resolved
Antonio Vazquez added 2 commits 2023-10-31 18:00:20 +01:00
Hans Goudey reviewed 2023-10-31 18:05:32 +01:00
@ -951,0 +1026,4 @@
if (mode == NormalizeMode::THICKNESS) {
bke::curves::fill_points<float>(points_by_curve, selected_curves, radius, radii);
}
if (mode == NormalizeMode::OPACITY) {
Member

else if, or even better switch (mode) so that adding a mode without changing this gives a compilation error

`else if`, or even better `switch (mode)` so that adding a mode without changing this gives a compilation error
antoniov marked this conversation as resolved
Antonio Vazquez added 1 commit 2023-10-31 18:53:58 +01:00
Antonio Vazquez added 1 commit 2023-10-31 18:59:40 +01:00
78a4427ce6 GPv3: Remove default case
Now this is not required
Hans Goudey requested changes 2023-10-31 19:02:43 +01:00
@ -951,0 +961,4 @@
OPACITY,
};
static const EnumPropertyItem prop_normalize_modes[] = {
Member

This can be defined inside of GREASE_PENCIL_OT_stroke_normalize

This can be defined inside of `GREASE_PENCIL_OT_stroke_normalize`
antoniov marked this conversation as resolved
@ -951,0 +1020,4 @@
}
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
MutableSpan<float> radii = drawing.radii_for_write();
Member

Retrieve the necessary attribute in the call to fill_points.

Getting an attribute with write access is potentially expensive. It's important to avoid it when possible.

Retrieve the necessary attribute in the call to `fill_points`. Getting an attribute with write access is potentially expensive. It's important to avoid it when possible.
antoniov marked this conversation as resolved
Antonio Vazquez added 1 commit 2023-11-01 10:45:39 +01:00
6d749d8dee GPv3: More cleanup to make it faster
* Moved the enum inside operator definition.
* Mutable span is only get if needed..
Antonio Vazquez added 1 commit 2023-11-01 10:47:06 +01:00
Antonio Vazquez added 1 commit 2023-11-01 12:10:43 +01:00
7f9854dd41 GPv3: Split Normalize op in two operators
* GREASE_PENCIL_OT_set_opacity
* GREASE_PENCIL_OT_set_thickness
Antonio Vazquez added 1 commit 2023-11-01 16:15:38 +01:00
First-time contributor

maybe changing the PR title to 'uniform' is also a good direction to uniform our heart

maybe changing the PR title to 'uniform' is also a good direction to uniform our heart
Antonio Vazquez changed title from GPv3: Normalize Stroke operator to GPv3: Set Uniform operator for Thickness and Opacity 2023-11-01 19:41:34 +01:00
Antonio Vazquez added 2 commits 2023-11-02 17:42:54 +01:00
Matias Mendiola approved these changes 2023-11-06 17:45:06 +01:00
Hans Goudey reviewed 2023-11-07 09:15:52 +01:00
@ -960,0 +1014,4 @@
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
ot->prop = RNA_def_float(
Member

Seems that this should be exposed as "Thickness" and then divided by 2 before it's assigned to the points.

Seems that this should be exposed as "Thickness" and then divided by 2 before it's assigned to the points.
Author
Member

I'm not sure about that. The name "Radius" is the same name used in Blender for the brush size. If we use "Thickness" as a name, we are breaking the thickness logic of the Drawing. Actually, the thickness is the result of applying the radius.

@mendio What do you think here?

I'm not sure about that. The name "Radius" is the same name used in Blender for the brush size. If we use "Thickness" as a name, we are breaking the thickness logic of the Drawing. Actually, the thickness is the result of applying the radius. @mendio What do you think here?
Member

The thickness is twice the radius. And the operator is called "Set Thickness"

The thickness is twice the radius. And the operator is called "Set Thickness"
Author
Member

Yes, agree. What I mean is, if we use here Thickness then maybe we need change also Radius in the Draw operator, because the "thickness" of the stroke in DRaw mode is set using "radius" parameter.

My concern is to be sure we keep consistency, so I will wait, before change the name, for @mendio because he has been working all these years to keep consistency, so his opinion is important here. If all agree I can change it easily.

Yes, agree. What I mean is, if we use here Thickness then maybe we need change also Radius in the Draw operator, because the "thickness" of the stroke in DRaw mode is set using "radius" parameter. My concern is to be sure we keep consistency, so I will wait, before change the name, for @mendio because he has been working all these years to keep consistency, so his opinion is important here. If all agree I can change it easily.

For the UI we use Radius and Strength names only in brush settings, once applied, it becomes Stroke Thickness and Stroke Opacity. So yes, Thickness fot the parameter is correct in this case because we are affecting an already existing stroke.

For the UI we use Radius and Strength names only in brush settings, once applied, it becomes Stroke Thickness and Stroke Opacity. So yes, Thickness fot the parameter is correct in this case because we are affecting an already existing stroke.
Author
Member

I have talked with @mendio and we agree to use Thickness instead of Radius.

I have talked with @mendio and we agree to use Thickness instead of Radius.
antoniov marked this conversation as resolved
Antonio Vazquez added 2 commits 2023-11-07 15:57:43 +01:00
4336411c84 GPv3: Rename Radius to Thickness
Also divide Thickness by 2 because radius is half thickness.
Hans Goudey approved these changes 2023-11-08 09:11:05 +01:00
@ -26,6 +27,9 @@
#include "ED_grease_pencil.hh"
#include "ED_screen.hh"
#include "UI_interface.hh"
Member

Looks like these two UI includes are unnecessary

Looks like these two UI includes are unnecessary
Author
Member

Correct! I would love for the Microsoft compiler to warn about these things as a warning, but it doesn't.

Correct! I would love for the Microsoft compiler to warn about these things as a warning, but it doesn't.
antoniov marked this conversation as resolved
Antonio Vazquez added 1 commit 2023-11-08 12:00:45 +01:00
Antonio Vazquez added 1 commit 2023-11-08 16:13:09 +01:00
79a1ace8d5 Merge branch 'main' into GPv3_normalize
Conflicts:
	source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc
Antonio Vazquez added 1 commit 2023-11-08 16:16:51 +01:00
7172784cd1 Merge branch 'main' into GPv3_normalize
Conflicts:
	source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc
Antonio Vazquez merged commit 405ad22429 into main 2023-11-08 16:19:10 +01:00
Antonio Vazquez deleted branch GPv3_normalize 2023-11-08 16:19:12 +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
6 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#114006
No description provided.