]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java
Simplified free ended variable length component update
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / RoutePipeAction.java
index 17455a328b0797cef34dc296d560aff852090ea7..509ab38cce6e9120f94a1e732768b4af0f993e64 100644 (file)
@@ -1061,16 +1061,19 @@ public class RoutePipeAction extends vtkSwtAction {
             * Updates tool graphics for current point 
             */
            private void updateCurrentPoint() {
-//             PipeComponentProvider.createStraightEdges(pipeShapes.get(pipeShapes.size() - 1), controlPoints.get(controlPoints.size() - 1), currentPoint, pipeDiameter*0.5);
                InlineComponent straight = (InlineComponent)added.get(added.size()-1);
-               // FIXME : does not take account space the the previous elbow reserves. 
+               // TODO: the inline length is from previous update step. 
+               double l = straight.getPrevious().getControlPoint().getInlineLength();
                Vector3d v = new Vector3d();
                v.sub(currentPosition, previousPosition);
                double length = v.length();
-               v.scale(0.5);
-               v.add(previousPosition);
-               straight.getControlPoint().setWorldPosition(v);
-               straight.getControlPoint().setLength(length);
+               if (length > MathTools.NEAR_ZERO) {
+               v.scale(1.0/length);
+               v.scale(0.5*(length+l));
+               v.add(previousPosition);
+               straight.getControlPoint().setWorldPosition(v);
+               straight.getControlPoint().setLength(length);
+               }
                try {
                                PipingRules.positionUpdate(straight.getControlPoint(),false);
                        } catch (Exception e) {