Bendy Bones #49315

Closed
opened 2016-09-10 09:31:57 +02:00 by Chris Offner · 12 comments

System Information
Windows 10
NVIDIA GTX 980 Ti

Blender Version
Broken: blender-2.78.0-git.d0e7c7a-windows64

Bendy Bones flip strangely, head behaves differently than tail

Steps to reproduce:

  1. Create Armature (Single Bone)
  2. Subdivide bone into 3 bones
  3. Move head of middle bone on its Y axis close to head of root bone
  4. Move head of last bone on its Y axis close to tail of last bone
  5. Rename root bone to Head, middle bone to Bone, last bone to Tail
  6. Unparent Tail bone from Bone bone
  7. Apply Bone Constraint StretchTo from Bone to Tail
  8. In "Bone"'s bone settings, check "Use Custom Handle References"
  9. Set In: to Head and Out: to Tail
  10. Rotate Head and Tail separately on axes perpendicular to bone (i.e. bone's Z or X axes), compare behaviour of Head and Tail.

When following Jason Schleifer's tutorial to set bendy bones up with these very nice and intuitive controls, I get strange instability/flipping even before the head bone reaches 90 degrees rotation. The tail bone however behaves as expected.
I'd expect both of them to behave identically, i.e. like the more stable tail bone.

Demo 1 (Click to play)
bendyBone.gif

Demo 2 (Click to play)
bendyBones2.gif

Demo 3
Moving Head off its rest position. Click to play.
bendyBones3.gif

Demo 4
Twisting Head and Tail respectively with Head off the rest position. Click to play.
bendybones4.gif

Two separate project files showing the same setup (one horizontally in world space, one vertically in world space):
bendybones_vertical.blend

bendybones.blend

Charles Wardlaw regarding this issue asked:
Are you aligning the root and tip quats to a common vector before extracting twist?

**System Information** Windows 10 NVIDIA GTX 980 Ti **Blender Version** Broken: blender-2.78.0-git.d0e7c7a-windows64 **Bendy Bones flip strangely, head behaves differently than tail** **Steps to reproduce:** 1. Create Armature (Single Bone) 2. Subdivide bone into 3 bones 3. Move head of middle bone on its Y axis close to head of root bone 4. Move head of last bone on its Y axis close to tail of last bone 5. Rename root bone to *Head*, middle bone to *Bone*, last bone to *Tail* 6. Unparent *Tail* bone from *Bone* bone 7. Apply Bone Constraint *StretchTo* from *Bone* to *Tail* 8. In "Bone"'s bone settings, check "Use Custom Handle References" 9. Set *In:* to *Head* and *Out:* to *Tail* 10. Rotate *Head* and *Tail* separately on axes perpendicular to bone (i.e. bone's Z or X axes), compare behaviour of *Head* and *Tail*. When following Jason Schleifer's tutorial to set bendy bones up with these very nice and intuitive controls, I get strange instability/flipping even before the head bone reaches 90 degrees rotation. The tail bone however behaves as expected. I'd expect both of them to behave identically, i.e. like the more stable tail bone. **Demo 1** (Click to play) ![bendyBone.gif](https://archive.blender.org/developer/F356979/bendyBone.gif) **Demo 2** (Click to play) ![bendyBones2.gif](https://archive.blender.org/developer/F356986/bendyBones2.gif) **Demo 3** Moving *Head* off its rest position. Click to play. ![bendyBones3.gif](https://archive.blender.org/developer/F356992/bendyBones3.gif) **Demo 4** Twisting *Head* and *Tail* respectively with *Head* off the rest position. Click to play. ![bendybones4.gif](https://archive.blender.org/developer/F356998/bendybones4.gif) Two separate project files showing the same setup (one horizontally in world space, one vertically in world space): [bendybones_vertical.blend](https://archive.blender.org/developer/F356977/bendybones_vertical.blend) [bendybones.blend](https://archive.blender.org/developer/F356976/bendybones.blend) Charles Wardlaw regarding this issue asked: *Are you aligning the root and tip quats to a common vector before extracting twist?*
Joshua Leung was assigned by Chris Offner 2016-09-10 09:31:57 +02:00
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @chrisoffner3d

Added subscriber: @chrisoffner3d
Author

Click the demo GIF images to show their full animation.
(The preview thumbnails are just static images it seems.)

Click the demo GIF images to show their full animation. (The preview thumbnails are just static images it seems.)

Added subscriber: @italic

Added subscriber: @italic

Added subscriber: @sindra1961

Added subscriber: @sindra1961

It did not occur if I excluded a check of Bone>Relations>Inherit Rotation of Bone.
Bone>Relations>Inherit Rotation: on
bendybones_vertical_on.png
Bone>Relations>Inherit Rotation: off
bendybones_vertical_off.png

It did not occur if I excluded a check of Bone>Relations>Inherit Rotation of Bone. Bone>Relations>Inherit Rotation: on ![bendybones_vertical_on.png](https://archive.blender.org/developer/F357702/bendybones_vertical_on.png) Bone>Relations>Inherit Rotation: off ![bendybones_vertical_off.png](https://archive.blender.org/developer/F357704/bendybones_vertical_off.png)
Member

The "good" news here is that this isn't a regression caused by the Bendy Bones changes. The custom handles feature only makes a few changes to the inputs of the calculations performed here (but not the way that the calculations responsible for doing anything of interest happen). This can be verified by disabling the custom handle refs, or by loading the files in old releases. However, this means that we still have to fix whatever it is that's causing this issue...


AFAICT, what's currently happening is that the code works by:

  1. Computing a "reference" rotation for the handle (using the handle position/offset, and "zero" roll). This uses the same code that's used for calculating the roll for bones when you create them - complete with all the quirks that can crop up there. You don't really want to mess around with this too much... what we've got now is a relatively good compromise between "mostly-working with predictable quirks" vs "random unpredictable failures". Reading up on that code does reveal however that there are some persistent numeric precision errors here that have cropped up several times in the past... (it's kindof a fickle "goldilocks zone" issue - too coarse and it gave errors, too fine and it gave errors)
  2. Taking the final transform of the next/prev handle bone and transforming that into the current bone's space
  3. Computing the delta transform between these two (i.e. how much the handle has "rotated")
  4. Compute a roll value by using atan2f(diff.zaxis.x, diff.zaxis.z) (remember, bones use the "y" axis the direction of the bone, so the x and z axes define the roll, and since z is often used as the "up" axis, it's a good reference)

My first thought was that it might be due to some discontinuities in atan2f() (though that doesn't entirely make sense as those are at 180 degrees, instead of near 90 degrees). So, as a first step, I tried normalising the vector being used for this calculation. However, this just made the problem worse, by now causing a whole lot more flipping than was already happening (i.e. now at +/- 86 degrees, 139 degrees, and 202 degrees).

I then added some debug code to try and get a bit more insight into what was going on. It turns out that the roll values were going from about -0.085/-7.056 degrees (roll1/roll2) at z=85 degrees, to 1.70/-22.709 at z=86 degrees, to -142.99/-161.53 at z=87 degrees!

After mulling over it more, I realised that the Stretch To constraint here might also be contributing somewhat to the problems here. This is because the Stretch To constraint basically rebuilds a transform matrix from scratch, and may therefore end up not putting everything back together in the right way. This lead to the discovery of a workaround:

On the Stretch To constraint, change the Plane to "Z"

This workaround however is only really useful if you're only going to rotate on the Z-Axis and not the X-Axis (as it ends up flipping which axis exhibits these artifacts). So, probably not that useful in an actual rig for animators to use, but it at least gives us some options.

So, still more investigation needed to figure out what exactly is the real source of this problem, and what the best fix to apply would be...

The "good" news here is that this isn't a regression caused by the Bendy Bones changes. The custom handles feature only makes a few changes to the inputs of the calculations performed here (but not the way that the calculations responsible for doing anything of interest happen). This can be verified by disabling the custom handle refs, or by loading the files in old releases. However, this means that we still have to fix whatever it is that's causing this issue... ------- AFAICT, what's currently happening is that the code works by: 1) Computing a "reference" rotation for the handle (using the handle position/offset, and "zero" roll). This uses the same code that's used for calculating the roll for bones when you create them - complete with all the quirks that can crop up there. You don't really want to mess around with this too much... what we've got now is a relatively good compromise between "mostly-working with predictable quirks" vs "random unpredictable failures". Reading up on that code does reveal however that there are some persistent numeric precision errors here that have cropped up several times in the past... (it's kindof a fickle "goldilocks zone" issue - too coarse and it gave errors, too fine and it gave errors) 2) Taking the final transform of the next/prev handle bone and transforming that into the current bone's space 3) Computing the delta transform between these two (i.e. how much the handle has "rotated") 4) Compute a roll value by using `atan2f(diff.zaxis.x, diff.zaxis.z)` (remember, bones use the "y" axis the direction of the bone, so the x and z axes define the roll, and since z is often used as the "up" axis, it's a good reference) ------------ My first thought was that it might be due to some discontinuities in `atan2f()` (though that doesn't entirely make sense as those are at 180 degrees, instead of near 90 degrees). So, as a first step, I tried normalising the vector being used for this calculation. However, this just made the problem worse, by now causing a whole lot more flipping than was already happening (i.e. now at +/- 86 degrees, 139 degrees, and 202 degrees). I then added some debug code to try and get a bit more insight into what was going on. It turns out that the roll values were going from about -0.085/-7.056 degrees (roll1/roll2) at z=85 degrees, to 1.70/-22.709 at z=86 degrees, to -142.99/-161.53 at z=87 degrees! After mulling over it more, I realised that the Stretch To constraint here might also be contributing somewhat to the problems here. This is because the Stretch To constraint basically rebuilds a transform matrix from scratch, and may therefore end up not putting everything back together in the right way. This lead to the **discovery of a workaround**: ``` On the Stretch To constraint, change the Plane to "Z" ``` This workaround however is only really useful if you're only going to rotate on the Z-Axis and not the X-Axis (as it ends up flipping which axis exhibits these artifacts). So, probably not that useful in an actual rig for animators to use, but it at least gives us some options. So, still more investigation needed to figure out what exactly is the real source of this problem, and what the best fix to apply would be...
Member

Added subscriber: @Mets

Added subscriber: @Mets
Joshua Leung was unassigned by Dalai Felinto 2019-12-23 16:37:00 +01:00

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sybren A. Stüvel self-assigned this 2020-01-30 14:52:58 +01:00

Unfortunately the Vimeo link is down, so I removed it from the description. The uploaded GIFs are still good.

I can reproduce this issue in 2.79, but can't reproduce this issue any more with Blender 2.82 alpha (87b551e836) so it appears the bug has been fixed already.

Please try the latest daily build: https://builder.blender.org/download/

If the problem persists, please let us know so we can re-open the report. Don't forget to mention the specific version you tested again.

Unfortunately the Vimeo link is down, so I removed it from the description. The uploaded GIFs are still good. I can reproduce this issue in 2.79, but can't reproduce this issue any more with Blender 2.82 alpha (87b551e8365954d03d1c27303b9776deefd4e4d3) so it appears the bug has been fixed already. Please try the latest daily build: https://builder.blender.org/download/ If the problem persists, please let us know so we can re-open the report. Don't forget to mention the specific version you tested again.
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
7 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#49315
No description provided.