aboutsummaryrefslogtreecommitdiff
path: root/js/tools/modifier-tool-base.js
diff options
context:
space:
mode:
authorhwc4872012-04-02 15:40:25 -0700
committerhwc4872012-04-02 15:40:25 -0700
commitdc9650af5760b1f93d6e93a383eabceacfdc0ad8 (patch)
tree6f34187aa4670cfceb276d5b2504d192652847dc /js/tools/modifier-tool-base.js
parent7805cc9c59d218ae9fe9cf3fac4fcec1fdf10fae (diff)
downloadninja-dc9650af5760b1f93d6e93a383eabceacfdc0ad8.tar.gz
Snapping fixes.
Diffstat (limited to 'js/tools/modifier-tool-base.js')
-rwxr-xr-xjs/tools/modifier-tool-base.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 94b806fd..07b28747 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -25,6 +25,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
25 _snapParam: { value: null }, 25 _snapParam: { value: null },
26 _snapIndex: { value: -1 }, 26 _snapIndex: { value: -1 },
27 _useQuadPt: { value: false }, 27 _useQuadPt: { value: false },
28 _shouldUseQuadPt: { value: false },
28 29
29 // we set snapping capabilities depending on the tool. 30 // we set snapping capabilities depending on the tool.
30 // The following variables are set in a tool's initializeSnapping method called on mouse down. 31 // The following variables are set in a tool's initializeSnapping method called on mouse down.
@@ -175,6 +176,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
175// } 176// }
176 } 177 }
177 178
179 // only do quadrant snapping if the 4 corners of the element are in the drag plane
180 var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
181 this._shouldUseQuadPt = (sign == 0)
182
178 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); 183 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
179 this._mouseDownHitRec = wpHitRec; 184 this._mouseDownHitRec = wpHitRec;
180 this._mouseUpHitRec = null; 185 this._mouseUpHitRec = null;
@@ -236,6 +241,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
236 } 241 }
237 } 242 }
238 243
244 //console.log( "ParameterizeSnap: " + paramPt );
239 return paramPt; 245 return paramPt;
240 } 246 }
241 }, 247 },
@@ -284,14 +290,16 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
284 y = x0 + ty*dy, 290 y = x0 + ty*dy,
285 z = 0.0; 291 z = 0.0;
286 var localPt = [x,y,z]; 292 var localPt = [x,y,z];
293
287 globalPt = viewUtils.localToGlobal( localPt, elt ); 294 globalPt = viewUtils.localToGlobal( localPt, elt );
288 295
289 // add in the delta 296 // add in the delta
290 var hitPt = this.GetObjectHitPoint(); 297 var hitPt = this.GetObjectHitPoint();
291 var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject ); 298 var scrPt = viewUtils.localToGlobal( hitPt, this._clickedObject );
292 var delta = [xEvent-scrPt[0], yEvent-scrPt[1]]; 299 var delta = [xEvent-scrPt[0], yEvent-scrPt[1], 0-scrPt[2]];
293 globalPt[0] += delta[0]; 300 globalPt[0] += delta[0];
294 globalPt[1] += delta[1]; 301 globalPt[1] += delta[1];
302 globalPt[2] += delta[2];
295 } 303 }
296 304
297 return globalPt; 305 return globalPt;
@@ -517,7 +525,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
517 525
518 // do the snap 526 // do the snap
519 var quadPt; 527 var quadPt;
520 if (mouseIsDown) 528 if (mouseIsDown && !do3DSnap && this._shouldUseQuadPt && (this._handleMode === null) && (this._mode === 0))
521 quadPt = this.GetQuadrantSnapPoint(x,y); 529 quadPt = this.GetQuadrantSnapPoint(x,y);
522 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt ); 530 var hitRec = snapManager.snap(x, y, do3DSnap, quadPt );
523 531
@@ -806,6 +814,8 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
806 HandleLeftButtonDown: { 814 HandleLeftButtonDown: {
807 value: function(event) { 815 value: function(event) {
808 816
817 console.log( "modifier-tool-base.HandleLeftButtonDown" );
818
809 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); 819 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
810 this.downPoint.x = point.x; 820 this.downPoint.x = point.x;
811 this.downPoint.y = point.y; 821 this.downPoint.y = point.y;