From 8c837a9e50c29e66bdf5bd7ea2fd15b1a7d5d598 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 29 Apr 2019 15:12:34 -0400
Subject: [PATCH] Use separators.

---
 BoundaryRep.java |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/BoundaryRep.java b/BoundaryRep.java
index 05b3429..14a7921 100644
--- a/BoundaryRep.java
+++ b/BoundaryRep.java
@@ -3247,12 +3247,21 @@
                     max = ay;
                 }
                 
+                if (max == 0)
+                {
+                        uvmap[i2] = 0.5f;
+                        uvmap[i2+1] = 0.5f;
+                        continue;
+                }
+                
                 x /= max;
                 y /= max;
 
                 double angle = Math.acos(Math.abs(z*2));
                 
                 double k = angle / Math.PI * 2;
+                
+                assert(k >= 0);
                 
                 // k == 0 => uv = 0 (center)
                 // k == 1 => uv = -1,1 (border)
@@ -3268,7 +3277,8 @@
                 t = Math.pow(t, 3);
                 
                 // Interpolate between k/length2 (center) and k (border)
-                k = k / length2 * (1 - t) + k * t;
+                if (length2 > 0)
+                        k *= (1 - t) / length2 + t;
                 
                 double u = k*x;
                 double v = k*y;

--
Gitblit v1.6.2