From 7fa2a1071ebd2b1df8af423a44ac50601bcbb268 Mon Sep 17 00:00:00 2001 From: SebastianWitt Date: Fri, 13 Oct 2023 23:05:15 +0200 Subject: [PATCH] Fix divide by zero error Lightmap Unwrap & small N-gons Ref: !113716 --- scripts/startup/bl_operators/uvcalc_lightmap.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/startup/bl_operators/uvcalc_lightmap.py b/scripts/startup/bl_operators/uvcalc_lightmap.py index a24d8d5320c..b232e48453a 100644 --- a/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -113,9 +113,15 @@ class prettyface: # ngons work different, we store projected result # in UVs to avoid having to re-project later. - for i, co in enumerate(cos_2d): - self.uv[i][:] = ((co.x - xmin) / xspan, - (co.y - ymin) / yspan) + if xspan < 0.0000001 or yspan < 0.0000001: + for i in range(len(cos_2d)): + self.uv[i][:] = (0.0, 0.0) + else: + for i, co in enumerate(cos_2d): + self.uv[i][:] = ( + (co.x - xmin) / xspan, + (co.y - ymin) / yspan, + ) self.children = []