Explorar o código

Handle empty cases in Sphere.union (#24701)

Garrett Johnson %!s(int64=2) %!d(string=hai) anos
pai
achega
341b2e863a
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      src/math/Sphere.js

+ 12 - 0
src/math/Sphere.js

@@ -195,6 +195,18 @@ class Sphere {
 
 	union( sphere ) {
 
+		// handle empty sphere cases
+		if ( sphere.isEmpty() ) {
+
+			return;
+
+		} else if ( this.isEmpty() ) {
+
+			this.copy( sphere );
+			return;
+
+		}
+
 		// from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769
 
 		// To enclose another sphere into this sphere, we only need to enclose two points: