X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Factions%2FTranslateInlineAction.java;h=1bb2874c5b0031feb6ab8d77efd312f2370efdf2;hb=53d55c24c779745f188bdb18d32f71d20acb61b2;hp=23096f7eabfc96e40568bef31e571ffca5405d7f;hpb=84132a1d750c45f9161afbd58b78572964e50d26;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java index 23096f7e..1bb2874c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java @@ -46,23 +46,29 @@ public class TranslateInlineAction extends TranslateAction{ setEnabled(false); return; } - if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed()) + if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed() && prev.getPrevious() != null) prev = prev.getPrevious(); - if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed()) { + if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed() && next.getNext() != null) { next = next.getNext(); } Point3d ns = new Point3d(); Point3d ne = new Point3d(); Point3d ps = new Point3d(); Point3d pe = new Point3d(); - next.getControlPointEnds(ns, ne); - prev.getControlPointEnds(ps, pe); + next.getEnds(ns, ne); + prev.getEnds(ps, pe); dir = comp.getControlPoint().getPathLegDirection(Direction.NEXT); dir.normalize(); // We may have offsets in the path leg, hence we have to project the coordinates. Vector3d wp = node.getWorldPosition(); - s = MathTools.closestPointOnStraight(pe, wp, dir); - e = MathTools.closestPointOnStraight(ns, wp, dir); + if (prev.getControlPoint().isVariableLength()) + s = MathTools.closestPointOnStraight(ps, wp, dir); + else + s = MathTools.closestPointOnStraight(pe, wp, dir); + if (next.getControlPoint().isVariableLength()) + e = MathTools.closestPointOnStraight(ne, wp, dir); + else + e = MathTools.closestPointOnStraight(ns, wp, dir); // Remove component's own space from end points to get actual movement range double l = comp.getControlPoint().getInlineLength(); Vector3d ld = new Vector3d(dir); @@ -126,13 +132,13 @@ public class TranslateInlineAction extends TranslateAction{ Vector3d p = node.getWorldPosition(); Vector3d i1 = new Vector3d(); - Vector3d i2 = new Vector3d(); - - double mu[] = new double[2]; - MathTools.intersectStraightStraight( p, dir,ray.pos, ray.dir, i2, i1,mu); - - Vector3d t = MathTools.closestPointOnEdge(i1, s, e); - return t; + Vector3d i2 = new Vector3d(); + + double mu[] = new double[2]; + MathTools.intersectStraightStraight( p, dir,ray.pos, ray.dir, i2, i1,mu); + + Vector3d t = MathTools.closestPointOnEdge(i1, s, e); + return t; }