|
|
|
@ -61,8 +61,8 @@ static float computeFaceArea(const world_t* world, const face_t* face) |
|
|
|
vertex_t* vertex = &world->vertices[vertIndex]; |
|
|
|
Vec3 vec = vertex->toVec(); |
|
|
|
|
|
|
|
float x = tangent.dotProduct(vec); |
|
|
|
float y = bitangent.dotProduct(vec); |
|
|
|
double x = tangent.dotProduct(vec); |
|
|
|
double y = bitangent.dotProduct(vec); |
|
|
|
bounds.includePoint(Vec3(x, y, 0)); |
|
|
|
} |
|
|
|
|
|
|
|
@ -125,8 +125,8 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
|
outFace.firstFaceVertex = (unsigned short)outFaceVertices.size(); |
|
|
|
outFace.textureId = (unsigned char)texinfo->texture_id; |
|
|
|
|
|
|
|
float minS = FLT_MAX, minT = FLT_MAX; |
|
|
|
float maxS = FLT_MIN, maxT = FLT_MIN; |
|
|
|
double minS = DBL_MAX, minT = DBL_MAX; |
|
|
|
double maxS = DBL_MIN, maxT = DBL_MIN; |
|
|
|
|
|
|
|
// Traverse the list of face edges to collect all of the face's vertices
|
|
|
|
Vec3 vertexSum; |
|
|
|
@ -143,8 +143,8 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
|
Vec3 vertexPoint = vertex->toVec(); |
|
|
|
|
|
|
|
// Calculate texture UV bounds
|
|
|
|
float s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width; |
|
|
|
float t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height; |
|
|
|
double s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width; |
|
|
|
double t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height; |
|
|
|
if (s > maxS) maxS = s; if (s < minS) minS = s; |
|
|
|
if (t > maxT) maxT = t; if (t < minT) minT = t; |
|
|
|
|
|
|
|
@ -159,8 +159,8 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
|
} |
|
|
|
|
|
|
|
// If the texture doesn't tile, we don't need to correct the UVs as much
|
|
|
|
float sRange = maxS - minS; |
|
|
|
float tRange = maxT - minT; |
|
|
|
double sRange = maxS - minS; |
|
|
|
double tRange = maxT - minT; |
|
|
|
if (sRange < 1) sRange = 1; |
|
|
|
if (tRange < 1) tRange = 1; |
|
|
|
|
|
|
|
@ -181,8 +181,8 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
|
faceVertex.light = 0; |
|
|
|
|
|
|
|
// Calculate texture UVs
|
|
|
|
float s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width; |
|
|
|
float t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height; |
|
|
|
double s = (vertexPoint.dotProduct(texinfo->vectorS) + texinfo->distS) / miptex->width; |
|
|
|
double t = (vertexPoint.dotProduct(texinfo->vectorT) + texinfo->distT) / miptex->height; |
|
|
|
if (minS < 0 || maxS > 1) s = (s - minS) / sRange; |
|
|
|
if (minT < 0 || maxT > 1) t = (t - minT) / tRange; |
|
|
|
|
|
|
|
@ -218,7 +218,7 @@ int process_faces(const world_t* world, const std::vector<ps1bsp_texture_t>& tex |
|
|
|
ps1bsp_facevertex_t& faceVertex = outFaceVertices[outFace.firstFaceVertex + faceVertIdx]; |
|
|
|
const vertex_t* vertex = &world->vertices[faceVertex.index]; |
|
|
|
faceVertex.light = compute_faceVertex_light4(world, face, faceBounds, vertex->toVec()); |
|
|
|
faceVertex.light <<= 1; |
|
|
|
faceVertex.light = (short)((float)faceVertex.light * 1.5f); |
|
|
|
if (faceVertex.light > 255) |
|
|
|
faceVertex.light = 255; |
|
|
|
} |
|
|
|
|