Permalink
Browse files

Removed common.js

Accuracy suffered with invsqrt and benchmarks didn't show it as a
consistent win. Better to let the browsers continue to optimize their
math. A few other cleanups included.
  • Loading branch information...
toji committed Dec 2, 2012
1 parent d646894 commit 77460dcec12877b14395dfd78c6090bb0e46fa59
View
@@ -1 +1,3 @@
.rvmrc
+
+.DS_Store
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2012 Brandon Jones, Colin MacKenzie IV
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- * distribution.
- */
-
-describe("common", function() {
- describe("glm_invsqrt", function() {
- it("should return 1 / sqrt(n)", function() { expect(glm_invsqrt(5)).toBeCloseTo(1 / Math.sqrt(5)); });
- });
-});
@@ -1,25 +1,24 @@
-/*
- * Copyright (c) 2012 Brandon Jones, Colin MacKenzie IV
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- * distribution.
- */
+/* Copyright (c) 2012, Brandon Jones, Colin MacKenzie IV. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
describe("mat2", function() {
var out, matA, matB, result;
@@ -1,5 +1,3 @@
-//= require 'gl-matrix/common.js'
-
//= require 'gl-matrix/vec2.js'
//= require 'gl-matrix/vec3.js'
//= require 'gl-matrix/vec4.js'
View
@@ -1,52 +0,0 @@
-/* Copyright (c) 2012, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
-
-/*
- * Common utilities used throughout the rest of the library
- */
-
-/**
- * Fast way to calculate the inverse square root,
- * see http://jsperf.com/inverse-square-root/5
- *
- * If typed arrays are not available, a slower
- * implementation will be used.
- *
- * @param {Number} n the number
- * @returns {Number} inverse square root
- */
-var glm_invsqrt = exports.glm_invsqrt = (function() {
- if (typeof(Float32Array) != 'undefined') {
- var y = new Float32Array(1);
- var i = new Int32Array(y.buffer);
-
- return function(n) {
- var x2 = n * 0.5;
- y[0] = n;
- i[0] = 0x5f3759df - (i[0] >> 1);
- var n2 = y[0];
- return n2 * (1.5 - (x2 * n2 * n2));
- };
- } else {
- return function(n) { return 1.0 / Math.sqrt(n); };
- }
-})();
View
@@ -226,4 +226,6 @@ mat2.str = function (a) {
return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
};
-exports.mat2 = mat2;
+if(exports) {
+ exports.mat2 = mat2;
+}
View
@@ -260,4 +260,6 @@ mat3.str = function (a) {
a[6] + ', ' + a[7] + ', ' + a[8] + ')';
};
-exports.mat3 = mat3;
+if(exports) {
+ exports.mat3 = mat3;
+}
View
@@ -792,4 +792,6 @@ mat4.str = function (a) {
a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')';
};
-exports.mat4 = mat4;
+if(exports) {
+ exports.mat4 = mat4;
+}
View
@@ -374,4 +374,6 @@ quat.str = function (a) {
return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
};
-exports.quat = quat;
+if(exports) {
+ exports.quat = quat;
+}
View
@@ -340,4 +340,6 @@ vec2.str = function (a) {
return 'vec2(' + a[0] + ', ' + a[1] + ')';
};
-exports.vec2 = vec2;
+if(exports) {
+ exports.vec2 = vec2;
+}
View
@@ -390,4 +390,6 @@ vec3.str = function (a) {
return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
};
-exports.vec3 = vec3;
+if(exports) {
+ exports.vec3 = vec3;
+}
View
@@ -300,7 +300,6 @@ vec4.normalize = function(out, a) {
w = a[3];
var len = x*x + y*y + z*z + w*w;
if (len > 0) {
- //TODO: evaluate use of glm_invsqrt here?
len = 1 / Math.sqrt(len);
out[0] = a[0] * len;
out[1] = a[1] * len;
@@ -394,4 +393,6 @@ vec4.str = function (a) {
return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
};
-exports.vec4 = vec4;
+if(exports) {
+ exports.vec4 = vec4;
+}

0 comments on commit 77460dc

Please sign in to comment.