From 517b6a896ae890717bdc55931c05b00b3e578da4 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Tue, 29 Oct 2019 14:01:58 +0200 Subject: [PATCH] Prevent Tube shape failing with provided tangents. gitlab #40 Change-Id: Ifd0977dc38885e5fbc6d5470dba6f16fd5a53a5b --- .../src/org/simantics/g3d/shape/Tube.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; -- 2.47.1