Browse Source

Prevent 16-bit overflow when storing face area; fixes wildly inconsistent tessellation LOD calculations

master
Nico de Poel 3 years ago
parent
commit
197c657361
  1. 5
      main.cpp
  2. 6
      ps1bsp.h

5
main.cpp

@ -152,8 +152,8 @@ int process_faces(const world_t* world, const TextureList& textures)
outFace.numFaceVertices = (unsigned char)(outFaceVertices.size() - outFace.firstFaceVertex);
outFace.center = (vertexSum / face->ledge_num).convertWorldPosition();
float area = computeFaceArea(world, face); // TODO: divide by number of polygons
outFace.center.pad = (short)(sqrt(area));
float area = computeFaceArea(world, face);
outFace.center.pad = (short)(area / 100);
outFaces.push_back(outFace);
}
@ -285,6 +285,7 @@ int process_faces(const world_t* world, const TextureList& textures)
}
outFace->numPolygons = (unsigned char)(outPolygons.size() - outFace->firstPolygon);
outFace->center.pad = (short)sqrt((double)outFace->center.pad * 100 / outFace->numPolygons);
}
printf("Converting data...\n");

6
ps1bsp.h

@ -95,9 +95,9 @@ typedef struct
unsigned char b : 5;
} ps1bsp_facevertex_t;
#define SURF_DRAWSKY 0x2
#define SURF_DRAWLIQUID 0x4
#define SURF_DRAWWATER 0x8
#define SURF_DRAWSKY 0x4
#define SURF_DRAWLIQUID 0x8
#define SURF_DRAWWATER 0x10
// High quality: Face -> polygons -> polygon vertex indices (index + UV + light) -> vertices
// Low quality: Face -> face vertex indices (index + color) -> vertices

Loading…
Cancel
Save