Sculpt: Migrate Box Hide to common gesture code #119040

Merged
Hans Goudey merged 7 commits from Sean-Kim/blender:migrate-hide-show into main 2024-03-06 05:25:55 +01:00
Member

This PR migrates the existing PAINT_OT_hide_show operator to the previously extracted gesture namespace performed in #118881

Changes

The current operator has support for choosing whether the hide / show action is performed on every vertex inside or outside the selection area. This has been added to the common gesture functionality too, but no common operator property has been exposed for it for the other Lasso / Box tools to use.

Previously, the PAINT_OT_hide_show operator handled three main cases (exposed as the VisArea enum):

  • All vertices of a mesh - ALL
  • All masked vertices of a mesh above a hardcoded threshold of 0.5 - MASKED
  • Either all selected vertices selected by the box tool (INSIDE) or all unselected vertices (OUTSIDE)

The existing code has been refactored to handle the first two options separately from the selection usecase to more clearly delineate a separation of concerns.

Open Questions

  • Is it useful / necessary for this tool to support the Front Faces Only setting that other box tools support?
  • Should the inside / outside option be exposed across all Box tools without requiring the user to edit the operator via the keymap?

Testing

  • Manual testing of the Box Hide operator with both INSIDE and OUTSIDE functionality

Prerequisite for #80390

This PR migrates the existing `PAINT_OT_hide_show` operator to the previously extracted `gesture` namespace performed in #118881 ## Changes The current operator has support for choosing whether the hide / show action is performed on every vertex inside or outside the selection area. This has been added to the common gesture functionality too, but no common operator property has been exposed for it for the other Lasso / Box tools to use. Previously, the `PAINT_OT_hide_show` operator handled three main cases (exposed as the `VisArea` `enum`): * All vertices of a mesh - `ALL` * All masked vertices of a mesh above a hardcoded threshold of `0.5` - `MASKED` * Either all *selected* vertices selected by the box tool (`INSIDE`) or all *unselected* vertices (`OUTSIDE`) The existing code has been refactored to handle the first two options separately from the selection usecase to more clearly delineate a separation of concerns. ## Open Questions * Is it useful / necessary for this tool to support the `Front Faces Only` setting that other box tools support? * Should the inside / outside option be exposed across all Box tools without requiring the user to edit the operator via the keymap? ## Testing * Manual testing of the `Box Hide` operator with both `INSIDE` and `OUTSIDE` functionality Prerequisite for #80390
Sean Kim added 1 commit 2024-03-04 03:33:22 +01:00
e827aca772 Sculpt: Migrate Box Hide to common gesture code
* Switch Box Hide tool to use extracted gesture functionality
* Adds support for inside/outside selection into core gesture code
* Separate object-wide functionality from selection-based functionality
Sean Kim requested review from Hans Goudey 2024-03-04 03:34:35 +01:00
Hans Goudey reviewed 2024-03-04 19:19:22 +01:00
Hans Goudey left a comment
Member

I like where you're heading here, but I'm finding the code a bit more confusing now. I left some comments inline with ideas.

I like where you're heading here, but I'm finding the code a bit more confusing now. I left some comments inline with ideas.
@ -277,1 +267,4 @@
static void partialvis_update_mesh(gesture::GestureData *gesture_data)
{
HideShowOperation *operation = (HideShowOperation *)gesture_data->operation;
Member

Use C++ reinterpret_cast rather than C-style casts

Use C++ `reinterpret_cast` rather than C-style casts
Sean-Kim marked this conversation as resolved
@ -594,2 +666,3 @@
switch (pbvh_type) {
Vector<PBVHNode *> nodes = bke::pbvh::search_gather(pbvh,
[&](PBVHNode & /* node */) { return true; });
Member

You can just pas {} to gather all nodes.

You can just pas `{}` to gather all nodes.
Sean-Kim marked this conversation as resolved
@ -650,9 +733,12 @@ void PAINT_OT_hide_show(wmOperatorType *ot)
ot->idname = "PAINT_OT_hide_show";
ot->description = "Hide/show some vertices";
/* Because this operator handles both interactive viewport functionality and predefined menu
Member

Because this operator handles both interactive viewport functionality and predefined menu actions

This seems to make the code quite a bit more complicated honestly. It's sort of hard to understand the diff and the code when it mixes these things. Especially with all the switches with defaults now, it's hard to tell where everything is handled at a glance. What do you think about splitting this into more operators? Something like:

  • PAINT_OT_hide_masked
  • PAINT_OT_hide_all
>Because this operator handles both interactive viewport functionality and predefined menu actions This seems to make the code quite a bit more complicated honestly. It's sort of hard to understand the diff and the code when it mixes these things. Especially with all the switches with defaults now, it's hard to tell where everything is handled at a glance. What do you think about splitting this into more operators? Something like: - `PAINT_OT_hide_masked` - `PAINT_OT_hide_all`
Author
Member

More operators was my first idea, but I was worried if doing so would be a breaking change. I’ll work on splitting them up.

I can see it being confusing too because of the function naming, I’ll spend some time thinking about that as well.

More operators was my first idea, but I was worried if doing so would be a breaking change. I’ll work on splitting them up. I can see it being confusing too because of the function naming, I’ll spend some time thinking about that as well.
Sean-Kim marked this conversation as resolved
@ -1671,6 +1671,11 @@ enum eShapeType {
SCULPT_GESTURE_SHAPE_LINE,
};
enum eSelectionType {
Member

enum eSelectionType -> enum class SelectionType

And it can have Inside and Outside as names. Combined with other changes I suggested, this could completely replace VisArea too.

`enum eSelectionType` -> `enum class SelectionType` And it can have `Inside` and `Outside` as names. Combined with other changes I suggested, this could completely replace `VisArea` too.
Sean-Kim marked this conversation as resolved
Sean Kim added 1 commit 2024-03-05 00:30:21 +01:00
ca40008b9d Address PR feedback
* Use reinterpret_cast
* Split existing operator into two new operators
* Fix call to search_gather
* Use enum class
Hans Goudey requested changes 2024-03-05 02:59:47 +01:00
Dismissed
Hans Goudey left a comment
Member

Really nice! Just a few small comments.

Really nice! Just a few small comments.
@ -276,0 +268,4 @@
vert_hide_update(*object, nodes, [&](const Span<int> verts, MutableSpan<bool> hide) {
for (const int i : verts.index_range()) {
if (gesture::is_affected(gesture_data, positions[verts[i]], normals[verts[i]]))
hide[i] = value;
Member

Missing curly braces here. We use them around all if statements

Missing curly braces here. We use them around all if statements
Sean-Kim marked this conversation as resolved
@ -531,3 +518,1 @@
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
BoundBox bb;
ED_view3d_clipping_calc(&bb, clip_planes, vc.region, vc.obact, rect);
partialvis_update_bmesh_nodes(ob, nodes, action, {});
Member

Rather than checking whether should_update is empty in the callback, maybe it's cleaner to pass [](const BMVert &vert) { return true; } here. That way the price isn't payed for other tests where it isn't necessary

Rather than checking whether `should_update` is empty in the callback, maybe it's cleaner to pass `[](const BMVert &vert) { return true; }` here. That way the price isn't payed for other tests where it isn't necessary
Sean-Kim marked this conversation as resolved
@ -1671,6 +1671,11 @@ enum eShapeType {
SCULPT_GESTURE_SHAPE_LINE,
};
enum class eSelectionType {
Member
enum class eSelectionType {
  Inside = 0,
  Outside = 1,
};

Sorry this is a bit nitpicky, the e is something we want to move away from though, and they sort of just look better without all caps ;) I'll commit more cleanups to move in that directions in more of the surrounding code later.

``` enum class eSelectionType { Inside = 0, Outside = 1, }; ``` Sorry this is a bit nitpicky, the `e` is something we want to move away from though, and they sort of just look better without all caps ;) I'll commit more cleanups to move in that directions in more of the surrounding code later.
Author
Member

Oh, was unaware of the change in standards - I think the handbook style guide is a bit out of date with those regards then

Oh, was unaware of the change in standards - I think the handbook style guide is a bit out of date with those regards then
Sean-Kim marked this conversation as resolved
Sean Kim added 1 commit 2024-03-05 05:09:22 +01:00
Sean Kim added 1 commit 2024-03-05 05:13:29 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
1abf8b3ca5
Add missed optimization for functionref
Sean Kim requested review from Hans Goudey 2024-03-05 05:22:29 +01:00
Hans Goudey approved these changes 2024-03-05 13:51:20 +01:00
Dismissed
Hans Goudey approved these changes 2024-03-05 13:53:01 +01:00
Hans Goudey left a comment
Member

What do you think about "hide_show_all" vs "hide_show_global"? I think it's a reasonable idea, but I didn't get used to "global" yet. It just has so many other connotations. "All" might be clear enough here.

Other than that, this looks good to go.

What do you think about "hide_show_all" vs "hide_show_global"? I think it's a reasonable idea, but I didn't get used to "global" yet. It just has so many other connotations. "All" might be clear enough here. Other than that, this looks good to go.
Member

@blender-bot build

@blender-bot build
Author
Member

What do you think about "hide_show_all" vs "hide_show_global"? I think it's a reasonable idea, but I didn't get use to "global" yet. It just has so many other connotations. "All" might be clear enough here.

Other than that, this looks good to go.

I was debating the same naming myself, I think all is fine, global does imply that it would apply to multiple objects.

> What do you think about "hide_show_all" vs "hide_show_global"? I think it's a reasonable idea, but I didn't get use to "global" yet. It just has so many other connotations. "All" might be clear enough here. > > Other than that, this looks good to go. I was debating the same naming myself, I think `all` is fine, `global` does imply that it would apply to multiple objects.
Sean Kim added 3 commits 2024-03-06 01:12:23 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
54803c0523
Add missed file
Author
Member

Renamed the files and merged from main. I ran the tests locally and they should be passing on buildbot now, just get the usual expected failures due to running in developer mode. PR should be good to go now @HooglyBoogly

Renamed the files and merged from main. I ran the tests locally and they should be passing on buildbot now, just get the usual expected failures due to running in developer mode. PR should be good to go now @HooglyBoogly
Member

@blender-bot build

@blender-bot build
Member

This test is failing in main too, I'll commit this now.

This test is failing in main too, I'll commit this now.
Hans Goudey merged commit 705964d7bb into main 2024-03-06 05:25:55 +01:00
Sean Kim deleted branch migrate-hide-show 2024-03-12 15:50:39 +01:00
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
2 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#119040
No description provided.