X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2Fcontrolpoint%2FPipingRules.java;h=50b22571874c46482359ec8b2472e4ce7673f28f;hb=c51024ff285310c85d0d5ed56a8932216e841dec;hp=2c5f7427c7143430beb56edb57583ee31fbafbbb;hpb=8334f50b69e1cdba45ed26d49f193d26d728b1fc;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java index 2c5f7427..50b22571 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java @@ -280,6 +280,9 @@ public class PipingRules { scp.insert(pcp1, pcp2); scp.setWorldPosition(pos); + Vector3d dir = new Vector3d(); + dir.sub(pcp2.getWorldPosition(), pcp1.getWorldPosition()); + updateControlPointOrientation(scp, dir); scp.setLength(length); validate(scp.getPipeRun()); return scp; @@ -1200,14 +1203,19 @@ public class PipingRules { PipeControlPoint dcp2 = u.end; Point3d position1 = new Point3d(u.startPoint); Point3d position2 = new Point3d(u.endPoint); + + Vector3d dir = new Vector3d(), offset = new Vector3d(); + calculateDirectedOffset(new Vector3d(position1), new Vector3d(position2), u.start, u.list, u.end, dir, offset); + Point3d position1offset = new Point3d(position1); - position1offset.sub(u.offset); + position1offset.add(offset); Point3d position2offset = new Point3d(position2); - position2offset.add(u.offset); + position2offset.sub(offset); Vector3d dir1 = direction(dcp1, Direction.NEXT); Vector3d dir2 = direction(dcp2, Direction.PREVIOUS); - Vector3d p1 = MathTools.closestPointOnStraight(position1offset, position2, dir2); - Vector3d p2 = MathTools.closestPointOnStraight(position2offset, position1, dir1); + + Vector3d p1 = MathTools.closestPointOnStraight(position1, position2offset, dir2); + Vector3d p2 = MathTools.closestPointOnStraight(position2, position1offset, dir1); double d1 = position1.distance(new Point3d(p1)); double d2 = position2.distance(new Point3d(p2)); @@ -1247,9 +1255,9 @@ public class PipingRules { p1.add(v); if (!u.reversed) - p2 = MathTools.closestPointOnStraight(new Point3d(p1), position2, dir2); + p2 = MathTools.closestPointOnStraight(new Point3d(p1), position2offset, dir2); else - p2 = MathTools.closestPointOnStraight(new Point3d(p1), position1, dir1); + p2 = MathTools.closestPointOnStraight(new Point3d(p1), position1offset, dir1); // By default, the elbows are placed next to each other, by using 90 deg angles. // If the distance between elbows is not enough, we must move the other elbow (and create more shallow angle elbows)