From a17c6e5325246d2147644a615adee68ab186c4e3 Mon Sep 17 00:00:00 2001 From: MythTitans Date: Fri, 11 Mar 2022 00:16:30 +0100 Subject: [PATCH] Fix normals computation at the 'seam' of smoothed torus shape (cherry picked from commit 8bcbaff41119b254c34938a632f787a8049e88c6) --- modules/csg/csg_shape.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index a0ff52947f6..2b2669dd3ec 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1597,6 +1597,9 @@ CSGBrush *CSGTorus::_build_brush() { for (int i = 0; i < sides; i++) { float inci = float(i) / sides; float inci_n = float((i + 1)) / sides; + if (i == sides - 1) { + inci_n = 0; + } float angi = inci * Math_PI * 2.0; float angi_n = inci_n * Math_PI * 2.0; @@ -1607,6 +1610,9 @@ CSGBrush *CSGTorus::_build_brush() { for (int j = 0; j < ring_sides; j++) { float incj = float(j) / ring_sides; float incj_n = float((j + 1)) / ring_sides; + if (j == ring_sides - 1) { + incj_n = 0; + } float angj = incj * Math_PI * 2.0; float angj_n = incj_n * Math_PI * 2.0;