GPv3: Invert weight operator #126275

Merged
Pratik Borhade merged 3 commits from PratikPB2123/blender:gpv3-weight-invert into main 2024-08-14 08:55:41 +02:00
Member

Port gp legacy "invert weight" operator.

Port gp legacy "invert weight" operator.
Pratik Borhade added 1 commit 2024-08-13 12:40:57 +02:00
Port gp legacy "invert weight" operator.
Pratik Borhade requested review from Falk David 2024-08-13 12:41:49 +02:00
Pratik Borhade added the
Module
Grease Pencil
label 2024-08-13 12:41:57 +02:00
Pratik Borhade added this to the Grease Pencil project 2024-08-13 12:42:06 +02:00
Pratik Borhade added 1 commit 2024-08-13 13:04:55 +02:00
Falk David requested changes 2024-08-13 13:31:21 +02:00
Dismissed
Falk David left a comment
Member

Thanks for working on this! Added some comments

Thanks for working on this! Added some comments
@ -360,0 +379,4 @@
/* Active vgroup index of drawing. */
const int drawing_vgroup_index = BLI_findstringindex(
&curves.vertex_group_names, active_defgroup->name, offsetof(bDeformGroup, name));
Member

Should assert here that drawing_vgroup_index != -1.

Should assert here that `drawing_vgroup_index != -1`.
filedescriptor marked this conversation as resolved
@ -360,0 +387,4 @@
return;
}
for (int i : weights.index_range()) {
Member

const int i

`const int i`
filedescriptor marked this conversation as resolved
Pratik Borhade added 1 commit 2024-08-13 13:43:20 +02:00
Add assert and const
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
03d0f755db
Lukas Tönne approved these changes 2024-08-13 15:22:30 +02:00
Falk David approved these changes 2024-08-13 15:26:06 +02:00
Author
Member

@blender-bot build

@blender-bot build
Pratik Borhade merged commit 7bfdc6dfea into main 2024-08-14 08:55:41 +02:00
Pratik Borhade deleted branch gpv3-weight-invert 2024-08-14 08:55:45 +02:00
Author
Member

Thanks for reviewing :)

Thanks for reviewing :)
Sietse Brouwer reviewed 2024-08-14 10:57:00 +02:00
Sietse Brouwer left a comment
Member

I know this PR is already merged, but a 'review after the facts' was the easiest way for me to address a few things 😉

I know this PR is already merged, but a 'review after the facts' was the easiest way for me to address a few things 😉
@ -360,0 +371,4 @@
const bDeformGroup *active_defgroup = static_cast<const bDeformGroup *>(
BLI_findlink(BKE_object_defgroup_list(object), active_index));
Member

There should be a check-and-report here when the active vertex group is locked.
(active_defgroup->flag & DG_LOCK_WEIGHT)

There should be a check-and-report here when the active vertex group is locked. `(active_defgroup->flag & DG_LOCK_WEIGHT)`
@ -360,0 +379,4 @@
/* Active vgroup index of drawing. */
const int drawing_vgroup_index = BLI_findstringindex(
&curves.vertex_group_names, active_defgroup->name, offsetof(bDeformGroup, name));
BLI_assert(drawing_vgroup_index != -1);
Member

There is no guarantee the active vertex group exists in the drawing. Instead of asserting, it should just skip the drawing (with a return) when the vertex group isn't used (drawing_vgroup_index == -1).

There is no guarantee the active vertex group exists in the drawing. Instead of asserting, it should just skip the drawing (with a `return`) when the vertex group isn't used (`drawing_vgroup_index == -1`).
@ -360,0 +389,4 @@
}
for (const int i : weights.index_range()) {
const float invert_weight = 1 - weights[i];
Member

Nitpick, but the style-guided way would be 1.0f.

Nitpick, but the style-guided way would be `1.0f`.
@ -360,0 +408,4 @@
/* api callbacks */
ot->exec = grease_pencil_weight_invert_exec;
ot->poll = grease_pencil_weight_painting_poll;
Member

It would be nicer to have a poll here that checks the existence of any vertex group, e.g. !BLI_listbase_is_empty(BKE_object_defgroup_list(object)). Then the menu item will be properly greyed out when there is no vertex group in the object.

It would be nicer to have a poll here that checks the existence of any vertex group, e.g. `!BLI_listbase_is_empty(BKE_object_defgroup_list(object))`. Then the menu item will be properly greyed out when there is no vertex group in the object.
Author
Member

Thanks @SietseB . I'll make a new PR then to address these points :)

Thanks @SietseB . I'll make a new PR then to address these points :)
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#126275
No description provided.