Sculpt: Add polyline hide operator #119483

Merged
Hans Goudey merged 17 commits from Sean-Kim/blender:polyline-hide into main 2024-04-29 14:04:28 +02:00
Member

This PR adds a polyline hide operator for sculpt mode as well as the necessary generic callback code to allow using this gesture in other selection tools.

polyline-hide.gif

Added Features

  • Polyline Hide operator
  • WM_gesture_polyline_* callback functions for usage in other operators
  • Status bar text while using the polyline modal
  • Common Gesture Polyline keymap for usage with the modal

Known Limitations

  • Unlike the Box Hide and Lasso Hide operators, the Polyline Hide operator does not provide a simple shortcut to click and show all hidden elements in a mesh. This is because the existing operators operate on a click-drag action while the new operator is invoked by just a click.

Design Task: #119353

This PR adds a polyline hide operator for sculpt mode as well as the necessary generic callback code to allow using this gesture in other selection tools. ![polyline-hide.gif](/attachments/1987fd19-4f96-43d0-ba53-81a80f30fa6e) ## Added Features * *Polyline Hide* operator * `WM_gesture_polyline_*` callback functions for usage in other operators * Status bar text while using the polyline modal * Common *Gesture Polyline* keymap for usage with the modal ## Known Limitations * Unlike the *Box Hide* and *Lasso Hide* operators, the *Polyline Hide* operator does not provide a simple shortcut to click and show all hidden elements in a mesh. This is because the existing operators operate on a click-drag action while the new operator is invoked by just a click. Design Task: #119353
Sean Kim added 2 commits 2024-03-14 19:18:02 +01:00
Sean Kim reviewed 2024-03-14 19:20:02 +01:00
@ -96,3 +96,3 @@
}
std::unique_ptr<GestureData> init_from_lasso(bContext *C, wmOperator *op)
static std::unique_ptr<GestureData> init_from_lasso(bContext *C,
Author
Member

I'm unsure about the naming here and for a term that would encompass both types. Originally I was thinking of "border" but that term is already currently used to specifically mean box selection in other areas of Blender.

I'm unsure about the naming here and for a term that would encompass both types. Originally I was thinking of "border" but that term is already currently used to specifically mean box selection in other areas of Blender.
Sean Kim reviewed 2024-03-14 19:27:06 +01:00
@ -83,0 +83,4 @@
else if (ELEM(type, WM_GESTURE_POLYLINE)) {
gesture->points_alloc = 64;
short *border = static_cast<short int *>(
MEM_mallocN(sizeof(short[2]) * gesture->points_alloc, "polyline points"));
Author
Member

I'm unsure of the data structure here, I was also considering using

struct PolylineData
{
   short current_pos[2];
   short *points;
}

To make the code intent more explicit, but opted instead to always store the current position in the last spot of the current array.

I'm unsure of the data structure here, I was also considering using ``` struct PolylineData { short current_pos[2]; short *points; } ``` To make the code intent more explicit, but opted instead to always store the current position in the last spot of the current array.
Sean Kim requested review from Hans Goudey 2024-03-14 19:28:59 +01:00
Sean Kim requested review from Daniel Bystedt 2024-03-14 19:29:43 +01:00
Hans Goudey reviewed 2024-03-14 19:39:28 +01:00
Hans Goudey left a comment
Member

Does the sculpt gesture system have to know that the polyline shape exists? Seems that the existing lasso code could be used directly by the new operators without changing anything.

Does the sculpt gesture system have to know that the polyline shape exists? Seems that the existing lasso code could be used directly by the new operators without changing anything.
@ -692,0 +911,4 @@
ot->name = "Polyline Gesture";
ot->idname = "WM_OT_polyline_gesture";
ot->description = "Outline a selection area with each mouse click.";
Member

The period is added automatically here

The period is added automatically here
Sean-Kim marked this conversation as resolved
Hans Goudey reviewed 2024-03-14 19:42:12 +01:00
Hans Goudey left a comment
Member
No description provided.
Author
Member

Does the sculpt gesture system have to know that the polyline shape exists? Seems that the existing lasso code could be used directly by the new operators without changing anything.

@HooglyBoogly That's a fair point. I thought it would be best to be explicit about them being different types for future maintenance since

static int hide_show_gesture_polyline_exec(bContext *C, wmOperator *op)
{
  std::unique_ptr<gesture::GestureData> gesture_data = gesture::init_from_lasso(C, op);
  if (!gesture_data) {
    return OPERATOR_CANCELLED;
  }
  hide_show_init_properties(*C, *gesture_data, *op);
  gesture::apply(*C, *gesture_data, *op);
  return OPERATOR_FINISHED;
}

would read to me as an error at init_from_lasso if I was more unfamiliar with the code. In the end though, I can't think of any particular usecase where the lasso and polyline code actually need to diverge within sculpt_gesture.cc

> Does the sculpt gesture system have to know that the polyline shape exists? Seems that the existing lasso code could be used directly by the new operators without changing anything. @HooglyBoogly That's a fair point. I thought it would be best to be explicit about them being different types for future maintenance since ``` static int hide_show_gesture_polyline_exec(bContext *C, wmOperator *op) { std::unique_ptr<gesture::GestureData> gesture_data = gesture::init_from_lasso(C, op); if (!gesture_data) { return OPERATOR_CANCELLED; } hide_show_init_properties(*C, *gesture_data, *op); gesture::apply(*C, *gesture_data, *op); return OPERATOR_FINISHED; } ``` would read to me as an error at `init_from_lasso` if I was more unfamiliar with the code. In the end though, I can't think of any particular usecase where the lasso and polyline code actually need to diverge within `sculpt_gesture.cc`
Member

would read to me as an error at init_from_lasso if I was more unfamiliar with the code. In the end though, I can't think of any particular usecase where the lasso and polyline code actually need to diverge within sculpt_gesture.cc

Right, I agree. I would have had the same instinct to make things explicit like that, but I don't think it helps us in practice and will probably end up with unnecessary boilerplate in a lot of places.

> would read to me as an error at `init_from_lasso` if I was more unfamiliar with the code. In the end though, I can't think of any particular usecase where the lasso and polyline code actually need to diverge within `sculpt_gesture.cc` Right, I agree. I would have had the same instinct to make things explicit like that, but I don't think it helps us in practice and will probably end up with unnecessary boilerplate in a lot of places.
Sean Kim requested review from Hans Goudey 2024-03-14 20:20:28 +01:00
Author
Member

No idea what's going on with this issue - noticed it somehow removed you from the reviewer list...?

No idea what's going on with this issue - noticed it somehow removed you from the reviewer list...?
Author
Member

Right, I agree. I would have had the same instinct to make things explicit like that, but I don't think it helps us in practice and will probably end up with unnecessary boilerplate in a lot of places.

Sounds good, I'll make the change here and consider renaming or adding other comments in sculpt_gesture.cc in a later PR to be more indicative of future usage.

> Right, I agree. I would have had the same instinct to make things explicit like that, but I don't think it helps us in practice and will probably end up with unnecessary boilerplate in a lot of places. Sounds good, I'll make the change here and consider renaming or adding other comments in `sculpt_gesture.cc` in a later PR to be more indicative of future usage.
First-time contributor

Just to make sure, to run the tool, Enter also works, right? the gif only shows the "click on first point" method

Just to make sure, to run the tool, `Enter` also works, right? the gif only shows the "click on first point" method
Author
Member

Just to make sure, to run the tool, Enter also works, right? the gif only shows the "click on first point" method

@ThinkingPolygons - Yes, pressing enter will also submit the shape - I didn't add a GIF for that.

> Just to make sure, to run the tool, `Enter` also works, right? the gif only shows the "click on first point" method @ThinkingPolygons - Yes, pressing enter will also submit the shape - I didn't add a GIF for that.
Sean Kim added 2 commits 2024-03-14 23:49:02 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 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
7caa55393f
Remove ShapeType::Polyline
Member

@Sergey @HooglyBoogly could anytone of you get @buildbot to make a build of this PR so that I can test from a users POV?

@Sergey @HooglyBoogly could anytone of you get @buildbot to make a build of this PR so that I can test from a users POV?
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119483) when ready.
Member

I suspect something is wrong with the current build
https://builder.blender.org/download/patch/PR119483

When using lasso hide or polyline hide, nothing happens. I activate the tool in the toolbar, press left mouse down and drag on the screen over a spher. Nothing happens. Box hide works as intended.

I suspect something is wrong with the current build https://builder.blender.org/download/patch/PR119483 When using lasso hide or polyline hide, nothing happens. I activate the tool in the toolbar, press left mouse down and drag on the screen over a spher. Nothing happens. Box hide works as intended.
First-time contributor

@DanielBystedt the polyline tool is working fine, the lasso tool is not
also, the polyline works by clicking to add points, not click and drag

@DanielBystedt the polyline tool is working fine, the lasso tool is not also, the polyline works by clicking to add points, not click and drag
Sean Kim added 1 commit 2024-03-19 01:51:06 +01:00
Author
Member

I fixed the issue @ThinkingPolygons brought up, made a mistake with the keymap entries, so Lasso Hide should be working again. I confirmed that Polyline Hide is also working still in this build. Since I don't have permissions to kick off a new package build, could you submit another request @HooglyBoogly ?

I fixed the issue @ThinkingPolygons brought up, made a mistake with the keymap entries, so Lasso Hide should be working again. I confirmed that Polyline Hide is also working still in this build. Since I don't have permissions to kick off a new package build, could you submit another request @HooglyBoogly ?
Sean Kim closed this pull request 2024-03-19 01:53:17 +01:00
Sean Kim reopened this pull request 2024-03-19 01:53:25 +01:00
Author
Member

Clicked the wrong button and accidentially closed it...

Clicked the wrong button and accidentially closed it...
Sean Kim added 1 commit 2024-03-19 03:42:38 +01:00
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 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
47a7e05bf8
make format and icon change
Sean Kim changed title from WIP: Sculpt: Add polyline hide operator to Sculpt: Add polyline hide operator 2024-03-19 03:42:46 +01:00
Author
Member

Updated and removed WIP. I've been working on making an icon for this separately, but the process is taking a bit longer than I'd like so I changed the icon here to just use the "None" placeholder.

Updated and removed WIP. I've been working on making an icon for this separately, but the process is taking a bit longer than I'd like so I changed the icon here to just use the "None" placeholder.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119483) when ready.
Sean Kim added 1 commit 2024-03-19 18:36:11 +01:00
Sean Kim added 1 commit 2024-03-19 18:49:32 +01:00
Member

In terms of functionality the polyline hide perfectly. Thanks for adding hotkey hints in the lower info bar! The tool icon is currently missing, but once there is an icon I am ready to approve the commit.

Let me know if the icon will be added in another PR for whatever reason.

In terms of functionality the polyline hide perfectly. Thanks for adding hotkey hints in the lower info bar! The tool icon is currently missing, but once there is an icon I am ready to approve the commit. Let me know if the icon will be added in another PR for whatever reason.
Author
Member

In terms of functionality the polyline hide perfectly. Thanks for adding hotkey hints in the lower info bar! The tool icon is currently missing, but once there is an icon I am ready to approve the commit.

Let me know if the icon will be added in another PR for whatever reason.

@DanielBystedt - I was planning on adding it in a future PR since we're still in alpha for 4.2 until June 5th. If you think we need one before landing this, would a reasonable compromise here be adding it to the Sculpt menu only and changing the toolbar when the icon is done?

Edit: Ignore this, I finished the icon file recently so at this point I think this question is moot.

> In terms of functionality the polyline hide perfectly. Thanks for adding hotkey hints in the lower info bar! The tool icon is currently missing, but once there is an icon I am ready to approve the commit. > > Let me know if the icon will be added in another PR for whatever reason. ~~@DanielBystedt - I was planning on adding it in a future PR since we're still in alpha for 4.2 until June 5th. If you think we need one before landing this, would a reasonable compromise here be adding it to the `Sculpt` menu only and changing the toolbar when the icon is done?~~ Edit: Ignore this, I finished the icon file recently so at this point I think this question is moot.
Member

Just a note that @JulienKaspar and @pablovazquez left some notes on the icon here
blender/blender-assets#2

Once the the icon comments are fixed I am ready to approve the PR

Just a note that @JulienKaspar and @pablovazquez left some notes on the icon here https://projects.blender.org/blender/blender-assets/pulls/2 Once the the icon comments are fixed I am ready to approve the PR
Sean Kim added 4 commits 2024-03-29 01:18:58 +01:00
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
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
b4e45df791
Adjust files after merge
Member

@blender-bot package

@blender-bot package
Member

Only blender organization members with write access can start builds. See documentation for details.

Only blender organization members with write access can start builds. See [documentation](https://projects.blender.org/infrastructure/blender-bot/src/branch/main/README.md) for details.
Member

@HooglyBoogly can you make a trigger a build with blender-bot? I just want to check the build before approving the commit

@HooglyBoogly can you make a trigger a build with blender-bot? I just want to check the build before approving the commit
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119483) when ready.
First-time contributor

any news on this?

any news on this?
Author
Member

any news on this?

@ThinkingPolygons - The icon PR was recently updated. Once that gets approved, I'll update this PR with the latest changes and then the only thing remaining should be the functional review from Hans and any changes that come from that

> any news on this? @ThinkingPolygons - The icon PR was recently updated. Once that gets approved, I'll update this PR with the latest changes and then the only thing remaining should be the functional review from Hans and any changes that come from that
Sean Kim added 1 commit 2024-04-11 00:52:42 +02:00
Hans Goudey requested changes 2024-04-15 16:58:12 +02:00
Dismissed
Hans Goudey left a comment
Member

I think there's an issue with the right click select keymap, it works quite differently-- I have to hold down right click for the whole operation and add points with LMB.

I think there's an issue with the right click select keymap, it works quite differently-- I have to hold down right click for the whole operation and add points with LMB.
@ -1664,0 +1664,4 @@
/* In the context of a sculpt gesture, both lasso and polyline modal
* operators are handled as the same general shape.
* TODO: Rename to polygon? */
Member

I think the current name is fine, at least it's not worth adding a TODO here

I think the current name is fine, at least it's not worth adding a TODO here
Sean-Kim marked this conversation as resolved
@ -697,0 +809,4 @@
break;
}
const float cur[2] = {float(cur_x), float(cur_y)};
Member

const float2 cur(cur_x, cur_y);
same with orig

`const float2 cur(cur_x, cur_y);` same with `orig`
Sean-Kim marked this conversation as resolved
Sean Kim added 1 commit 2024-04-16 01:52:42 +02:00
Sean Kim added 1 commit 2024-04-16 02:02:07 +02:00
Author
Member

I think there's an issue with the right click select keymap, it works quite differently-- I have to hold down right click for the whole operation and add points with LMB.

Thanks for the feedback - haven't yet addressed this in the most recent commit.

> I think there's an issue with the right click select keymap, it works quite differently-- I have to hold down right click for the whole operation and add points with LMB. Thanks for the feedback - haven't yet addressed this in the most recent commit.
Sean Kim added 1 commit 2024-04-16 17:51:44 +02:00
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
a911660e8d
Fix RCS tool interaction
Sean Kim requested review from Hans Goudey 2024-04-16 17:52:06 +02:00
Author
Member

Updated the keymap so that with RCS enabled, the interactions remain the same (i.e. starting the tool & adding points with LMB and canceling with RMB / ESC)

Updated the keymap so that with RCS enabled, the interactions remain the same (i.e. starting the tool & adding points with LMB and canceling with RMB / ESC)
Hans Goudey approved these changes 2024-04-16 18:11:22 +02:00
Hans Goudey left a comment
Member

Works great! I'll wait for Daniel's approval to commit this.

Works great! I'll wait for Daniel's approval to commit this.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119483) when ready.
Sean Kim added 1 commit 2024-04-17 00:33:22 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 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
f8ac68bfb0
Merge branch 'main' of projects.blender.org:blender/blender into polyline-hide
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119483) when ready.
Daniel Bystedt approved these changes 2024-04-28 09:26:44 +02:00
Daniel Bystedt left a comment
Member

Works great. Thank you for the commit!

Works great. Thank you for the commit!
Hans Goudey merged commit 55fc1066ac into main 2024-04-29 14:04:28 +02:00
Sean Kim deleted branch polyline-hide 2024-04-30 22:43:17 +02: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
5 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#119483
No description provided.