Skip to content

Commit

Permalink
Replaces matrix math functions in o3d-webgl with a new library that u…
Browse files Browse the repository at this point in the history
…ses 1-dimensional arrays to represent matrices instead of 2-dimensional arrays.

This is a duplicate of Daniel Horn's change http://codereview.chromium.org/3072008 for committal.

Review URL: http://codereview.chromium.org/3273004

git-svn-id: http://src.chromium.org/svn/trunk/src/o3d/samples/o3djs@59268 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information
[email protected] committed Sep 13, 2010
1 parent 1237b99 commit 6fff3d8
Show file tree
Hide file tree
Showing 9 changed files with 4,534 additions and 1,338 deletions.
16 changes: 8 additions & 8 deletions canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ o3djs.canvas.CanvasInfo = function(pack, root, viewInfo) {
1,
1,
1,
[[1, 0, 0, 0],
[0, 0, 1, 0],
[0, -1, 0, 0],
[0, 0, 0, 1]]);
o3djs.math.makeMatrix4(1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0 ,0,
0, 0, 0, 1));

/**
* A shape for opaque quads.
Expand All @@ -257,10 +257,10 @@ o3djs.canvas.CanvasInfo = function(pack, root, viewInfo) {
1,
1,
1,
[[1, 0, 0, 0],
[0, 0, 1, 0],
[0, -1, 0, 0],
[0, 0, 0, 1]]);
o3djs.math.makeMatrix4(1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0 ,0,
0, 0, 0, 1));
};
/**
* The CanvasQuad object encapsulates a Transform, a rectangle Shape,
Expand Down
30 changes: 16 additions & 14 deletions debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ o3djs.debug.DebugLine.prototype.update_ = function() {
perp2 = math.cross(perp1, direction);
}
this.transform_.localMatrix =
[perp2.concat(0),
direction.concat(0),
perp1.concat(0),
this.start_.concat(1)];
o3djs.math.makeMatrix4(perp2[0], perp2[1], perp2[2], 0,
direction[0], direction[1], direction[2], 0,
perp1[0], perp1[1], perp1[2], 0,
this.start_[0], this.start_[1], this.start_[2], 1);
this.transform_.scale(1, math.length(vector), 1);
};

Expand Down Expand Up @@ -517,16 +517,18 @@ o3djs.debug.DebugHelper = function(pack, viewInfo) {
// Create the axis shape.
for (var ii = 0; ii < O3D_DEBUG_AXIS_INFO_.length; ++ii) {
var info = O3D_DEBUG_AXIS_INFO_[ii];
var cubeShape = o3djs.primitives.createCube(pack,
material,
1,
[[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[info.offset[0] * 0.5,
info.offset[1] * 0.5,
info.offset[2] * 0.5,
1]]);
var cubeShape = o3djs.primitives.createCube(
pack,
material,
1,
o3djs.math.makeMatrix4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
info.offset[0] * 0.5,
info.offset[1] * 0.5,
info.offset[2] * 0.5,
1));

var cube = cubeShape.elements[0];
cube.owner = this.axisShape_;
pack.removeObject(cubeShape);
Expand Down
8 changes: 4 additions & 4 deletions fps.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ o3djs.fps.FPSManager = function(pack, clientWidth, clientHeight, opt_parent) {
1,
1,
1,
[[1, 0, 0, 0],
[0, 0, 1, 0],
[0, -1, 0, 0],
[0.5, 0.5, 0, 1]]);
o3djs.math.makeMatrix4(1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0.5, 0.5, 0, 1));

var barXOffset = 10;
var barYOffset = 2;
Expand Down
6 changes: 4 additions & 2 deletions manipulators.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ o3djs.manipulators.Line_.prototype.closestPointToRay = function(startPoint,
// value of u' is less than zero.
var rayDirection = o3djs.math.subVector(endPoint, startPoint);
var ddrd = o3djs.math.dot(this.direction_, rayDirection);
var A = [[-o3djs.math.lengthSquared(this.direction_), ddrd],
[ddrd, -o3djs.math.lengthSquared(rayDirection)]];
var A = o3djs.math.makeMatrix2(-o3djs.math.lengthSquared(this.direction_),
ddrd,
ddrd,
-o3djs.math.lengthSquared(rayDirection));
var det = o3djs.math.det2(A);
if (Math.abs(det) < o3djs.manipulators.EPSILON) {
return null;
Expand Down
Loading

0 comments on commit 6fff3d8

Please sign in to comment.