Animation: Armature symmetrize ebones refactor #106487
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106487
Loading…
Reference in New Issue
No description provided.
Delete Branch "cgtinker/blender:symmetrize-refactoring"
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?
This patch removes some nested
if-statements
to improve readablilty - there is no functional change. My main intention has been to improve readability and therefore making it easier to implement changes in the future.Seperating the symmetrize operator selection logic from the temp pointer logic may reduces performance but it seems acceptable in this case. The change allows focussing on the selection logic without taking care of the temp pointers at the same time.
WIP: Animation: Armature symmetrize ebones refactorto Animation: Armature symmetrize ebones refactorI think this refactor is a much-needed improvement, thanks.
I 100% agree with the separation of concerns, but I do have a few concerns myself about the resulting code.
The name comparison (
STREQ(name_flip, ebone_iter->name)
): in the original code, this was used to entirely skip the handling of the bone. Now it only skips the deselection, but not the setting of the temp pointer.The logic of skipping invisible/deselected bones is now also duplicated.
How about this?
armature_symmetrize_exec()
.ED_armature_set_symmetrizable_ebone_selection
to handle a single bone only, and call it from within the above loop.I think that would address things.
@ -1089,6 +1096,71 @@ static EditBone *get_symmetrized_bone(bArmature *arm, EditBone *bone)
return (mirror != NULL) ? mirror : bone;
}
static void ED_armature_set_symmetrizable_ebone_selection(bArmature *arm, int axis, int direction)
No need to have an
ED_armature
prefix, those are only for functions that are declared in the header files (and thus part of Blender's internal API).Also
axis
anddirection
can be declared asconst int
.@ -1199,3 +1229,3 @@
BLI_string_flip_side_name(name_flip, ebone_iter->name, false, sizeof(name_flip));
/* bones must have a side-suffix */
/* mirrored bones must have a side-suffix */
Comments nowadays should be a full sentence, so start with a capital and end with a period. Touching is fixing ;-)
At first a tried to move only the selection part to a seperate method but it leads to issues. When both bones are selected and if the ebone_iter gets deselected no temp pointer gets set.
That's why I've been rerunning the "is selected / visible" logic at first. To reduce the overhead I decided to move it back in the main loop and set the temp ptr reference in the last step which kinda seperates it.
Having a method which deselects bones and returns a bool if a ptr should be set seems odd...
@ -1176,0 +1189,4 @@
}
/* Set temp pointer to mirrored ebones */
if (ebone) {
When you're here in the code,
ebone
is guaranteed to be non-NULL
.And even if it were to be
NULL
, settingebone_iter->temp.ebone = NULL
in that case also wouldn't hurt.Right, I've overlooked that, thanks.
I agree, it would look like the wrong abstraction/grouping of logic to me. Basically the code does:
So indeed, having the first point and half of the second in one function would be odd.
There's plenty of other improvements you could make to the original code, but I think the more important thing is to make just those improvements that make #105385 trivial to do. If after that you feel like more cleaning up, that's excellent for another PR :)
If you could just look at the removal of that
if
, then I think this PR is in good shape to get merged.Can it get merged?
Then I'd fix #105385
Thanks!