Browse Source

Fix normals computation at the 'seam' of smoothed sphere and cylinder shapes

(cherry picked from commit 509e03c82133ef55e33da25f13786d0b966945b6)
MythTitans 3 years ago
parent
commit
5bd75bccae
1 changed files with 7 additions and 0 deletions
  1. 7 0
      modules/csg/csg_shape.cpp

+ 7 - 0
modules/csg/csg_shape.cpp

@@ -973,6 +973,10 @@ CSGBrush *CSGSphere::_build_brush() {
 				double u0 = double(j) / radial_segments;
 				double u0 = double(j) / radial_segments;
 
 
 				double longitude1 = longitude_step * (j + 1);
 				double longitude1 = longitude_step * (j + 1);
+				if (j == radial_segments - 1) {
+					longitude1 = 0;
+				}
+
 				double x1 = Math::sin(longitude1);
 				double x1 = Math::sin(longitude1);
 				double z1 = Math::cos(longitude1);
 				double z1 = Math::cos(longitude1);
 				double u1 = double(j + 1) / radial_segments;
 				double u1 = double(j + 1) / radial_segments;
@@ -1328,6 +1332,9 @@ CSGBrush *CSGCylinder::_build_brush() {
 			for (int i = 0; i < sides; i++) {
 			for (int i = 0; i < sides; i++) {
 				float inc = float(i) / sides;
 				float inc = float(i) / sides;
 				float inc_n = float((i + 1)) / sides;
 				float inc_n = float((i + 1)) / sides;
+				if (i == sides - 1) {
+					inc_n = 0;
+				}
 
 
 				float ang = inc * Math_PI * 2.0;
 				float ang = inc * Math_PI * 2.0;
 				float ang_n = inc_n * Math_PI * 2.0;
 				float ang_n = inc_n * Math_PI * 2.0;