Game Development Reference

In-Depth Information

{

long
index = nextEdge[edgeIndex];

if
(index == 0xFFFF)

{

nextEdge[edgeIndex]=edgeCount;

break
;

}

edgeIndex=index;

}

}

nextEdge[edgeCount]=0xFFFF;

edgeCount++;

}

i1=i2;

}

triangle++;

}

// Second pass over all triangles. This finds all the edges satisfying

// the condition that the first vertex index is greater than the second

// vertex index when the direction from the first vertex to the second

// vertex represents a counterclockwise winding around the triangle to

// which the edge belongs. For each of these edges, the same edge should

// have already been found in the first pass for a different triangle.

// So we search the list of edges for the higher-numbered vertex index

// for the matching edge and fill in the second triangle index. The

// maximum number of comparisons in this search for any vertex is the

// number of edges having that vertex as an endpoint.

triangle = triangleArray;

for
(
long
a = 0; a < triangleCount; a++)

{

long
i1 = triangle->index[2];

for
(
long
b = 0; b < 3; b++)

{

long
i2 = triangle->index[b];

Search Nedrilad ::

Custom Search