WIP: Fix #119300: Bones in pose mode snap to the posed object #119386

Draft
Germano Cavalcante wants to merge 1 commits from mano-wii/blender:fix_119300 into main

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

When you are transforming pose bones, it does not seem to be ideal to snap to objects affected by the transformation, as this creates a feedback loop.

Therefore, this commit ignores dependent objects during the pose bones transformation.

The solution is basically move the code that sets
BA_SNAP_FIX_DEPS_FIASCO (time to change the name? 👀) from
transform_convert_object.cc to transform_snap.cc.

To make the function generic, a callback is set in the parameters in
order to define which bases are the ones transformed.


I put WIP because it comes into design issues that perhaps deserve to be discussed.

Attached file for testing

When you are transforming pose bones, it does not seem to be ideal to snap to objects affected by the transformation, as this creates a feedback loop. Therefore, this commit ignores dependent objects during the pose bones transformation. The solution is basically move the code that sets `BA_SNAP_FIX_DEPS_FIASCO` (time to change the name? 👀) from `transform_convert_object.cc` to `transform_snap.cc`. To make the function generic, a callback is set in the parameters in order to define which bases are the ones transformed. --- I put WIP because it comes into design issues that perhaps deserve to be discussed. Attached file for testing
Germano Cavalcante added the
Module
Animation & Rigging
label 2024-03-12 16:44:02 +01:00
Germano Cavalcante added 1 commit 2024-03-12 16:44:11 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
3e509725e3
WIP: Fix #119300: Bones in pose mode snap to the posed object
This solution basically moves the code that sets
`BA_SNAP_FIX_DEPS_FIASCO` (time to change the name?) from
`transform_convert_object.cc` to `transform_snap.cc`.

To make the function generic, a callback is set in the parameters in
order to define which bases will be transformed.
Germano Cavalcante requested review from Sybren A. Stüvel 2024-03-12 16:44:33 +01:00
Germano Cavalcante requested review from Sergey Sharybin 2024-03-12 16:44:34 +01:00

In an ideal world you could imagine that you might be able to snap bones from one chain to bones of another independent chain. Not sure if that was working already, if it was then this change probably needs to go a bit more granular than checking for transform components.

In an ideal world you could imagine that you might be able to snap bones from one chain to bones of another independent chain. Not sure if that was working already, if it was then this change probably needs to go a bit more granular than checking for transform components.

@mano-wii From the PR description, I have no idea what this would actually change from a user's perspective. Could you update it a bit?

@mano-wii From the PR description, I have no idea what this would actually change from a user's perspective. Could you update it a bit?
Author
Member

Sorry for the delay in replying.
I improved the PR description.
To make it clear, below are some gifs showing the behavior before and after.
Note that before there was a kind of "feedback loop" in which the bone would snap to the geometry itself being posed.
After, the geometry continues to be posed, but the snap is not made to it.

Before After

If I understand Sergey's proposal, the ideal would be to ignore only the geometry being affected (the vertices below in the example file would still be targeted by the snap).
Although it is not impossible, in my opinion it adds a lot of complication to the code for little benefit.

Other solutions:

  • Snap to original geometry (without modifiers)
  • Make an internal copy of the mesh before transforming and snap to the copy instead

About the PR: The solution was to move existing code that tags Bases to be ignored and implement callbacks to identify dependent/related Bases in general cases.
An alternative to callbacks would be to mark the dependent/related Bases with BA_TEMP_TAG and use this tag inside the code that was moved.

Sorry for the delay in replying. I improved the PR description. To make it clear, below are some gifs showing the behavior before and after. Note that before there was a kind of "feedback loop" in which the bone would snap to the geometry itself being posed. After, the geometry continues to be posed, but the snap is not made to it. | Before | After | | ------ | ----- | | ![](/attachments/18913891-7552-4ffc-a66b-ed9465ba4c4f) | ![](/attachments/5475569e-ef50-4c1c-b6bf-bb779ed59c9e) | If I understand Sergey's proposal, the ideal would be to ignore only the geometry being affected (the vertices below in the example file would still be targeted by the snap). Although it is not impossible, in my opinion it adds a lot of complication to the code for little benefit. Other solutions: - Snap to original geometry (without modifiers) - Make an internal copy of the mesh before transforming and snap to the copy instead --- About the PR: The solution was to move existing code that tags Bases to be ignored and implement callbacks to identify dependent/related Bases in general cases. An alternative to callbacks would be to mark the dependent/related Bases with `BA_TEMP_TAG` and use this tag inside the code that was moved.
375 KiB
426 KiB

I think the approach of ignoring all dependents may be too restrictive. See my earlier comment #119300 (comment) for a use case where this would not work.

I think the approach of ignoring all dependents may be too restrictive. See my earlier comment https://projects.blender.org/blender/blender/issues/119300#issuecomment-1149876 for a use case where this would not work.

@dr.sybren The comment describes some theoretical case which would be nice to have, and it is not something that is possible to achieve with the current architecture. It is also not very constructive to suggest making a bigger architectural change to fix the current state of bone transform not implementing feedback loop detection in the current definitions of such loop.

The more addressable issue here is the fact that the current dependency traversal API seems to be limited in a sense that all bones will be reported as the same component, so the code will be detecting false-positive feedback loops of fully independent bone chains. At least that is what I remember from the initial state of that code. If it is not yet made to be more flexible to properly allow traversing bones, then it is something that can be implemented without big architectural changes.

@dr.sybren The comment describes some theoretical case which would be nice to have, and it is not something that is possible to achieve with the current architecture. It is also not very constructive to suggest making a bigger architectural change to fix the current state of bone transform not implementing feedback loop detection in the current definitions of such loop. The more addressable issue here is the fact that the current dependency traversal API seems to be limited in a sense that all bones will be reported as the same component, so the code will be detecting false-positive feedback loops of fully independent bone chains. At least that is what I remember from the initial state of that code. If it is not yet made to be more flexible to properly allow traversing bones, then it is something that can be implemented without big architectural changes.

From the PR description:

Therefore, this commit ignores dependent objects during the pose bones transformation.

It would seem that this is not limited to objects only, and also affects snapping to bones.

@Sergey wrote:
The comment describes some theoretical case which would be nice to have, and it is not something that is possible to achieve with the current architecture.

I think you're misunderstanding me. The "Pose bone A snapping to bone B that has a dependency on A" case currently works. I've attached an example blend file.

Screenshot with two bones

Rotate the 'MoveMe' bone, and you'll see the other rotates along with it. Translate the 'MoveMe' bone, and it'll snap to the other bone just fine. Without this PR, that is.

It is also not very constructive to suggest making a bigger architectural change...

Which is why I also suggested removing the "bones are also vertices" assumption from the snapping code, and making snapping to bones a separate option from snapping to vertices. I think that that'll be a rather simple change to implement. That would be an alternative way of reaching the same goal: to prevent bones from snapping to the mesh that they deform.

From the PR description: > Therefore, this commit ignores dependent objects during the pose bones transformation. It would seem that this is not limited to objects only, and also affects snapping to bones. > @Sergey wrote: > The comment describes some theoretical case which would be nice to have, and it is not something that is possible to achieve with the current architecture. I think you're misunderstanding me. The "Pose bone `A` snapping to bone `B` that has a dependency on `A`" case **currently works**. I've attached [an example blend file](/attachments/5308d75e-8b4e-4ce8-8725-58a515f61390). ![Screenshot with two bones](/attachments/856da883-e243-4bc7-be23-655a6fce5bf6) Rotate the 'MoveMe' bone, and you'll see the other rotates along with it. Translate the 'MoveMe' bone, and it'll snap to the other bone just fine. Without this PR, that is. > It is also not very constructive to suggest making a bigger architectural change... Which is why I also suggested removing the "bones are also vertices" assumption from the snapping code, and making snapping to bones a separate option from snapping to vertices. I think that that'll be a rather simple change to implement. That would be an alternative way of reaching the same goal: to prevent bones from snapping to the mesh that they deform.

The part about "this is something that currently works, but the suggested PR breaks it" is not something that comes across very clearly, and it would have been more gooder if it was stated more explicitly.

The thing is, when someone says that something is helpful to have (especially when it actually helpful to have) the message comes across that it should work per design. However, the file you've demonstrated it happened to work in a specific configuration, but it is not something that is guaranteed per design. If you add Copy Location to CopiesRotation with an influence of 0.2 you'll start having those annoying oscillations. Such behavior is not something that is expected as per UW design, hence there is this system which detects feedback loop in object mode. And from this point of view it is the pose mode transform which deviates from the intended design.

And that becomes a trade-offs. On the one hand, if you do not change anything in the pose mode transform, then some cases which currently work keeps working, but also all the cases which currently don't work lead to those wonky looking epilepsy. And if you change it, then no epilepsy cases happens, matching the expected behavior with transform in other modes, but you will introduce regression in cases which currently happened to work.

To me having solid UX is important, probably even more important that keeping cases, which can not be reliably supported by the current design, working. I also do not think it is correct to separate this behavior across different modes. As in, in the demo file you've made you can easily replace bones with objects, so why bones should allow such cases, but not the objects.

There are also seems to be two separate topics here:

  1. Having snapping system which works predictably in cases when a feedback loop is involved.
  2. Having an option to limit snapping of bones to bones.

The latter one does sound useful to have, and it does sound like it will mitigate the case from the original report. But it does not move forward with the former one, since you can have feedback loop which will upset snapping even when it is limited to bones only.

The part about "this is something that currently works, but the suggested PR breaks it" is not something that comes across very clearly, and it would have been more gooder if it was stated more explicitly. The thing is, when someone says that something is helpful to have (especially when it actually helpful to have) the message comes across that it should work per design. However, the file you've demonstrated it happened to work in a specific configuration, but it is not something that is guaranteed per design. If you add `Copy Location` to `CopiesRotation` with an influence of 0.2 you'll start having those annoying oscillations. Such behavior is not something that is expected as per UW design, hence there is this system which detects feedback loop in object mode. And from this point of view it is the pose mode transform which deviates from the intended design. And that becomes a trade-offs. On the one hand, if you do not change anything in the pose mode transform, then some cases which currently work keeps working, but also all the cases which currently don't work lead to those wonky looking epilepsy. And if you change it, then no epilepsy cases happens, matching the expected behavior with transform in other modes, but you will introduce regression in cases which currently happened to work. To me having solid UX is important, probably even more important that keeping cases, which can not be reliably supported by the current design, working. I also do not think it is correct to separate this behavior across different modes. As in, in the demo file you've made you can easily replace bones with objects, so why bones should allow such cases, but not the objects. There are also seems to be two separate topics here: 1. Having snapping system which works predictably in cases when a feedback loop is involved. 2. Having an option to limit snapping of bones to bones. The latter one does sound useful to have, and it does sound like it will mitigate the case from the original report. But it does not move forward with the former one, since you can have feedback loop which will upset snapping even when it is limited to bones only.
Author
Member

Which is why I also suggested removing the "bones are also vertices" assumption from the snapping code, and making snapping to bones a separate option from snapping to vertices. I think that that'll be a rather simple change to implement. That would be an alternative way of reaching the same goal: to prevent bones from snapping to the mesh that they deform.

I'm not sure if this would be a solution, as the user might also want to snap to Mesh, and that would result in the same problem.

> Which is why I also suggested removing the "bones are also vertices" assumption from the snapping code, and making snapping to bones a separate option from snapping to vertices. I think that that'll be a rather simple change to implement. That would be an alternative way of reaching the same goal: to prevent bones from snapping to the mesh that they deform. I'm not sure if this would be a solution, as the user might also want to snap to Mesh, and that would result in the same problem.

Maybe I was more hooked onto the title of #119300: "Bone snapping to only bones", which is why I thought that having an option to do this would be a simple way forward. I agree that this is a separate thing from fixing the feedback issues.

And +1 for keeping all the transformables working the same way. The more unification we have between objects and bones, the better.

I'll trigger a test build, so that I can share a link in the A&R module meeting today.

@blender-bot package

Maybe I was more hooked onto the title of #119300: "Bone snapping to only bones", which is why I thought that having an option to do this would be a simple way forward. I agree that this is a separate thing from fixing the feedback issues. And +1 for keeping all the transformables working the same way. The more unification we have between objects and bones, the better. I'll trigger a test build, so that I can share a link in the A&R module meeting today. @blender-bot package

@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/PR119386) when ready.
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119386) when ready.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
This pull request has changes conflicting with the target branch.
  • source/blender/editors/transform/transform_snap.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix_119300:mano-wii-fix_119300
git checkout mano-wii-fix_119300
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
4 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#119386
No description provided.