|
|
@ -158,6 +158,12 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
vertexSum = vertexSum + vertexPoint; |
|
|
vertexSum = vertexSum + vertexPoint; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If the texture doesn't tile, we don't need to correct the UVs as much
|
|
|
|
|
|
float sRange = maxS - minS; |
|
|
|
|
|
float tRange = maxT - minT; |
|
|
|
|
|
if (sRange < 1) sRange = 1; |
|
|
|
|
|
if (tRange < 1) tRange = 1; |
|
|
|
|
|
|
|
|
// Go over the edges again to fudge some UVs for the vertices (this second pass is only necessary because we don't have texture tiling yet)
|
|
|
// Go over the edges again to fudge some UVs for the vertices (this second pass is only necessary because we don't have texture tiling yet)
|
|
|
for (int edgeListIdx = 0; edgeListIdx < face->ledge_num; ++edgeListIdx) |
|
|
for (int edgeListIdx = 0; edgeListIdx < face->ledge_num; ++edgeListIdx) |
|
|
{ |
|
|
{ |
|
|
@ -177,8 +183,8 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
// Calculate texture UVs
|
|
|
// Calculate texture UVs
|
|
|
float s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width; |
|
|
float s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width; |
|
|
float t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height; |
|
|
float t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height; |
|
|
s = (s - minS) / (maxS - minS); |
|
|
|
|
|
t = (t - minT) / (maxT - minT); |
|
|
|
|
|
|
|
|
if (minS < 0 || maxS > 1) s = (s - minS) / sRange; |
|
|
|
|
|
if (minT < 0 || maxT > 1) t = (t - minT) / tRange; |
|
|
|
|
|
|
|
|
// Rescale the UVs to the dimensions of the mipmap we've selected for our texture atlas
|
|
|
// Rescale the UVs to the dimensions of the mipmap we've selected for our texture atlas
|
|
|
faceVertex.u = (unsigned char)(s * (ps1tex.w - 1)); |
|
|
faceVertex.u = (unsigned char)(s * (ps1tex.w - 1)); |
|
|
|