diff --git a/main.cpp b/main.cpp index e49ef85..1fd45dc 100644 --- a/main.cpp +++ b/main.cpp @@ -137,7 +137,7 @@ int process_faces(const world_t* world, const std::vector& tex outFaces.push_back(outFace); } - std::vector outSurfVertices; + std::vector outPolyVertices; std::vector outPolygons; // Iterate over all faces again; now that we know the bounds of each face, we can calculate lighting for all of them @@ -156,7 +156,7 @@ int process_faces(const world_t* world, const std::vector& tex for (auto polyIter = polygons.begin(); polyIter != polygons.end(); ++polyIter) { ps1bsp_polygon_t outPoly = { 0 }; - outPoly.firstPolyVertex = (unsigned short)outSurfVertices.size(); + outPoly.firstPolyVertex = (unsigned short)outPolyVertices.size(); for (auto polyVertIter = polyIter->polyVertices.begin(); polyVertIter != polyIter->polyVertices.end(); ++polyVertIter) { @@ -165,21 +165,21 @@ int process_faces(const world_t* world, const std::vector& tex Vec3 vertex = tesselator.getVertices()[vertIndex]; - ps1bsp_surfvertex_t surfVert = { 0 }; - surfVert.index = (unsigned short)vertIndex; - surfVert.u = (unsigned char)(normalizedUV.x * (ps1tex.w - 1)) + ps1tex.uoffs; - surfVert.v = (unsigned char)(normalizedUV.y * (ps1tex.h - 1)) + ps1tex.voffs; + ps1bsp_polyvertex_t polyVert = { 0 }; + polyVert.index = (unsigned short)vertIndex; + polyVert.u = (unsigned char)(normalizedUV.x * (ps1tex.w - 1)) + ps1tex.uoffs; + polyVert.v = (unsigned char)(normalizedUV.y * (ps1tex.h - 1)) + ps1tex.voffs; int light = compute_faceVertex_light5(world, face, faceBounds, vertex); light = (int)((float)light * 1.5f); // Compromise between overbright and non-overbright lighting. Looks good in practice. if (light > 255) light = 255; - surfVert.light = (unsigned short)light; - outSurfVertices.push_back(surfVert); + polyVert.light = (unsigned short)light; + outPolyVertices.push_back(polyVert); } - outPoly.numPolyVertices = (unsigned short)(outSurfVertices.size() - outPoly.firstPolyVertex); + outPoly.numPolyVertices = (unsigned short)(outPolyVertices.size() - outPoly.firstPolyVertex); outPolygons.push_back(outPoly); } @@ -265,8 +265,8 @@ int process_faces(const world_t* world, const std::vector& tex // Write collected data to file and update header info writeMapData(textures, outHeader.textures, fbsp); writeMapData(outVertices, outHeader.vertices, fbsp); - writeMapData(outSurfVertices, outHeader.surfVertices, fbsp); writeMapData(outPolygons, outHeader.polygons, fbsp); + writeMapData(outPolyVertices, outHeader.polyVertices, fbsp); writeMapData(outFaces, outHeader.faces, fbsp); writeMapData(outFaceVertices, outHeader.faceVertices, fbsp); writeMapData(outPlanes, outHeader.planes, fbsp); diff --git a/ps1bsp.h b/ps1bsp.h index 55d7ecd..0d1d57e 100644 --- a/ps1bsp.h +++ b/ps1bsp.h @@ -30,7 +30,6 @@ typedef struct ps1bsp_dentry_t textures; ps1bsp_dentry_t vertices; - ps1bsp_dentry_t surfVertices; ps1bsp_dentry_t polygons; ps1bsp_dentry_t polyVertices; ps1bsp_dentry_t faces; @@ -57,13 +56,13 @@ typedef struct short pad; } ps1bsp_vertex_t; -// Texture UV and lighting data for a vertex on a particular surface. Can be shared between multiple polygons on the same surface. +// Texture UV and lighting data for a vertex on a particular polygon. typedef struct { unsigned short index; unsigned short light; // Can be made into u_char if we need to store more data; currently u_short for 32-bit alignment purposes unsigned short u, v; // Can be made into u_char if we need to store more data; currently u_short for 32-bit alignment purposes -} ps1bsp_surfvertex_t; +} 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. // This ahead-of-time tesselation is done to deal with the fact that the PS1 can't do texture wrapping, meaning tiling textures have to be broken up into separate polygons.