]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Prevent Tube shape failing with provided tangents. 18/3418/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 29 Oct 2019 12:01:58 +0000 (14:01 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 29 Oct 2019 12:01:58 +0000 (14:01 +0200)
gitlab #40

Change-Id: Ifd0977dc38885e5fbc6d5470dba6f16fd5a53a5b

org.simantics.g3d/src/org/simantics/g3d/shape/Tube.java

index 6b1bf618b7533f8183aed58c4210b27278b4f790..a3c9dd192f085d201a76c6c9536074bb0cb3e422 100644 (file)
@@ -69,11 +69,13 @@ public class Tube {
                
                Vector3d t = new Vector3d();
                
-               for (int i = 0; i < vertices.size() - 1; i++) {
-                       t.set(vertices.get(i+1));
-                       t.sub(vertices.get(i));
-                       if (t.lengthSquared() < 0.0000001)
-                               throw new IllegalArgumentException("vertices at index " + i + " are too close to each other");
+               if (tangents == null) {
+               for (int i = 0; i < vertices.size() - 1; i++) {
+                       t.set(vertices.get(i+1));
+                       t.sub(vertices.get(i));
+                       if (t.lengthSquared() < 0.0000001)
+                               throw new IllegalArgumentException("vertices at index " + i + " are too close to each other");
+               }
                }
                
                int vcount = vertices.size()*resolution;