From 802e92eb70b00849dadacf2c6590d27edbe65d99 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 8 Feb 2012 15:39:47 -0800 Subject: bug fixes for better anchor point rotation and removing snapping on hover and mouse down --- js/helper-classes/RDGE/GLAnchorPoint.js | 11 +++++++++++ js/helper-classes/RDGE/GLBrushStroke.js | 6 +++++- js/helper-classes/RDGE/GLSubpath.js | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'js/helper-classes/RDGE') diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js index 6b4af072..716f59d4 100644 --- a/js/helper-classes/RDGE/GLAnchorPoint.js +++ b/js/helper-classes/RDGE/GLAnchorPoint.js @@ -55,6 +55,11 @@ GLAnchorPoint.prototype.setNextFromPrev = function () { //translate the next point from the translation that was applied to the prev. point GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) { + //do nothing if the total translation is zero + var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz); + if (totalTransSq < 0.0000001) + return; + // *** compute the rotation of the prev vector *** var oldP = Vector.create([this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z]); var newP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]); @@ -71,6 +76,7 @@ GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) { //TEMP for some situations the axis angle computation returns NaNs if (isNaN(newN[0]) || isNaN(newN[1]) || isNaN(newN[2])) { + console.log("NaN in translateNextFromPrev"); return; } //end TEMP @@ -80,6 +86,11 @@ GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) { } //translate the next point from the translation that was applied to the prev. point GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) { + //do nothing if the total translation is zero + var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz); + if (totalTransSq < 0.0000001) + return; + // *** compute the rotation of the next vector *** var oldN = Vector.create([this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z]); var newN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]); diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js index 552545f0..fdf1595c 100644 --- a/js/helper-classes/RDGE/GLBrushStroke.js +++ b/js/helper-classes/RDGE/GLBrushStroke.js @@ -4,7 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -// Todo: This shoudl be converted to a module +// Todo: This entire class should be converted to a module var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; /////////////////////////////////////////////////////////////////////// @@ -140,6 +140,10 @@ function GLBrushStroke() { this._dirty = false; } + this.buildBuffers = function () { + return; //no need to do anything for now + }//buildBuffers() + //render // specify how to render the subpath in Canvas2D this.render = function () { diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index 383194d4..a14fdda0 100644 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js @@ -4,7 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -// Todo: This shoudl be converted to a module +// Todo: This entire class should be converted to a module var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; @@ -163,6 +163,7 @@ function GLSubpath() { } */ + var numPoints = this._samples.length/3; ctx.moveTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]); for (var i=0;i