]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fix cause of endless loop in overlap resolution 94/3894/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Thu, 20 Feb 2020 16:27:26 +0000 (18:27 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Thu, 20 Feb 2020 16:31:53 +0000 (18:31 +0200)
gitlab #86

Change-Id: I256a7c12e168410ef2ff3be4c08a77208448734b

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java

index cb8200725df456eeca3ab738089148ed42f7cd4a..2c77c2bfbc9f24f1b9bb5fe89ca37dcb3ca894c1 100644 (file)
@@ -759,7 +759,7 @@ public class PipingRules {
                        continue;
                    double curr = gapObj.d;
                    int d = 1;
-                   while (curr < -MIN_INLINE_LENGTH) {
+                   while (d < gaps.size() && curr < -MIN_INLINE_LENGTH) {
                        GapObj next = i+d >= 0 ? gaps.get(i+d) : null;
                     GapObj prev = i-d >= 0 ? gaps.get(i-d) : null;
                        if (next != null && next.gap == Gap.SPACE) {
@@ -778,7 +778,7 @@ public class PipingRules {
                                pcp.first.setWorldPosition(p);
                            }
                        }
-                       if (curr < -MIN_INLINE_LENGTH && prev != null && prev.gap == Gap.SPACE) {
+                       else if (prev != null && prev.gap == Gap.SPACE) {
                            double move = Math.min(-curr, prev.d);
                         curr+= move;
                         prev.d -= move;
@@ -794,6 +794,9 @@ public class PipingRules {
                             pcp.first.setWorldPosition(p);
                         }
                        }
+                       else {
+                           d++;
+                       }
                    }
                }
            } else {