diff --git a/main.c b/main.c index a52f2a4..8d3da54 100644 --- a/main.c +++ b/main.c @@ -8,7 +8,7 @@ extern u_long tim_e1m1[]; extern u_long bsp_test[]; -VECTOR cam_pos = { 2176, 1152, 128 }; // START +VECTOR cam_pos = { 2176, 1152, 272 }; // START //VECTOR cam_pos = { 1920, -1408, 352 }; // E1M1 SVECTOR cam_rot = { 0, 0, 0 }; diff --git a/ps1bsp.h b/ps1bsp.h index 1e97abf..db02d50 100755 --- a/ps1bsp.h +++ b/ps1bsp.h @@ -60,7 +60,7 @@ typedef struct typedef struct { unsigned short firstFaceVertex; - unsigned short numFaceVertices; + unsigned char numFaceVertices; } ps1bsp_face_t; // Pre-parsed and encoded entity data (this runs the risk of becoming too bloated) diff --git a/test.ps1bsp b/test.ps1bsp index cd61132..87e7184 100755 Binary files a/test.ps1bsp and b/test.ps1bsp differ diff --git a/world.c b/world.c index 7aa8207..ccfe05c 100644 --- a/world.c +++ b/world.c @@ -63,12 +63,28 @@ void world_draw(const world_t *world) vecs[vertIdx].pad = vert->baseLight; } - // Draw the face as a triangle fan - for (int vertIdx = 1; vertIdx < face->numFaceVertices - 1; ++vertIdx) + // Draw the face as a triangle strip + const SVECTOR *v0, *v1, *v2; + 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 + + for (u_char vertIdx = 0; vertIdx < face->numFaceVertices - 2; ++vertIdx) { - const SVECTOR *v0 = &vecs[0]; - const SVECTOR *v1 = &vecs[vertIdx]; - const SVECTOR *v2 = &vecs[vertIdx + 1]; + 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 gte_ldv3(v0, v1, v2);