diff --git a/draw.h b/draw.h index 7fd3bf6..644f1ab 100644 --- a/draw.h +++ b/draw.h @@ -10,7 +10,7 @@ #define setColorFast(pr, r) *((u_int*)(pr)) = *((u_int*)(r)) #define setUVFast(pu, u) *((u_short*)(pu)) = *((u_short*)(u)) -static u_int color_white = ((255 << 24) | (255 << 16) | (255 << 8) | 255); +static u_int color_white = ((255 << 16) | (255 << 8) | 255); static INLINE void draw_triangle_lit(SVECTOR *verts, u_long *ot) { @@ -243,8 +243,8 @@ static INLINE void draw_quadstrip_textured(const ps1bsp_vertex_t *vertices, cons // Fill out the quad's data fields in struct order, to optimize data access // First vertex and texture CLUT setColorFast(&poly->r0, &v0->r); - gte_stsxy0(&poly->x0); setUVFast(&poly->u0, &v0->u); + gte_stsxy0(&poly->x0); poly->clut = quake_clut; // Second vertex and texture page @@ -264,8 +264,8 @@ static INLINE void draw_quadstrip_textured(const ps1bsp_vertex_t *vertices, cons // Fourth vertex setColorFast(&poly->r3, &v3->r); - gte_stsxy(&poly->x3); setUVFast(&poly->u3, &v3->u); + gte_stsxy(&poly->x3); setPolyGT4(poly); addPrim(ot, poly); @@ -309,29 +309,29 @@ static INLINE void draw_quadstrip_water(const ps1bsp_vertex_t *vertices, const p // Fill out the quad's data fields in struct order, to optimize data access // First vertex and texture CLUT setColorFast(&poly->r0, &color_white); - gte_stsxy0(&poly->x0); setUVFast(&poly->u0, &v0->u); - poly->clut = quake_clut; + gte_stsxy0(&poly->x0); + poly->clut = water_clut; // Second vertex and texture page - gte_stsxy1(&poly->x1); setUVFast(&poly->u1, &v1->u); poly->tpage = tpage; + gte_stsxy1(&poly->x1); // Third vertex - gte_stsxy2(&poly->x2); setUVFast(&poly->u2, &v2->u); + gte_stsxy2(&poly->x2); // Transform the fourth vertex to complete the quad gte_ldv0(&vertices[v3->index]); gte_rtps(); // Fourth vertex - gte_stsxy(&poly->x3); setUVFast(&poly->u3, &v3->u); + gte_stsxy(&poly->x3); setPolyFT4(poly); - setSemiTrans(poly, semiTrans); + if (semiTrans) poly->code |= 2; addPrim(ot, poly); ++polyCount; } diff --git a/ps1bsp.h b/ps1bsp.h index 14b768a..c872937 100755 --- a/ps1bsp.h +++ b/ps1bsp.h @@ -59,9 +59,9 @@ typedef struct // TODO: break up into poly vertex (index + uv) and surface vertex (index + light) shared between polygons. Will reduce this struct size to 4 bytes and eliminate duplicate light values. typedef struct { - unsigned short index; - unsigned char u, v; unsigned char r, g, b, pad; + unsigned char u, v; + unsigned short index; } ps1bsp_polyvertex_t; // Faces are broken up into one or more polygons, each of which can be drawn as a quad/triangle strip with a single texture. diff --git a/test.ps1bsp b/test.ps1bsp index 126eb37..c8c5d8c 100755 Binary files a/test.ps1bsp and b/test.ps1bsp differ diff --git a/world.c b/world.c index b5cefe2..f784672 100644 --- a/world.c +++ b/world.c @@ -316,7 +316,7 @@ void world_draw(const world_t *world) world_drawface = &world_drawface_lit; ps1bsp_leaf_t *firstLeaf = NULL; - world_sortLeafs(world, world->models[0].nodeId, pvs, &firstLeaf); + world_sortLeafs(world, 0, pvs, &firstLeaf); ps1bsp_face_t *firstFace = world_sortFaces(world, firstLeaf); world_drawFaces(world, firstFace); }