Fix T95648: Rigify: use eye axis in computing the eyelid tracking weights.

If the coordinate space of the eyelids is computed only from the
eye rotation center points and corners, it fails if the center is
close or in front of the line connecting the corners.

Instead, compute the space based on the main eye axis plus the line
between corners, which only slightly changes the result compared to
the previous method, but is more robust.
This commit is contained in:
Alexander Gavrilov 2022-02-11 11:40:07 +03:00
parent bfec050a97
commit df2296e154
Notes: blender-bot 2023-02-14 18:24:52 +01:00
Referenced by issue #95648, Issues with lower lids of the updated face rig (Occurs at times and other times it does not)
1 changed files with 3 additions and 6 deletions

View File

@ -92,13 +92,10 @@ class Rig(BaseSkinRig):
if len(self.eye_corner_nodes) != 2:
self.raise_error('Expected 2 eye corners, but found {}', len(self.eye_corner_nodes))
# Build a coordinate space with XY plane based on center and two corners,
# and Y axis oriented as close to the eye axis as possible.
vecs = [(node.point - self.center).normalized() for node in self.eye_corner_nodes]
normal = vecs[0].cross(vecs[1])
space_axis = self.axis - self.axis.project(normal)
# Build a coordinate space with XY plane based on eye axis and two corners
corner_axis = self.eye_corner_nodes[1].point - self.eye_corner_nodes[0].point
matrix = matrix_from_axis_pair(space_axis, normal, 'z').to_4x4()
matrix = matrix_from_axis_pair(self.axis, corner_axis, 'x').to_4x4()
matrix.translation = self.center
self.eye_corner_matrix = matrix.inverted()