Sculpt Mode: Add exisiting Tools as Menu Operators #102427
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#102427
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
(NOTE) This task is part of the community & sub tasks of the workboard. Anyone is free to pick up this task and contribute. For any questions or needed reviewers, please tag @Sergey @HooglyBoogly and @JulienKaspar.
Previous limitations on using the Adjust Last Operation panel are being lifted, and fixing #99607 is being prioritized.
This will make it possible to add many active tools in the toolbar to the header menus as operators.
This has the following advantages:
Needed Operators
This is based on operators that currently only exist as active tools, or are not properly exposed at all yet.
Many operators are depending on the cursor position. This feature should be used heavily:
da2ba40268
Initially or later on some operators can be combined into a single operator and accordingly renamed.
The first step is to add the existing operations as they are to the menus.
There are also still some open questions for some operators but these can be resolved during testing and review.
Sculpt
Transform Tools
Trim Tools
Project Tools
Fairing
Mesh Filter Tool
ScaleRemove
Mask
Face Sets
Paint
Color Filter Tool
Fill Color(Part of #99769)Other
sculpt.expand
with target data set toColor
)Layout
This is how the operators could be arranged.
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscribers: @JulienKaspar, @JosephEagar
From recent module meeting:
EDIT: This seems to be already implemented with D12255.
Hello, I'd like to work on this please.
I just want to make sure that I understand the requirements of this issue correctly. The main requirement is to add the long list of operators mentioned in the issue description to the sculpting workspace UI, correct?
For example, this is the current state of the
Sculpt
menu on my end.And the issue requires that its updated to be as so:
And the same applies to the other menus:
mask
,face sets
, andpaint
. Correct?Also, I'd like to ask for any hints on where to start on the code/documentation side. I'll be searching on my own, but any hints are greatly appreciated.
@Tarek-Yasser Thanks! Feel free to assign the issue to yourself once you're working on it.
You also understood the description right.
Some of these operators are very straight forward to add and barely need any adjustments in the code. Probably just a
OPTYPE_DEPENDS_ON_CURSOR
flag.Others are more complicated (like the Filters) because of their specific implementation.
The patch doesn't need to include all of the listed operators at once. First working on the low hanging fruits is also fine.
General documentation and help can be found here: https://developer.blender.org/
@JosephEagar can give some technical pointers for this patch specifically.
Thank you for the quick reply. I'll be sure to consult the documentation in case any operator proves to be challenging. I'll also try to submit patches incrementally so things are easier to review.
Quick question: Am I supposed to assign myself or not? The old website (I think) allowed this, but this one isn't allowing me to assign myself.
@Tarek-Yasser You should be able to do assign yourself.
If there are still any issues with the site you can get support at #blender-developers-migration-support on chat.blender ;)
Quick update regarding assigning myself: After asking at
#blender-developers-migration-support
. Brecht informed me that only members of the Blender organization can be assigned to issues (message can be found here).So I guess I'm "unofficialy assigned" for the time being.
Regarding my progress so far. I've been scouring the blender docs and grepping whatever I'm seeing in the UI for any hint where the code for the menus might be to no avail (yet). The documentation for this module seems a bit scarce so I'll try digging deeper.
EDIT: I think I found the UI code. It seems to be at
release/scripts/startup/bl_ui/space_view3d.py
Taking advantage of this revisions you can include lasso hide, is an useful tool
@Dethknight I didn't include any non existing operators in this task.
But missing gesture operators are very welcome too, as part of #80390.
A few updates here:
For Move, Rotate, and Scale, I grepped through the code and inspected the UI for a while and found this section:
efabe81c91/release/scripts/startup/bl_ui/space_view3d.py (L1034-L1036)
It seems to be transforming the whole object without doing anything special, is this the intended behaviour?
Toggle Visibility
,Fair Positions
, andFair Tangency
troubles.Old long question
Regarding
Toggle Visibility
,Fair Positions
, andFair Tangency
. I tried copyinglayout.operator(...)
like the previous point but it didn't work. Each time the sculpt menu is opened, I get the following error:Here are the sections where I think the operators are defined:
-
efabe81c91/source/blender/editors/sculpt_paint/sculpt_face_set.cc (L787-L794)
-
efabe81c91/source/blender/editors/sculpt_paint/sculpt_face_set.cc (L972-L992)
-
efabe81c91/source/blender/editors/sculpt_paint/sculpt_face_set.cc (L1058-L1097)
-
efabe81c91/source/blender/editors/sculpt_paint/sculpt_face_set.cc (L1465-L1485)
I tried the following values
operator
:-
sculpt.face_sets_change_visibility
-
sculpt.face_sets_edit
(I think this has a propertymode
to use withFAIR_POSITIONS
andFAIR_TANGENCY
?)From what I could scrape together (this part seems to not have much documentation):
SCULPT_OT_face_sets_change_visibility
defines an operator (OT?), which is calledface_sets_change_visibility
and fallssculpt
. So it should be called like so:Any guidance/documentation would be much appreciated.
Update: After watching this part. I think these functions are not yet exposed in the Python API?. @JulienKaspar is this what you meant when you said that "some operators are straightforward and others are more complicated"?
So, trying out:
sculpt.face_set_change_visibility
sculpt.face_set_edit
With "set" instead of "sets" seems to work? I'm so confused...
I can't seem to find "Box/Lasso Add". I could only find "Box/Lasso Trim" and "Line Project" in
space_toolsystem_toolbar.py
. Do they have another name?Some notes for new contributors or blender newbies:
make lite
. I'm not sure if this would be suitable for working on every part of the code, but it works for me.@JulienKaspar
I checked out the rest of the operations and I have some notes/questions. I know you're an artist so you might be not quite familiar with the nitty gritty details of the code, feel free to refer me to someone else.
Which operators should get the flag
OPTYPE_DEPENDS_ON_CURSOR
, or how can I determine that myself? I'm quite inexperienced with sculpting so things aren't quite obvious yet.For menu entries that can be disabled depending on the existence of something, is there a consistent way to query the information I need? For example:
Relax Face Set Boundaries (Grayed out if no Face Sets?)
.I did check out the Python API documentation, but it didn't contain the information I needed. I also tried compiling the
bpy
module and importing it, but it appears there's only data at runtime (inside blender)Currently, the only way for me to inspect Python code at runtime is to add print statements, compile, run, and repeat. Is there a better way to do this? (attaching a debugger, etc...)
For the
Paint
menu, I can't seem to find the typesInvert
,Levels
, andExpand Color by Topology
.Also for the
Paint
menu, I think theBlur
type is instead calledSmooth
, is this correct?@Tarek-Yasser True. Technical information is so far still missing from these tasks.
Refer to @JosephEagar here or on blender.chat for more info.
OPTYPE_DEPENDS_ON_CURSOR
should generally be used for operators where the initial cursor position is vital for the operator (Expand) or when the active face set is used, ie. the face set under the cursor (Filters).I'll edit the main text to be more clear. The
Invert
andLevels
operatorsd do not exist in sculpt mode and are only availbile in the vertex/texture painting modes.Instead there are color filters for
Brightness
andValue
.Expand Color by Topology
is available via thesculpt.expand
operator and setting the data target toColor
.Quick update:
Sculpt
menu PR is still ongoing (hopefully close to done?) on the original branch of the issue (sculpt_mode_add_menu_operators
).102427_continued
.Mask
menu to look similar to the posted image, I've also addedMask by Colors
in the menu.I'll try not to dive in too deep as to not make things grow out of hand again.
@Tarek-Yasser Thanks! Any issues that are resolved will be marked as done or removed from this task description 👍
Another update:
Finished up the
Face Sets
menu. Also did a few basic tests to make sure things work.Note that the
sculpt_face_set_edit
operator seems to need the redo panel treatment.Started working on
Paint
, added all of the menu in the screenshot exceptInvert
andLevels
, I can't really find them.For "combo" operators (
Hue/Saturation/Value
), The code seems to treat each as a different operator.Was the intention in the original issue to somehow have one entry in the menu for all of them or should I implement them as one entry each?
Current tool implementation also has each as a different operator/option.
The main difference between the tool and the menu entry is that the tool allows you to choose a color for
Fill
, the menu entry does not. It just uses black. I think the most user friendly solution would to be pop up a color picker once the user clicks the menu entry. I'll look into that for a bit (no rabbit holes this time!)The rest of the operator variants:
Hue
,Saturation
, ...,Blue
just require a strength so they don't need anything to be "functional"This operator also lacks a modal keymap, a proper status bar, and the mouse cursor. I'll probably add them like I did with mesh filters.
edit: I don't actually know if
popover
oroperator_menu_hold
is correct.Popover
interestly integrates as a submenu; I did not tryoperator_menu_hold
The HSV color filter ops are implemented separately, yes. We could combine them if that would be better.
For Fill, I think you can use
UILayout.popover
for it.UILayout.operator_menu_hold
is another possibility. The former requires subclassing Panel and the latter a Menu. In both cases you'll want to make a color button to the appropriate last operator property, like so:layout.prop(WindowManager.operator_properties_last("sculpt.color_filter"), "fill_color")
And then make a button to the actual operator with
UILayout.operator
as normal:layout.operator("sculpt.color_filter")
I imagine the panel class would look like this:
Btw I refactored color filter to support the last operator panel and redo last operator, like with mesh filter.
So I spent yesterday playing with the code you posted and looking at the python examples and API documentation.
The code you posted needed some small modifications to work:
I don't think the current fill color UI "popover" is correct? Here's what I imagined:
Here's how the above snippet renders in the UI:
One more thing,
layout.operator_context = "EXEC_DEFAULT"
doesn't seem to work as intended. I assume the intended behaviour is that you choose the color, then clickFill
and click the object, applying the color fill immediately without dragging.But currently, the following error is printed in the terminal:
Removing the line restores the modal behaviour (i.e. clicking and dragging) which works correctly, but I'm not sure if this is what you wanted.
Removing bl_context draws the submenu in "Tools" as shown in the previous image. Adding
bl_context = ".sculpt_mode"
draws it in the header besidesDyntopo
too. Note that "popover" is not a valid option for bl_context.If I misunderstood what's required, just point me to something similar and I'll figure things out.
The redo panel seems to have a bug with Fill Color. If I use the menu entry, then try to change the color or strength through the redo panel, it doesn't work. If I try applying the menu entry again then use the redo panel, the color/strength are then updated properly. Using the tools panel seems to work fine the first time.
Next up: cancelling / modal keymap + cursor.
Another unrelated thing I've noticed is that the viewport shading setting is not saved. For example, when I set it to
Render Preview
, save the blend file, then re-open, it's reset toSolid
.@Tarek-Yasser Thanks for looking deeper into the Color Fill operator.
It's fair to say that this one is more complex than the other ones and should get more design discussions before going further.
IMO the best way to implement this is to follow conventions of most image editing applications, by adding a color setting to the scene itself.
Any fill operator, tool or brush should then be able to either use the Unified color setting of the scene (default) or define their own color in their tool setting or adjust last operation settings.
This Scene color then needs to be always visible in the header of any mode capable of painting.
Ok, let's say we were to implement this. There are a few things that I think should be considered:
If we are to look things we already have, I think it would look something like Vertex/Texture Paint:
I could be wrong, but this feels like it could potentially be a separate issue? Depending on the amount of change, this could be something that takes time since it might span a few parts of Blender.
@Tarek-Yasser Yes the fill oeprator can be kept as a separate topic.
Ideally the discussion can continue over on #99769.
I'll scratch it from the description in this task.
But about your questions:
I'm pretty sure a scene color already exists, because of
bpy.types.UnifiedPaintSettings.use_unified_color
.This color could be more generally exposed in the header at all times.
This one is also saved with the .blend file.
I would propose that:
If a tool/brush is already defining their own color, then this one takes precedent and will be shown in the header (like in Vertex/Texture Paint Mode) instead and will be used for any color operator instead of the scene color.
@JulienKaspar @JosephEagar Ok, I think this issue and the #104718 are really done now.
The last push should (hopefully) finalize Color Filter.
Stuff implemented:
WM_CUROSOR_EW_SCROLL
.SCULPT_orig_vert_data_init
toSCULPT_UNDO_COLOR
.The following are some notes and potential docs I wrote down while working.
Notes
Expand color by topology crashes?
Inside
sculpt_expand_colors_update_task_cb
,vd.mask
which is a pointer is dereferenced without any checks.Drawing a mask solves the crashing issue but I'm not sure if a mask is even required for this to work?
So I've got two solutions depending on the required behaviour:
The only way I currently know of checking if a mask exists is to loop over the PBVH and check vertices.
Something like this: I'm not quite sure if there's a better way (cached somewhere perhaps?)
nullptr
before dereferencing it.Filter Mesh/Color share some code.
If the code is not going to change much, it might be a good issue for new developers to pull out this common code.
Here's a list of the code I know is mostly duplicated:
Using keymap actions in operator code.
This follows from Filter Mesh, you can find steps to how the modal keymap was implemented in a comment in #104718.