From: Marko Luukkainen Date: Mon, 5 Aug 2019 12:32:55 +0000 (+0300) Subject: Support for reversible in-line components X-Git-Tag: v1.43.0~238 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F59%2F3059%2F1;p=simantics%2F3d.git Support for reversible in-line components gitlab #13 Change-Id: I2348320a5bba2b8d86b7a0bcc118d85f81023186 --- diff --git a/org.simantics.plant3d.ontology/graph/plant3d.pgraph b/org.simantics.plant3d.ontology/graph/plant3d.pgraph index d7dce09e..46a6a34b 100644 --- a/org.simantics.plant3d.ontology/graph/plant3d.pgraph +++ b/org.simantics.plant3d.ontology/graph/plant3d.pgraph @@ -69,7 +69,9 @@ P3D.SizeChangeComponent MathTools.NEAR_ZERO) + dir.normalize(); + Quat4d q = getControlPointOrientationQuat(dir, angle); + if (reversed) { + Quat4d q2 = new Quat4d(); + q2.set(new AxisAngle4d(MathTools.Y_AXIS, Math.PI)); + q.mulInverse(q2); + } + return q; + } else { + Vector3d dir = getPathLegDirection(Direction.PREVIOUS); + dir.negate(); + if (dir.lengthSquared() > MathTools.NEAR_ZERO) + dir.normalize(); + return getControlPointOrientationQuat(dir, turnAxis, angle); + } + } - public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) { + public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) { if (dir.lengthSquared() < MathTools.NEAR_ZERO) return MathTools.getIdentityQuat(); 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 ea8a512b..3fc04881 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 @@ -1476,8 +1476,11 @@ public class PipingRules { double angle = 0.0; if (angleO != null) angle = angleO; - - Quat4d q = pcp.getControlPointOrientationQuat(angle); + Boolean reversedO = pcp.getReversed(); + boolean reversed = false; + if (reversedO != null) + reversed = reversedO; + Quat4d q = pcp.getControlPointOrientationQuat(angle, reversed); pcp.setWorldOrientation(q); }