}
p1 = dcp.getWorldPosition();
- // FIXME: calculate position of the elbows properly.
+ Vector3d v = new Vector3d();
if (!u.reversed)
- p1.add(dir1);
+ v.set(dir1);
else
- p1.add(dir2);
+ v.set(dir2);
+
+ // Reserve space for 90 deg elbow
+ double off = dcp1.getPipeRun().getTurnRadius();
+ v.scale(off);
+ p1.add(v);
if (!u.reversed)
p2 = MathTools.closestPointOnStraight(new Point3d(p1), position2, dir2);
else
p2 = MathTools.closestPointOnStraight(new Point3d(p1), position1, 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)
+ if (MathTools.distance(p1, p2) < off*2.05) {
+ p2.add(v);
+ }
PipeControlPoint tcp1 = insertElbow(dcp, next, p1);
PipeControlPoint tcp2 = insertElbow(tcp1, next, p2);