|
|
|
@ -137,7 +137,7 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
|
outFaces.push_back(outFace); |
|
|
|
} |
|
|
|
|
|
|
|
std::vector<ps1bsp_surfvertex_t> outSurfVertices; |
|
|
|
std::vector<ps1bsp_polyvertex_t> outPolyVertices; |
|
|
|
std::vector<ps1bsp_polygon_t> 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<ps1bsp_texture_t>& 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<ps1bsp_texture_t>& 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<ps1bsp_texture_t>& 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); |
|
|
|
|