From ada488781ff815a827e7f5903f2c55773e3be0f3 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 1 Feb 2012 12:16:11 -0800 Subject: when selecting anchor points, first check if the selected anchor position is close enough --- js/helper-classes/RDGE/GLSubpath.js | 168 +++++++++++++++++++++--------------- 1 file changed, 98 insertions(+), 70 deletions(-) diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index c4ca1b20..9b6ae917 100644 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js @@ -433,17 +433,111 @@ GLSubpath.prototype.pickAnchor = function (pickX, pickY, pickZ, radius) { var retCode = this.SEL_NONE; var radSq = radius * radius; var minDistance = Infinity; - for (var i = 0; i < numAnchors; i++) { - var distSq = this._Anchors[i].getDistanceSq(pickX, pickY, pickZ); + //check if the clicked location is close to the currently selected anchor position + if (this._selectedAnchorIndex>=0 && this._selectedAnchorIndex=0 && this._selectedAnchorIndex=0 && selAnchorIndex === -1) { + var distSq = this._Anchors[this._selectedAnchorIndex].getPrevDistanceSq(pickX, pickY, pickZ); + if (distSq < minDistance && distSq < radSq){ + selAnchorIndex = this._selectedAnchorIndex; + minDistance = distSq; + retCode = retCode | this.SEL_PREV; + } else { + //check the next for this anchor point + distSq = this._Anchors[this._selectedAnchorIndex].getNextDistanceSq(pickX, pickY, pickZ); + if (distSq=0 && selAnchorIndex === -1) { - var distSq = this._Anchors[this._selectedAnchorIndex].getPrevDistanceSq(pickX, pickY, pickZ); - if (distSq < minDistance && distSq < radSq){ - selAnchorIndex = this._selectedAnchorIndex; - minDistance = distSq; - retCode = retCode | this.SEL_PREV; - } else { - //check the next for this anchor point - distSq = this._Anchors[this._selectedAnchorIndex].getNextDistanceSq(pickX, pickY, pickZ); - if (distSq