Don't draw shapes/sprites with zero scaling factor.
This commit is contained in:
parent
05a85abce8
commit
cc25c3c8dc
@ -297,7 +297,11 @@ class AFPRenderer(VerboseOutput):
|
||||
transform = parent_transform.multiply(renderable.tag.transform or Matrix.identity())
|
||||
|
||||
# Calculate the inverse so we can map canvas space back to texture space.
|
||||
try:
|
||||
inverse = transform.inverse()
|
||||
except ZeroDivisionError:
|
||||
print(f"WARNING: Transform Matrix {transform} has zero scaling factor, making it non-invertible!")
|
||||
return
|
||||
|
||||
# Render individual shapes if this is a sprite.
|
||||
if renderable.tag.source_tag_id in self.__registered_sprites:
|
||||
|
@ -123,6 +123,7 @@ class Matrix:
|
||||
def inverse(self) -> "Matrix":
|
||||
denom = (self.a * self.d - self.b * self.c)
|
||||
|
||||
try:
|
||||
return Matrix(
|
||||
a=self.d / denom,
|
||||
b=-self.b / denom,
|
||||
@ -131,6 +132,10 @@ class Matrix:
|
||||
tx=(self.c * self.ty - self.d * self.tx) / denom,
|
||||
ty=-(self.a * self.ty - self.b * self.tx) / denom,
|
||||
)
|
||||
except ZeroDivisionError:
|
||||
pass
|
||||
|
||||
raise ZeroDivisionError(f"Matrix({self}) cannot be inverted!")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"a: {round(self.a, 5)}, b: {round(self.b, 5)}, c: {round(self.c, 5)}, d: {round(self.d, 5)}, tx: {round(self.tx, 5)}, ty: {round(self.ty, 5)}"
|
||||
|
Loading…
Reference in New Issue
Block a user