Fix T102396: ValueError: matrix does not have an inverse

Refactor the matrix stack in a way that does not require matrix
inversion. Basically, store the state of the final transform in
the stack.

Technically this makes regression test to fail with Blender Icons,
but the new code gives more correct icons. So the reference image
is to simply be regenerated.
This commit is contained in:
Sergey Sharybin 2022-11-10 11:07:05 +01:00
parent 1ca94b05aa
commit a28c3f9cc0
Notes: blender-bot 2023-02-14 18:12:48 +01:00
Referenced by issue #102396, import_curve.svg() ValueError: matrix does not have an inverse
1 changed files with 6 additions and 5 deletions

View File

@ -964,16 +964,17 @@ class SVGGeometry:
Push transformation matrix
"""
self._context['transform'].append(matrix)
self._context['matrix'] = self._context['matrix'] @ matrix
current_matrix = self._context['matrix']
self._context['matrix_stack'].append(current_matrix)
self._context['matrix'] = current_matrix @ matrix
def _popMatrix(self):
"""
Pop transformation matrix
"""
matrix = self._context['transform'].pop()
self._context['matrix'] = self._context['matrix'] @ matrix.inverted()
old_matrix = self._context['matrix_stack'].pop()
self._context['matrix'] = old_matrix
def _pushStyle(self, style):
"""
@ -1822,9 +1823,9 @@ class SVGLoader(SVGGeometryContainer):
rect = (0, 0)
self._context = {'defines': {},
'transform': [],
'rects': [rect],
'rect': rect,
'matrix_stack': [],
'matrix': m,
'materials': {},
'styles': [None],