From c49befa43288730538d82f709b05dfd08c40e562 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov <angavrilov@gmail.com>
Date: Mon, 11 Jul 2022 18:36:55 +0300
Subject: [PATCH] Rigify: fix T95864 - inconsistent bone roll in the wolf
 metarig.

Edit mode represents bone orientation via their head and tail
locations, plus a roll value. This math has a singularity in
the -Y direction, resulting in instability and discontinuity
for bones exactly aligned to the Y axis (the tail flips the
deform bones, so +Y is also bad).

The only reliable way to avoid problems is to un-align the
bones via very small offsets in the Z direction.
---
 rigify/metarigs/Animals/wolf.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/rigify/metarigs/Animals/wolf.py b/rigify/metarigs/Animals/wolf.py
index a2ade9104..87d74c87b 100644
--- a/rigify/metarigs/Animals/wolf.py
+++ b/rigify/metarigs/Animals/wolf.py
@@ -169,7 +169,7 @@ def create(obj):
 
     bone = arm.edit_bones.new('spine.004')
     bone.head = 0.0000, 0.4085, 0.7928
-    bone.tail = 0.0000, 0.2416, 0.7928
+    bone.tail = 0.0000, 0.2416, 0.7927
     bone.roll = 0.0000
     bone.use_connect = False
     bones['spine.004'] = bone.name
@@ -181,7 +181,7 @@ def create(obj):
     bone.parent = arm.edit_bones[bones['spine.004']]
     bones['spine.003'] = bone.name
     bone = arm.edit_bones.new('spine.005')
-    bone.head = 0.0000, 0.2416, 0.7928
+    bone.head = 0.0000, 0.2416, 0.7927
     bone.tail = 0.0000, 0.1202, 0.7773
     bone.roll = 0.0000
     bone.use_connect = True
@@ -189,14 +189,14 @@ def create(obj):
     bones['spine.005'] = bone.name
     bone = arm.edit_bones.new('spine.002')
     bone.head = 0.0000, 0.5555, 0.7567
-    bone.tail = 0.0000, 0.7816, 0.7412
+    bone.tail = 0.0000, 0.7816, 0.7411
     bone.roll = 0.0000
     bone.use_connect = True
     bone.parent = arm.edit_bones[bones['spine.003']]
     bones['spine.002'] = bone.name
     bone = arm.edit_bones.new('spine.006')
     bone.head = 0.0000, 0.1202, 0.7773
-    bone.tail = 0.0000, 0.0096, 0.7773
+    bone.tail = 0.0000, 0.0096, 0.7772
     bone.roll = 0.0000
     bone.use_connect = True
     bone.parent = arm.edit_bones[bones['spine.005']]
@@ -230,14 +230,14 @@ def create(obj):
     bone.parent = arm.edit_bones[bones['spine.005']]
     bones['thigh.R'] = bone.name
     bone = arm.edit_bones.new('spine.001')
-    bone.head = 0.0000, 0.7816, 0.7412
+    bone.head = 0.0000, 0.7816, 0.7411
     bone.tail = 0.0000, 0.9624, 0.7412
     bone.roll = 0.0000
     bone.use_connect = True
     bone.parent = arm.edit_bones[bones['spine.002']]
     bones['spine.001'] = bone.name
     bone = arm.edit_bones.new('spine.007')
-    bone.head = 0.0000, 0.0096, 0.7773
+    bone.head = 0.0000, 0.0096, 0.7772
     bone.tail = 0.0000, -0.0980, 0.7945
     bone.roll = 0.0000
     bone.use_connect = True
-- 
GitLab