|
|
@ -178,31 +178,40 @@ static INLINE void draw_quadstrip_colored(const ps1bsp_vertex_t *vertices, const |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static INLINE void draw_triangle_textured(STVECTOR *verts, u_short tpage, u_long *ot) |
|
|
|
|
|
|
|
|
static INLINE void draw_triangle_textured(const ps1bsp_vertex_t *vertices, const ps1bsp_polyvertex_t *polyVerts, u_short tpage, u_long *ot) |
|
|
{ |
|
|
{ |
|
|
// Draw a single textured triangle |
|
|
|
|
|
const STVECTOR *v0 = &verts[0]; |
|
|
|
|
|
const STVECTOR *v1 = &verts[1]; |
|
|
|
|
|
const STVECTOR *v2 = &verts[2]; |
|
|
|
|
|
|
|
|
const ps1bsp_polyvertex_t *v0, *v1, *v2; |
|
|
|
|
|
|
|
|
// Naively draw the triangle with GTE, nothing special or optimized about this |
|
|
|
|
|
gte_ldv3(v0, v1, v2); |
|
|
|
|
|
|
|
|
v0 = &polyVerts[0]; |
|
|
|
|
|
v1 = &polyVerts[1]; |
|
|
|
|
|
v2 = &polyVerts[2]; |
|
|
|
|
|
|
|
|
|
|
|
// Transform the three vertices |
|
|
|
|
|
gte_ldv3(&vertices[v0->index], &vertices[v1->index], &vertices[v2->index]); |
|
|
gte_rtpt(); // Rotation, translation, perspective projection |
|
|
gte_rtpt(); // Rotation, translation, perspective projection |
|
|
|
|
|
|
|
|
// Draw a gouraud shaded textured triangle |
|
|
// Draw a gouraud shaded textured triangle |
|
|
POLY_GT3 *poly = (POLY_GT3*)mem_prim(sizeof(POLY_GT3)); |
|
|
POLY_GT3 *poly = (POLY_GT3*)mem_prim(sizeof(POLY_GT3)); |
|
|
setPolyGT3(poly); |
|
|
|
|
|
gte_stsxy3_gt3(poly); |
|
|
|
|
|
|
|
|
|
|
|
// Texture UVs |
|
|
|
|
|
setUV3(poly, v0->u, v0->v, v1->u, v1->v, v2->u, v2->v); |
|
|
|
|
|
|
|
|
// Fill out the quad's data fields in struct order, to optimize data access |
|
|
|
|
|
// First vertex and texture CLUT |
|
|
|
|
|
setColorFast(&poly->r0, &v0->r); |
|
|
|
|
|
setUVFast(&poly->u0, &v0->u); |
|
|
|
|
|
gte_stsxy0(&poly->x0); |
|
|
poly->clut = quake_clut; |
|
|
poly->clut = quake_clut; |
|
|
|
|
|
|
|
|
|
|
|
// Second vertex and texture page |
|
|
|
|
|
setColorFast(&poly->r1, &v1->r); |
|
|
|
|
|
gte_stsxy1(&poly->x1); |
|
|
|
|
|
setUVFast(&poly->u1, &v1->u); |
|
|
poly->tpage = tpage; |
|
|
poly->tpage = tpage; |
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
// Third vertex |
|
|
|
|
|
setColorFast(&poly->r2, &v2->r); |
|
|
|
|
|
gte_stsxy2(&poly->x2); |
|
|
|
|
|
setUVFast(&poly->u2, &v2->u); |
|
|
|
|
|
|
|
|
|
|
|
setPolyGT3(poly); |
|
|
addPrim(ot, poly); |
|
|
addPrim(ot, poly); |
|
|
++polyCount; |
|
|
++polyCount; |
|
|
} |
|
|
} |
|
|
|