From: Marko Luukkainen Date: Tue, 29 Oct 2019 12:01:58 +0000 (+0200) Subject: Prevent Tube shape failing with provided tangents. X-Git-Tag: v1.43.0~162^2~1 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F3418%2F1;p=simantics%2F3d.git Prevent Tube shape failing with provided tangents. gitlab #40 Change-Id: Ifd0977dc38885e5fbc6d5470dba6f16fd5a53a5b --- diff --git a/org.simantics.g3d/src/org/simantics/g3d/shape/Tube.java b/org.simantics.g3d/src/org/simantics/g3d/shape/Tube.java index 6b1bf618..a3c9dd19 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/shape/Tube.java +++ b/org.simantics.g3d/src/org/simantics/g3d/shape/Tube.java @@ -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;