|
|
@ -318,9 +318,9 @@ int process_faces(const world_t* world) |
|
|
// export_lightmap(world, face, bounds, faceIdx);
|
|
|
// export_lightmap(world, face, bounds, faceIdx);
|
|
|
|
|
|
|
|
|
outFace.numFaceVertices = (unsigned short)(outFaceVertices.size() - outFace.firstFaceVertex); |
|
|
outFace.numFaceVertices = (unsigned short)(outFaceVertices.size() - outFace.firstFaceVertex); |
|
|
outFace.centerPoint = convertWorldPosition(vertexSum / outFace.numFaceVertices); |
|
|
|
|
|
|
|
|
outFace.center = convertWorldPosition(vertexSum / outFace.numFaceVertices); |
|
|
float area = computeFaceArea(world, face); |
|
|
float area = computeFaceArea(world, face); |
|
|
outFace.centerPoint.pad = (short)(sqrt(area)); |
|
|
|
|
|
|
|
|
outFace.center.pad = (short)(sqrt(area)); |
|
|
outFaces.push_back(outFace); |
|
|
outFaces.push_back(outFace); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -335,28 +335,9 @@ int process_faces(const world_t* world) |
|
|
{ |
|
|
{ |
|
|
ps1bsp_facevertex_t& faceVertex = outFaceVertices[outFace.firstFaceVertex + faceVertIdx]; |
|
|
ps1bsp_facevertex_t& faceVertex = outFaceVertices[outFace.firstFaceVertex + faceVertIdx]; |
|
|
faceVertex.light = compute_faceVertex_light2(world, face, faceVertex.index, faceBounds, vertexFaces); |
|
|
faceVertex.light = compute_faceVertex_light2(world, face, faceVertex.index, faceBounds, vertexFaces); |
|
|
|
|
|
|
|
|
if (face->lightmap >= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
ps1bsp_vertex_t& vertex = outVertices[faceVertex.index]; |
|
|
|
|
|
*(unsigned short*)(&vertex.baseLight) += faceVertex.light; |
|
|
|
|
|
vertex.r++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Average the lightmap values for each vertex
|
|
|
|
|
|
for (auto iter = outVertices.begin(); iter != outVertices.end(); ++iter) |
|
|
|
|
|
{ |
|
|
|
|
|
unsigned char count = (*iter).r; |
|
|
|
|
|
if (count == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
unsigned short accumulate = *(unsigned short*)(&(*iter).baseLight); |
|
|
|
|
|
(*iter).baseLight = accumulate / count; |
|
|
|
|
|
(*iter).r = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Convert planes
|
|
|
// Convert planes
|
|
|
std::vector<ps1bsp_plane_t> outPlanes; |
|
|
std::vector<ps1bsp_plane_t> outPlanes; |
|
|
for (int planeIdx = 0; planeIdx < world->numPlanes; ++planeIdx) |
|
|
for (int planeIdx = 0; planeIdx < world->numPlanes; ++planeIdx) |
|
|
|