Fix #114981 : Add box, circle and lasso selection tools to weight paint + bone select mode #115807
No reviewers
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115807
Loading…
Reference in New Issue
No description provided.
Delete Branch "daisea3e1203/blender:add-select-tools-to-bone-select-mode"
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?
Issue
Currently, bone select mode in weight paint mode (added/made explicit in #115409) has a tweak tool, but lacks box, circle and lasso select tools, lacking consistency with the other two modes (face and vertex select modes) in Weight paint mode. This results in a lack of useful methods for selecting multiple bones in weight paint mode, which was mentioned as necessary in issue #114981 .
Note : This issue was mentioned in the Future Improvements section of PR #115409, and will address Issue #114981 together with PR #115409 which is already merged.
Solution
By adding a box, circle and lasso select tools with the following behavior, all selection tools can be added while respecting the current behavior of selecting bones using alt-click and LCS and right-click in RCS (referred to as click behavior):
Note: this PR will also enable the B and C hotkeys for box select and circle select as the keymap from 3D View will fall through to weight paint mode.
Examples
Cursor picking with box and lasso tool will not deselect bones, but region picking will. (Clicking here will not deselect the bone, but box selecting from here to the right will. Same goes for the lasso tool.)
When an object has multiple armatures deforming it and both armatures were selected when going into weight paint mode, box selecting all the bones will only select the bones from the armature with the active bone. It is still possible to select the bone in the other armature by cursor picking.
(before box select)
(after box select)
(after clicking on a bone in the other armature)
Key areas for review
Behavior of region selecting an empty space
The ability to deselect all bones by region selecting an empty area felt reasonable, and might be useful in situations where selecting multiple bones in weight paint mode is useful. (To run a certain operation based on the selection of bones?) However, this does not align with the current behavior of alt-click bone select where clicking in an empty space will not deselect any bones. If aligning with this behavior feels more natural, then maybe region selecting an empty space should not deselect all bones.
Files
Example file used in screen shots: pr_115807_single_armature.blend, pr_115807_multiple_armatures.blend
Commit message for the squashed commit
Currently, bone select mode in weight paint mode has a tweak tool, but lacks box, circle and lasso select tools, lacking consistency with the other two modes (face and vertex select modes) in Weight paint mode. This results in a lack of useful methods for selecting multiple bones in weight paint mode.
By adding a box, circle and lasso select tools with the following behavior, all selection tools can be added while respecting the current behavior of selecting bones using alt-click and LCS and right-click in RCS (referred to as click behavior):
WIP: Add box, circle and lasso selection tools to weight paint + bone select modeto Fix #114981 : Add box, circle and lasso selection tools to weight paint + bone select modeminor comment style changes.
The bigger thing is the behavior when clicking in an empty space. It feels weird to me, and it is inconsistent with the behavior in object mode. But I feel like it's not up to me to decide.
Great job pointing that out in the PR description btw. And also good job testing the edge case of multiple armatures.
@Mets need you to have an eye on this. What should happen when clicking in an empty space with e.g. the box select tool.
@ -208,2 +208,4 @@
*/
bool BKE_paint_select_vert_test(const Object *ob);
// /**
// * Return true when in weight paint + bone-select mode?
The blender comment style is without the double slash (//) at the start
Also I feel like the comment should not be a question. I know this is the same as the functions above,
but it's confusing to read.
I assume its just a statement. As in it returns true when in weight paint + bone-select mode.
I applied the same change in
09a3f4b9b1
to the two functions above (change the question mark to a period) since I encountered them many times when coding for this PR, and were used as a statement to check for their respective modes.@ -2914,0 +2919,4 @@
else if (BKE_paint_select_bone_test(vc.obact)) {
/* pass */
/* During weight paint mode, when there are multiple armatures deforming a single mesh,
this comment is great. I love it
@ -5307,6 +5320,21 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
}
FOREACH_OBJECT_IN_MODE_END;
}
/* Select bones from pose mode armature in weight paint + bone-select mode */
comments end with a dot
Addressed in
05bb4f72e0
Thank you for spotting these mistakes! Will be careful with comments in future PRs 🙏
Thanks for the patch!
To be clear, this is practically unsupported in Blender as it is, so the fact that it doesn't work perfectly is not the biggest issue imo.
However, if it did work, that would make life easier in a lovely but unlikely to be near future, where Armature deformation is done via GeoNodes, so the weights can come from as many armature objects as desired and still be normalized. But considering this is not on anybody's roadmap, I don't feel strongly about it.
I would stay consistent with other areas of Blender here. This sounds a bit esoteric to me.
Deselect All is Alt+A throughout Blender. Meanwhile, box/circle/lasso select is an additive selection throughout Blender. Having it clear the selection when there's nothing in the selected region feels like it will just result in confusion, so I wouldn't do it tbh.
this is another area where LCS and RCS are different. LCS definitely deselects by clicking an empty area. Will need to check RCS
Thank you for the feedback! Will check the RCS behavior and append to the PR description.
Oh wow, nevermind, I think it's not a left/right-click select thing, but a tool vs hotkey thing. Selection Tools, which I never used, behave differently from B/C/Ctrl+Click hotkeys... Wow. I learned something. Well, I think that's odd, but that ain't this patch's fault. But still, let's try to be consistent, and if this is consistent with the rest of Blender as it is, then so be it. 🙃
That said, I wish those hotkeys were available in weight paint mode, at least B and C. But I suppose that is a separate issue.
I forgot to mention in the description (fixed), but B and C hotkeys will be available with this patch! (the respective keymap from 3d View will be applied automatically now that the selection tools are available in weight paint mode.)
Will check if the behavior of selection tools activated from hotkeys align with the behavior you mentioned 👍
@Mets I checked the behavior of B and C hotkeys in weight paint mode, and they aligned with what you mentioned 👍 (region selecting with hotkeys doesn't deselect bones while region selecting with selection tools does. This behavior is appended to the PR description.)
@ChrisLend Thank you for spotting the comment style mistakes! They have been addressed in the last two commits. The review from @Mets should also be resolved with the check on hotkey behaviors above!
Since if the feedback from @Mets is to make it consistent with the rest of blender, I am comparing weigth paint with pose mode here.
RCS
LCS
so the only difference I could find was the deselection behavior which is inconsistent and I think should change
@ChrisLend
Do you think it would be clearer to create a separate PR for changing the behavior of clicking in an empty space during weight paint mode (row1 for LCS and RCS), and proceed with this PR as is?
The reason is that while the behaviors for rows 2-4 is related to the new box/circle select tools, changing row 1's behavior involves changing the existing behavior of not deselecting bones when right-clicking in an empty space during weight paint mode in RCS.
@Mets your opinion on this? I don't mind having that as a separate PR if the behavior is already like that
Ah, so Blender is already inconsistent as it is, and right-clicking in an empty space in weight paint mode won't deselect bones like it does in pose mode. Odd indeed.
I'd say that's a separate topic though, and I wouldn't hold back this PR because of it.
Just checked and it is consistent with the face/vertex mask selection behavior.
Thanks for pointing that out. In that case it looks good to land
I don't know if I'm misunderstanding how these additions are supposed to work, but box/circle/lasso selecting isn't actually selecting bones in my testing. I can activate the tools just fine, and e.g. drag a box out. It's just that it doesn't actually affect the bone selection. Simply clicking does still select the bones, however.
Just popping in to nag about a small thing.
@ -1046,1 +1046,4 @@
bool BKE_paint_select_bone_test(const Object *ob)
{
return ((ob != nullptr) && (ob->type == OB_MESH) && (ob->data != nullptr) &&
This will be clearer when written as separate expressions. I know the current code is consistent with the existing code, but I find the existing code really hard to read too, and I don't think we should duplicate that.
This separates the precondition checks from the actual query.
I also think the query is incorrect, as it checks whether any flag is set, ignoring
ME_EDIT_PAINT_FACE_SEL
andME_EDIT_PAINT_VERT_SEL
. IMO it should check that these flags are not set. I suspect this is the right check, but please do verifyNote that I didn't include the check for
ob->data != nullptr
, as this is implied byob->type == OB_MESH
. If a Mesh object doesn't have any data, there is something very wrong and other areas in the code will have stopped working already. This function is not the place to try and solve this problem.Thank you very much for the review and the insights about mesh data 🙏
The query is incorrect as you have pointed out, and have probably lead to the tools not functioning properly in some situations as @nathanvegdahl has demonstrated below. This has been fixed in
e11fce8298
.I have also refactored the two functions above in a similar fashion in
93a58c7601
, but if you think this change should occur in a different PR or occasion, please let me know.Ideally, such cleanups would happen before this PR (first cleanup, then change functionality). In this case I don't think that would be worth the effort, though.
Thank you very much for the feedback!
When I attempt to make a large change to the codebase in the future, I will make sure to create a separate clean up PR beforehand.
Sorry for the back-and-forth, but looking back at this now, I do think that it's better to have this change as a small separate PR that we can land before this one. That way this little fix can be described by itself, and in the hypothetical case that it causes any issues, rolled back by itself, without having to deal with this entire PR.
Can you try with factory preferences or share your file? I just tried on my end which has a similar setup and it's definitely working.
@ChrisLend Yeah, here's the blend file. (Note: in the video I only moved the bones outside the mesh to verify that it wasn't an occlusion issue.)
Resetting to factory preferences didn't make any difference for me.
@nathanvegdahl
Thank you so much for pointing this out! This is probably related to the flag check error @dr.sybren has pointed out, and should be fixed in the latest commit.
@nathanvegdahl indeed I can reproduce the issue with your file, but I cannot see the difference to my file. Can you verify my test file works for you
Edit: didn't see your latest comment. Will check the latest commit
Edit 2: yes with the latest changes, it even works in nathans test file
The latest change fixes the issue for me as well.
I've only given the code a cursory code review, since @ChrisLend and @dr.sybren have already looked more closely. But it looks good to me. I spent a bit more time testing, and it now seems to work as expected as well, including when multiple armatures are selected.
@ChrisLend
The changes requested by @dr.sybren has been addressed and were reviewed in the conversation thread, so this PR is probably ready to land!
I have also added a "Commit message for the squashed commit" in the PR description since I noticed you had to edit the PR description into a commit message when creating the squashed commit in the last PR. I simply removed references to other issues/PRs, and revised the Issue and Solution section, editing in the information from EDITs and NOTEs.
@daisea3e1203 I've re-requested review from @dr.sybren since he still had not given the green tick. once that is given I can land it.
Thanks for writing a commit message beforehand :)
What was the reasoning behind this choice?
About the commit message:
I'd recommend describing what the commit does. Using a word like "currently" can be confusing, as as soon as that commit is made, the message does not describe Blender's current behaviour any more.
By writing can be added, the message implies that they have not been added yet. The PR title (which is used as commit title) tells us that these tools are added by this commit, though. This would be another point of confusion.
I think the commit message can be simpler. The initial paragraph could be something like:
After that a more elaborate message can be written with more detailed changes, motivations of choices, etc.
I'm just clicking "Request Changes" to get this off my review queue.
Checkout
From your project repository, check out a new branch and test the changes.