diff options
author | Pushkar Joshi | 2012-04-18 09:47:26 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-18 09:47:26 -0700 |
commit | 38ae1158abe94f917dbf375e73e1a9f0f68a61e8 (patch) | |
tree | 8f18fbe86a257472202ff92250737ee541b7c9cf /js/tools | |
parent | 5bac19550ae74bb5561d1e1fbb55bdac8c5e3dd1 (diff) | |
download | ninja-38ae1158abe94f917dbf375e73e1a9f0f68a61e8.tar.gz |
allow drawing polylines in YZ and XZ planes as well as XY. In those planes, still have bug with shift when the bbox of the path grows (due to missing translation)
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/PenTool.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 8abb41ef..0e3bd15c 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -726,17 +726,23 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
726 | }, | 726 | }, |
727 | 727 | ||
728 | //prepare the selected subpath | 728 | //prepare the selected subpath |
729 | // convert the anchor points to stage world space (assume that's already the case if there is no subpath canvas) | ||
730 | // compute the center of the future canvas of this subpath in stage world space | 729 | // compute the center of the future canvas of this subpath in stage world space |
731 | // convert the anchor points from stage world to local space of the canvas | 730 | // compute local coordinates for the subpath (in case it does not have a canvas) |
732 | PrepareSelectedSubpathForRendering: { | 731 | PrepareSelectedSubpathForRendering: { |
733 | value: function(){ | 732 | value: function(){ |
734 | var i=0,d=0; | 733 | var i=0,d=0; |
735 | var currAnchor = null; | 734 | var currAnchor = null; |
736 | var xAdjustment = snapManager.getStageWidth()*0.5; | 735 | var xAdjustment = snapManager.getStageWidth()*0.5; |
737 | var yAdjustment = snapManager.getStageHeight()*0.5; | 736 | var yAdjustment = snapManager.getStageHeight()*0.5; |
737 | var swPos=null, swPrev=null, swNext=null; | ||
738 | var localPos=null, localPrev=null, localNext=null; | ||
738 | 739 | ||
739 | var numAnchors = this._selectedSubpath.getNumAnchors(); | 740 | var numAnchors = this._selectedSubpath.getNumAnchors(); |
741 | if (numAnchors<2){ | ||
742 | return;//nothing to do | ||
743 | } | ||
744 | this._selectedSubpath.makeDirty(); | ||
745 | |||
740 | var bboxMin=null, bboxMax=null; | 746 | var bboxMin=null, bboxMax=null; |
741 | if (this._selectedSubpathCanvas) { | 747 | if (this._selectedSubpathCanvas) { |
742 | //if there already is a subpath canvas, it means the anchor points are in local space | 748 | //if there already is a subpath canvas, it means the anchor points are in local space |
@@ -779,10 +785,24 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
779 | bboxMax = this._selectedSubpath.getBBoxMax(); | 785 | bboxMax = this._selectedSubpath.getBBoxMax(); |
780 | this._selectedSubpathCanvasCenter = VecUtils.vecInterpolate(3, bboxMin, bboxMax, 0.5); | 786 | this._selectedSubpathCanvasCenter = VecUtils.vecInterpolate(3, bboxMin, bboxMax, 0.5); |
781 | 787 | ||
782 | //todo convert the path points into local coordinates | 788 | //convert the path points into local coordinates by multiplying by the inverse of the plane mat |
783 | 789 | for (i=0;i<numAnchors;i++){ | |
790 | currAnchor = this._selectedSubpath.getAnchor(i); | ||
791 | swPos = [currAnchor.getPosX()-xAdjustment,currAnchor.getPosY()-yAdjustment,currAnchor.getPosZ()]; | ||
792 | swPrev = [currAnchor.getPrevX()-xAdjustment,currAnchor.getPrevY()-yAdjustment,currAnchor.getPrevZ()]; | ||
793 | swNext = [currAnchor.getNextX()-xAdjustment,currAnchor.getNextY()-yAdjustment,currAnchor.getNextZ()]; | ||
794 | var planeMatInv = glmat4.inverse(this._selectedSubpathPlaneMat, []); | ||
795 | localPos = MathUtils.transformAndDivideHomogeneousPoint(swPos, planeMatInv); | ||
796 | localPrev = MathUtils.transformAndDivideHomogeneousPoint(swPrev, planeMatInv); | ||
797 | localNext = MathUtils.transformAndDivideHomogeneousPoint(swNext, planeMatInv); | ||
798 | currAnchor.setPos(localPos[0],localPos[1],localPos[2]); | ||
799 | currAnchor.setPrevPos(localPrev[0],localPrev[1],localPrev[2]); | ||
800 | currAnchor.setNextPos(localNext[0],localNext[1],localNext[2]); | ||
801 | } | ||
784 | } | 802 | } |
785 | 803 | ||
804 | //todo MISSING: sandwich the planeMat between with the translation to the previous center of the canvas in local space and its inverse | ||
805 | |||
786 | this._selectedSubpath.makeDirty(); | 806 | this._selectedSubpath.makeDirty(); |
787 | this._selectedSubpath.createSamples(false); | 807 | this._selectedSubpath.createSamples(false); |
788 | this._selectedSubpath.offsetPerBBoxMin(); | 808 | this._selectedSubpath.offsetPerBBoxMin(); |