|
|
|
@ -63,30 +63,25 @@ void world_draw(const world_t *world) |
|
|
|
vecs[vertIdx].pad = vert->baseLight; |
|
|
|
} |
|
|
|
|
|
|
|
// Draw the face as a triangle strip |
|
|
|
const SVECTOR *v0, *v1, *v2; |
|
|
|
// Draw the face as a quad strip |
|
|
|
const SVECTOR *v0, *v1, *v2, *v3; |
|
|
|
const SVECTOR *head = vecs; |
|
|
|
const SVECTOR *tail = vecs + face->numFaceVertices; |
|
|
|
u_char reverse = 0; |
|
|
|
|
|
|
|
v2 = head++; // Initialize first vertex to index 0 and set head to index 1 |
|
|
|
// Initialize the first two vertices |
|
|
|
v2 = --tail; |
|
|
|
v3 = head++; |
|
|
|
|
|
|
|
for (u_char vertIdx = 0; vertIdx < face->numFaceVertices - 2; ++vertIdx) |
|
|
|
// Normally a quad strip would have (N-2)/2 quads, but we might end up with a sole triangle at the end which will be drawn as a collapsed quad |
|
|
|
u_char numQuads = (face->numFaceVertices - 1) / 2; |
|
|
|
for (u_char quadIdx = 0; quadIdx < numQuads; ++quadIdx) |
|
|
|
{ |
|
|
|
if (reverse ^= 1) |
|
|
|
{ |
|
|
|
v0 = v2; |
|
|
|
v1 = head; |
|
|
|
v2 = --tail; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
v0 = v1; |
|
|
|
v1 = ++head; |
|
|
|
v2 = tail; |
|
|
|
} |
|
|
|
|
|
|
|
// Naively draw the triangle with GTE, nothing special or optimized about this |
|
|
|
v0 = v2; |
|
|
|
v1 = v3; |
|
|
|
v2 = --tail; |
|
|
|
v3 = head++; |
|
|
|
|
|
|
|
// Naively draw the quad with GTE, nothing special or optimized about this |
|
|
|
gte_ldv3(v0, v1, v2); |
|
|
|
gte_rtpt(); // Rotation, translation, perspective projection |
|
|
|
|
|
|
|
@ -104,17 +99,25 @@ void world_draw(const world_t *world) |
|
|
|
continue; |
|
|
|
|
|
|
|
// Draw a flat-shaded untextured colored triangle |
|
|
|
POLY_G3 *poly = (POLY_G3*)mem_prim(sizeof(POLY_G3)); |
|
|
|
POLY_G4 *poly = (POLY_G4*)mem_prim(sizeof(POLY_G4)); |
|
|
|
if (poly == NULL) |
|
|
|
break; |
|
|
|
|
|
|
|
setPolyG3(poly); |
|
|
|
setPolyG4(poly); |
|
|
|
|
|
|
|
gte_stsxy0(&poly->x0); |
|
|
|
gte_stsxy1(&poly->x1); |
|
|
|
gte_stsxy2(&poly->x2); |
|
|
|
|
|
|
|
gte_stsxy3_g3(poly); |
|
|
|
// Transform the fourth vertex to complete the quad |
|
|
|
gte_ldv0(v3); |
|
|
|
gte_rtps(); |
|
|
|
gte_stsxy(&poly->x3); |
|
|
|
|
|
|
|
poly->r0 = poly->g0 = poly->b0 = (uint8_t)v0->pad; |
|
|
|
poly->r1 = poly->g1 = poly->b1 = (uint8_t)v1->pad; |
|
|
|
poly->r2 = poly->g2 = poly->b2 = (uint8_t)v2->pad; |
|
|
|
poly->r3 = poly->g3 = poly->b3 = (uint8_t)v3->pad; |
|
|
|
|
|
|
|
addPrim(curOT + depth, poly); |
|
|
|
} |
|
|
|
|