WIP #104054 Symmetize visible edit bones if nothing has been selected #105385

Closed
Denys Hsu wants to merge 3 commits from cgtinker/blender:104054-symmetrize-armature-nothing-selected into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

Symmetrize does nothing when there are no bones selected (Silently exits). Expected behaviour would be that when nothing is selected, the armature gets symmetrized as if all bones are selected.

When all bones are selected, all visible, selectable bones are symmetrized. This makes sense from the user perspective and also should be expected when nothing has been selected.

Options to solve this problem:

  • Select all, if nothing has been selected ("reuse the deselection code").
  • Select bones depending on the selected direction if mirrowed bones are available.

Selecting all visible bones seemed like the naive solution to this problem as Symmetrize operates on selected bones and deselects mirrored bones if all bones have been selected.

Symmetrize does nothing when there are no bones selected (Silently exits). Expected behaviour would be that when nothing is selected, the armature gets symmetrized as if all bones are selected. When all bones are selected, all visible, selectable bones are symmetrized. This makes sense from the user perspective and also should be expected when nothing has been selected. Options to solve this problem: - Select all, if nothing has been selected ("reuse the deselection code"). - Select bones depending on the selected direction if mirrowed bones are available. Selecting all visible bones seemed like the naive solution to this problem as Symmetrize operates on selected bones and deselects mirrored bones if all bones have been selected.
Denys Hsu added 1 commit 2023-03-02 20:58:43 +01:00
Sybren A. Stüvel requested changes 2023-03-03 14:28:47 +01:00
Sybren A. Stüvel left a comment
Member

This doesn't just symmetrize the visible edit bones, it actually selects them, which is quite a different thing. Selection has to be treated carefully, as often it's the result of specific actions by the artist.

You may want to check Ingredients of a PR as well, to expand the PR description a bit. A think that's missing now is an analysis of the alternatives. For example, the code could also be adjusted to symmetrize all the bones when there is no selection, and not just only the visible ones. I'm not saying your choice is bad, quite the contrary, I think it's good to limit the effect to visible bones only. But having this motivated as an explicit choice will make it easier to understand later on.

This doesn't just symmetrize the visible edit bones, it actually selects them, which is quite a different thing. Selection has to be treated carefully, as often it's the result of specific actions by the artist. You may want to check [Ingredients of a PR](https://wiki.blender.org/wiki/Process/Contributing_Code#Ingredients_of_a_Pull_Request) as well, to expand the PR description a bit. A think that's missing now is an analysis of the alternatives. For example, the code could also be adjusted to symmetrize all the bones when there is no selection, and not just only the visible ones. I'm not saying your choice is bad, quite the contrary, I think it's good to limit the effect to visible bones only. But having this motivated as an explicit choice will make it easier to understand later on.
Denys Hsu changed title from Ref #104054 Symmetize visible edit bones if nothing has been selected to WIP #104054 Symmetize visible edit bones if nothing has been selected 2023-03-04 23:26:52 +01:00
Author
Contributor

This doesn't just symmetrize the visible edit bones, it actually selects them, which is quite a different thing. Selection has to be treated carefully, as often it's the result of specific actions by the artist.

You may want to check Ingredients of a PR as well, to expand the PR description a bit. A think that's missing now is an analysis of the alternatives. For example, the code could also be adjusted to symmetrize all the bones when there is no selection, and not just only the visible ones. I'm not saying your choice is bad, quite the contrary, I think it's good to limit the effect to visible bones only. But having this motivated as an explicit choice will make it easier to understand later on.

Thanks for the input. I'm not sure if selecting nothing is a specific action in this case, but I totally get that selections should be treated carefully. I updated the PR description decided to not select all via the context, if nothing has been selected.

This makes the actual change more readable - the operator still acts like the symmetrize when everything is selected. Kinda would like to remove some nesting swell but I wanted to keep the actual changes easy to read.

> This doesn't just symmetrize the visible edit bones, it actually selects them, which is quite a different thing. Selection has to be treated carefully, as often it's the result of specific actions by the artist. > > You may want to check [Ingredients of a PR](https://wiki.blender.org/wiki/Process/Contributing_Code#Ingredients_of_a_Pull_Request) as well, to expand the PR description a bit. A think that's missing now is an analysis of the alternatives. For example, the code could also be adjusted to symmetrize all the bones when there is no selection, and not just only the visible ones. I'm not saying your choice is bad, quite the contrary, I think it's good to limit the effect to visible bones only. But having this motivated as an explicit choice will make it easier to understand later on. Thanks for the input. I'm not sure if selecting nothing is a specific action in this case, but I totally get that selections should be treated carefully. I updated the PR description decided to not select all via the context, if nothing has been selected. This makes the actual change more readable - the operator still acts like the symmetrize when everything is selected. Kinda would like to remove some nesting swell but I wanted to keep the actual changes easy to read.
Denys Hsu added 1 commit 2023-03-06 14:16:43 +01:00
Denys Hsu added 1 commit 2023-03-06 14:41:49 +01:00
Denys Hsu requested review from Sybren A. Stüvel 2023-03-06 14:48:48 +01:00
Sybren A. Stüvel requested changes 2023-03-07 17:32:25 +01:00
Sybren A. Stüvel left a comment
Member

Kinda would like to remove some nesting swell but I wanted to keep the actual changes easy to read.

I completely agree. I've added two inline notes, but then I hit the more complex code and it's just super hard to follow what's going on.

I think it's better to first clean up the existing code. Some flipping of conditions and added continue statements will already help a lot in reducing the indentation levels. Also I feel the code should be split up into a few smaller functions, so that the overall purpose of each block becomes clearer.

Would you be up for that, in a diffent PR? After that, we can revisit this change, I'm sure it'll be a lot easier to implement once the code has been cleaned up.

> Kinda would like to remove some nesting swell but I wanted to keep the actual changes easy to read. I completely agree. I've added two inline notes, but then I hit the more complex code and it's just super hard to follow what's going on. I think it's better to first clean up the existing code. Some flipping of conditions and added `continue` statements will already help a lot in reducing the indentation levels. Also I feel the code should be split up into a few smaller functions, so that the overall purpose of each block becomes clearer. Would you be up for that, in a diffent PR? After that, we can revisit this change, I'm sure it'll be a lot easier to implement once the code has been cleaned up.
@ -1102,2 +1102,3 @@
/* cancel if nothing selected */
/* check is any ebone is selected on init */
bool is_selected = true;

IMO is_selected doesn't quite cover the purpose. In other code I've used the name is_selection_relevant for this.

IMO `is_selected` doesn't quite cover the purpose. In other code I've used the name `is_selection_relevant` for this.
@ -1104,2 +1104,3 @@
bool is_selected = true;
if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
is_selected = false;

The declaration and if can be reduced to:

const bool is_selected = CTX_DATA_COUNT(C, selected_bones) > 0;

This has the added advantage that now the variable can be const.

The declaration and `if` can be reduced to: ```c const bool is_selected = CTX_DATA_COUNT(C, selected_bones) > 0; ``` This has the added advantage that now the variable can be `const`.
Author
Contributor

Kinda would like to remove some nesting swell but I wanted to keep the actual changes easy to read.

I completely agree. I've added two inline notes, but then I hit the more complex code and it's just super hard to follow what's going on.

I think it's better to first clean up the existing code. Some flipping of conditions and added continue statements will already help a lot in reducing the indentation levels. Also I feel the code should be split up into a few smaller functions, so that the overall purpose of each block becomes clearer.

Would you be up for that, in a diffent PR? After that, we can revisit this change, I'm sure it'll be a lot easier to implement once the code has been cleaned up.

Sure, was thinking the same. I'll create another PR soon.

> > Kinda would like to remove some nesting swell but I wanted to keep the actual changes easy to read. > > I completely agree. I've added two inline notes, but then I hit the more complex code and it's just super hard to follow what's going on. > > I think it's better to first clean up the existing code. Some flipping of conditions and added `continue` statements will already help a lot in reducing the indentation levels. Also I feel the code should be split up into a few smaller functions, so that the overall purpose of each block becomes clearer. > > Would you be up for that, in a diffent PR? After that, we can revisit this change, I'm sure it'll be a lot easier to implement once the code has been cleaned up. Sure, was thinking the same. I'll create another PR soon.
Sybren A. Stüvel added the
Module
Animation & Rigging
label 2023-04-07 12:51:02 +02:00
Sybren A. Stüvel added this to the Animation & Rigging project 2023-04-07 12:51:07 +02:00
Denys Hsu closed this pull request 2023-05-13 01:10:13 +02:00
Sybren A. Stüvel removed this from the Animation & Rigging project 2023-05-15 11:37:55 +02:00

Pull request closed

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#105385
No description provided.