aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/geom/sub-path.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js
index 62937461..7e11bb33 100755
--- a/js/lib/geom/sub-path.js
+++ b/js/lib/geom/sub-path.js
@@ -413,19 +413,21 @@ GLSubpath.prototype._checkIntersectionWithSamples = function(startIndex, endInde
413 //will assume that the BBox test is performed outside this function 413 //will assume that the BBox test is performed outside this function
414 if (endIndex<startIndex){ 414 if (endIndex<startIndex){
415 //go from startIndex to the end of the samples 415 //go from startIndex to the end of the samples
416 endIndex = this._Samples.length; 416 endIndex = this._Samples.length-1;
417 } 417 }
418 for (var i=startIndex; i<endIndex-1; i++){ 418 var retParam = null;
419 for (var i=startIndex; i<endIndex; i++){
419 var seg0 = this._Samples[i].slice(0); 420 var seg0 = this._Samples[i].slice(0);
420 var j=i+1; 421 var j=i+1;
421 var seg1 = this._Samples[j].slice(0); 422 var seg1 = this._Samples[j].slice(0);
422 var distToSegment = MathUtils.distPointToSegment(point, seg0, seg1); 423 var distToSegment = MathUtils.distPointToSegment(point, seg0, seg1);
423 if (distToSegment<=radius){ 424 if (distToSegment<=radius){
424 var paramDistance = MathUtils.paramPointProjectionOnSegment(point, seg0, seg1); //TODO Optimize! this function was called in distPointToSegment above 425 var paramDistance = MathUtils.paramPointProjectionOnSegment(point, seg0, seg1); //TODO Optimize! this function was called in distPointToSegment above
425 return this._sampleParam[i] + (this._sampleParam[j] - this._sampleParam[i])*paramDistance; 426 retParam = this._sampleParam[i] + (this._sampleParam[j] - this._sampleParam[i])*paramDistance;
427 break;
426 } 428 }
427 } 429 }
428 return null; 430 return retParam;
429}; 431};
430 432
431GLSubpath.prototype._checkIntersection = function(controlPts, beginParam, endParam, point, radius) { 433GLSubpath.prototype._checkIntersection = function(controlPts, beginParam, endParam, point, radius) {
@@ -589,6 +591,10 @@ GLSubpath.prototype.pickPath = function (pickX, pickY, pickZ, radius, testOnly)
589 selAnchorIndex = anchorAndRetCode[0]; 591 selAnchorIndex = anchorAndRetCode[0];
590 retCode = anchorAndRetCode[1]; 592 retCode = anchorAndRetCode[1];
591 593
594 if (retCode!== this.SEL_NONE){
595 retCode = retCode | this.SEL_PATH; //ensure that path is also selected if anything else is selected
596 }
597
592 //if the location is not close any of the anchors, check if it is close to the curve itself 598 //if the location is not close any of the anchors, check if it is close to the curve itself
593 if (selAnchorIndex===-1) { 599 if (selAnchorIndex===-1) {
594 //first check if the input location is within the bounding box 600 //first check if the input location is within the bounding box
@@ -603,9 +609,11 @@ GLSubpath.prototype.pickPath = function (pickX, pickY, pickZ, radius, testOnly)
603 [this._Anchors[nextIndex].getPosX(),this._Anchors[nextIndex].getPosY(),this._Anchors[nextIndex].getPosZ()]]; 609 [this._Anchors[nextIndex].getPosX(),this._Anchors[nextIndex].getPosY(),this._Anchors[nextIndex].getPosZ()]];
604 var point = [pickX, pickY, pickZ]; 610 var point = [pickX, pickY, pickZ];
605 if (this._isWithinGivenBoundingBox(point, controlPoints, radius)) { 611 if (this._isWithinGivenBoundingBox(point, controlPoints, radius)) {
612 //var intersectParam = this._checkIntersection(controlPoints, 0.0, 1.0, point, radius);
606 var intersectParam = this._checkIntersectionWithSamples(this._anchorSampleIndex[i], this._anchorSampleIndex[nextIndex], point, radius); 613 var intersectParam = this._checkIntersectionWithSamples(this._anchorSampleIndex[i], this._anchorSampleIndex[nextIndex], point, radius);
607 if (intersectParam){ 614 if (intersectParam!==null){
608 selAnchorIndex=i; 615 selAnchorIndex=i;
616 retCode = retCode | this.SEL_PATH;
609 retParam = intersectParam-i; //make the retParam go from 0 to 1 617 retParam = intersectParam-i; //make the retParam go from 0 to 1
610 break; 618 break;
611 } 619 }
@@ -614,9 +622,6 @@ GLSubpath.prototype.pickPath = function (pickX, pickY, pickZ, radius, testOnly)
614 }//if is within bbox 622 }//if is within bbox
615 } 623 }
616 624
617 if (retCode!== this.SEL_NONE)
618 retCode = retCode | this.SEL_PATH; //ensure that path is also selected if anything else is selected
619
620 if (!testOnly){ 625 if (!testOnly){
621 this._selectMode = retCode; 626 this._selectMode = retCode;
622 this._selectedAnchorIndex = selAnchorIndex; 627 this._selectedAnchorIndex = selAnchorIndex;