Skip to content

Commit

Permalink
fixed QuadGeometry to push multiple indices at once using Vector.push()
Browse files Browse the repository at this point in the history
  • Loading branch information
JMLX42 committed Jun 2, 2012
1 parent 3b80a79 commit fd29c40
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/aerys/minko/scene/node/mesh/geometry/primitive/QuadGeometry.as
Expand Up @@ -16,31 +16,38 @@ package aerys.minko.scene.node.mesh.geometry.primitive
}

public function QuadGeometry(doubleSided : Boolean = false,
width : uint = 1,
height : uint = 0,
numColumns : uint = 1,
numRows : uint = 0,
streamsUsage : uint = 0)
{
var vertices : Vector.<Number> = new Vector.<Number>();
var indices : Vector.<uint> = new Vector.<uint>();

height ||= width;
numRows ||= numColumns;

for (var y : int = 0; y <= height; y++)
for (var x : int = 0; x <= width; x++)
vertices.push(x / width - .5, y / height - .5, 0.,
x / width, 1. - y / height);

for (y = 0; y < height; y++)
for (var y : int = 0; y <= numRows; y++)
{
for (x = 0; x < width; x++)
for (var x : int = 0; x <= numColumns; x++)
{
indices.push(x + (width + 1) * y);
indices.push(x + 1 + y * (width + 1));
indices.push((y + 1) * (width + 1) + x);
vertices.push(
x / numColumns - .5, y / numRows - .5, 0.,
x / numColumns, 1. - y / numRows
);
}
}

indices.push(x + 1 + y * (width + 1));
indices.push((y + 1) * (width + 1) + x + 1);
indices.push((y + 1) * (width + 1) + x);
for (y = 0; y < numRows; y++)
{
for (x = 0; x < numColumns; x++)
{
indices.push(
x + (numColumns + 1) * y,
x + 1 + y * (numColumns + 1),
(y + 1) * (numColumns + 1) + x,
x + 1 + y * (numColumns + 1),
(y + 1) * (numColumns + 1) + x + 1,
(y + 1) * (numColumns + 1) + x
);
}
}

Expand Down

0 comments on commit fd29c40

Please sign in to comment.