Anim: ensure subdivided bones have sequential names #119775

Merged
Sybren A. Stüvel merged 2 commits from dr.sybren/blender:pr/bone-subdivide-order into main 2024-03-22 15:26:32 +01:00

This PR consists of two commits, and I intend to land it as such. The first is a fix for a bug that doesn't happen yet in Blender (because the relevant parameter is always nullptr), the second is the actual change in the bone subdivision code (which passes a non-nullptr value for that parameter).

This commit basically ensures that subdividing "Bone" results in a chain "Bone", "Bone.001", "Bone.002", etc. Before, the order would be "Bone", "Bone.004", "Bone.003", etc.

Before After
before After

The code could have been a bit nicer, but that would require refactoring more. More explanations in the in-code comments.


This might break add-ons that assume to know the bone names before the
actual subdivision happens. This would always have been fragile, as
there may, for example, already have been a "Bone.001"; in that case
subdividing "Bone" would result in "Bone", "Bone.002", etc. Instead, the
parent-child chain should be followed.

This PR consists of two commits, and I intend to land it as such. The first is a fix for a bug that doesn't happen yet in Blender (because the relevant parameter is always `nullptr`), the second is the actual change in the bone subdivision code (which passes a non-`nullptr` value for that parameter). This commit basically ensures that subdividing "Bone" results in a chain "Bone", "Bone.001", "Bone.002", etc. Before, the order would be "Bone", "Bone.004", "Bone.003", etc. | Before | After | | -- | -- | | ![before](/attachments/a6141343-9dc4-4d4a-8d99-bce956aebf98) | ![After](/attachments/64c623f6-90b1-4fe8-b745-24b7d7f8d034) | The code could have been a bit nicer, but that would require refactoring more. More explanations in the in-code comments. ---------- This might break add-ons that assume to know the bone names before the actual subdivision happens. This would always have been fragile, as there may, for example, already have been a "Bone.001"; in that case subdividing "Bone" would result in "Bone", "Bone.002", etc. Instead, the parent-child chain should be followed.
Sybren A. Stüvel added this to the 4.2 LTS milestone 2024-03-22 10:11:27 +01:00
Sybren A. Stüvel added the
Module
Animation & Rigging
label 2024-03-22 10:11:27 +01:00
Sybren A. Stüvel requested review from Christoph Lendenfeld 2024-03-22 10:21:50 +01:00
Sybren A. Stüvel requested review from Pierrick PICAUT 2024-03-22 10:21:59 +01:00
Author
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/PR119775) when ready.
Christoph Lendenfeld approved these changes 2024-03-22 11:09:51 +01:00
Christoph Lendenfeld left a comment
Member

lgtm. makes much more sense now
There is a crash when using F2 for renaming, but that doesn't come from these changes.
But that does mean the build will crash when testing it.

reported the crash: #119778: Crash when using F2 to rename in the 3D viewport

lgtm. makes much more sense now There is a crash when using F2 for renaming, but that doesn't come from these changes. But that does mean the build will crash when testing it. reported the crash: [#119778: Crash when using F2 to rename in the 3D viewport](https://projects.blender.org/blender/blender/issues/119778)
@ -1772,0 +1779,4 @@
* The code above cuts into fractions (for cuts=3 it cuts into 1/4, then 1/3, then 1/2), which
* means that it MUST be run in that order. It could also just calculate the final bone length
* and create (N-1) bones of that length, which can then be done in any order. If that ever
* happens, the order can be inverted, and then the call to ED_armature_ebone_unique_name() can

the order can be inverted
does that mean it can be inverted from the current LISTBASE_FOREACH_BACKWARD meaning just iterating forward?
If that is the case, I think it's clearer to say that explicitly

`the order can be inverted` does that mean it can be inverted from the current `LISTBASE_FOREACH_BACKWARD` meaning just iterating forward? If that is the case, I think it's clearer to say that explicitly
Author
Member

No, it refers back to "it MUST be run in that order", which in turn refers to "The code above". I'll reword to clarify.

No, it refers back to "it MUST be run in that order", which in turn refers to "The code above". I'll reword to clarify.
dr.sybren marked this conversation as resolved
Sybren A. Stüvel force-pushed pr/bone-subdivide-order from 47a11db1c2 to 649d04d429 2024-03-22 15:21:36 +01:00 Compare
Sybren A. Stüvel force-pushed pr/bone-subdivide-order from 649d04d429 to b5e4a4dc2e 2024-03-22 15:21:45 +01:00 Compare
Sybren A. Stüvel merged commit 9f0cc7fe64 into main 2024-03-22 15:26:32 +01:00
Sybren A. Stüvel deleted branch pr/bone-subdivide-order 2024-03-22 15:26:34 +01:00
Author
Member

ce8a032ac2 was also part of this PR, even though that wasn't marked as such by Gitea.

ce8a032ac2a3edf9fde9cdeb5a8dd42a6c5625ec was also part of this PR, even though that wasn't marked as such by Gitea.
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
3 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#119775
No description provided.