|
|
@ -41,8 +41,8 @@ void world_load(const u_long *data, world_t *world) |
|
|
|
|
|
|
|
|
LOAD_CHUNK(ps1bsp_texture_t, world->textures, world->numTextures, bytes, header->textures); |
|
|
LOAD_CHUNK(ps1bsp_texture_t, world->textures, world->numTextures, bytes, header->textures); |
|
|
LOAD_CHUNK(ps1bsp_vertex_t, world->vertices, world->numVertices, bytes, header->vertices); |
|
|
LOAD_CHUNK(ps1bsp_vertex_t, world->vertices, world->numVertices, bytes, header->vertices); |
|
|
LOAD_CHUNK(ps1bsp_surfvertex_t, world->surfVertices, world->numSurfVertices, bytes, header->surfVertices); |
|
|
|
|
|
LOAD_CHUNK(ps1bsp_polygon_t, world->polygons, world->numPolygons, bytes, header->polygons); |
|
|
LOAD_CHUNK(ps1bsp_polygon_t, world->polygons, world->numPolygons, bytes, header->polygons); |
|
|
|
|
|
LOAD_CHUNK(ps1bsp_polyvertex_t, world->polyVertices, world->numPolyVertices, bytes, header->polyVertices); |
|
|
LOAD_CHUNK(ps1bsp_face_t, world->faces, world->numFaces, bytes, header->faces); |
|
|
LOAD_CHUNK(ps1bsp_face_t, world->faces, world->numFaces, bytes, header->faces); |
|
|
LOAD_CHUNK(ps1bsp_facevertex_t, world->faceVertices, world->numFaceVertices, bytes, header->faceVertices); |
|
|
LOAD_CHUNK(ps1bsp_facevertex_t, world->faceVertices, world->numFaceVertices, bytes, header->faceVertices); |
|
|
LOAD_CHUNK(ps1bsp_plane_t, world->planes, world->numPlanes, bytes, header->planes); |
|
|
LOAD_CHUNK(ps1bsp_plane_t, world->planes, world->numPlanes, bytes, header->planes); |
|
|
@ -313,13 +313,13 @@ static void world_drawface(const world_t *world, const ps1bsp_face_t *face) |
|
|
const ps1bsp_polygon_t* poly = &world->polygons[face->firstPolygon]; |
|
|
const ps1bsp_polygon_t* poly = &world->polygons[face->firstPolygon]; |
|
|
for (u_char polyIdx = 0; polyIdx < face->numPolygons; ++polyIdx, ++poly) |
|
|
for (u_char polyIdx = 0; polyIdx < face->numPolygons; ++polyIdx, ++poly) |
|
|
{ |
|
|
{ |
|
|
ps1bsp_surfvertex_t *surfVertex = &world->surfVertices[poly->firstPolyVertex]; |
|
|
|
|
|
|
|
|
ps1bsp_polyvertex_t *polyVertex = &world->polyVertices[poly->firstPolyVertex]; |
|
|
SVECTOR *curVert = verts; |
|
|
SVECTOR *curVert = verts; |
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++surfVertex, ++curVert) |
|
|
|
|
|
|
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++polyVertex, ++curVert) |
|
|
{ |
|
|
{ |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[surfVertex->index]; |
|
|
|
|
|
|
|
|
const ps1bsp_vertex_t *vert = &world->vertices[polyVertex->index]; |
|
|
*curVert = *((SVECTOR*)vert); |
|
|
*curVert = *((SVECTOR*)vert); |
|
|
curVert->pad = surfVertex->light; |
|
|
|
|
|
|
|
|
curVert->pad = polyVertex->light; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (poly->numPolyVertices == 3) |
|
|
if (poly->numPolyVertices == 3) |
|
|
@ -336,62 +336,20 @@ static void world_drawface(const world_t *world, const ps1bsp_face_t *face) |
|
|
const ps1bsp_polygon_t* poly = &world->polygons[face->firstPolygon]; |
|
|
const ps1bsp_polygon_t* poly = &world->polygons[face->firstPolygon]; |
|
|
for (u_char polyIdx = 0; polyIdx < face->numPolygons; ++polyIdx, ++poly) |
|
|
for (u_char polyIdx = 0; polyIdx < face->numPolygons; ++polyIdx, ++poly) |
|
|
{ |
|
|
{ |
|
|
ps1bsp_surfvertex_t *surfVertex = &world->surfVertices[poly->firstPolyVertex]; |
|
|
|
|
|
|
|
|
ps1bsp_polyvertex_t *polyVertex = &world->polyVertices[poly->firstPolyVertex]; |
|
|
STVECTOR *curVert = verts; |
|
|
STVECTOR *curVert = verts; |
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++surfVertex, ++curVert) |
|
|
|
|
|
|
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++polyVertex, ++curVert) |
|
|
{ |
|
|
{ |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[surfVertex->index]; |
|
|
|
|
|
|
|
|
const ps1bsp_vertex_t *vert = &world->vertices[polyVertex->index]; |
|
|
*((SVECTOR*)curVert) = *((SVECTOR*)vert); |
|
|
*((SVECTOR*)curVert) = *((SVECTOR*)vert); |
|
|
curVert->u = (u_short)surfVertex->u; |
|
|
|
|
|
curVert->v = (u_short)surfVertex->v; |
|
|
|
|
|
curVert->pad = surfVertex->light; |
|
|
|
|
|
|
|
|
curVert->u = (u_short)polyVertex->u; |
|
|
|
|
|
curVert->v = (u_short)polyVertex->v; |
|
|
|
|
|
curVert->pad = polyVertex->light; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
draw_quad_strip_tex(verts, poly->numPolyVertices, faceTexture->tpage); |
|
|
draw_quad_strip_tex(verts, poly->numPolyVertices, faceTexture->tpage); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// if (!enableTexturing) |
|
|
|
|
|
// { |
|
|
|
|
|
// // Draw untextured, vertex colored polygons |
|
|
|
|
|
// SVECTOR *vecs = (SVECTOR*)(scratchpad + 256); |
|
|
|
|
|
|
|
|
|
|
|
// // Copy this face's vertices into scratch RAM for fast reuse |
|
|
|
|
|
// // TODO: this is the main performance bottleneck right now! |
|
|
|
|
|
// ps1bsp_facevertex_t *faceVertex = &world->faceVertices[face->firstFaceVertex]; |
|
|
|
|
|
// SVECTOR *curVec = vecs; |
|
|
|
|
|
// for (int vertIdx = 0; vertIdx < face->numFaceVertices; ++vertIdx, ++faceVertex, ++curVec) |
|
|
|
|
|
// { |
|
|
|
|
|
// const ps1bsp_vertex_t *vert = &world->vertices[faceVertex->index]; |
|
|
|
|
|
// *curVec = *((SVECTOR*)vert); |
|
|
|
|
|
// curVec->pad = faceVertex->light; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// if (face->numFaceVertices == 3) // Special case: draw single triangles using the simplest method |
|
|
|
|
|
// draw_triangle_fan(vecs, 3); |
|
|
|
|
|
// else |
|
|
|
|
|
// draw_quad_strip(vecs, face->numFaceVertices); |
|
|
|
|
|
// } |
|
|
|
|
|
// else |
|
|
|
|
|
// { |
|
|
|
|
|
// // Draw textured, vertex colored polygons |
|
|
|
|
|
// STVECTOR *vecs = (STVECTOR*)(scratchpad + 256); |
|
|
|
|
|
|
|
|
|
|
|
// // Copy this face's vertices into scratch RAM for fast reuse |
|
|
|
|
|
// ps1bsp_facevertex_t *faceVertex = &world->faceVertices[face->firstFaceVertex]; |
|
|
|
|
|
// ps1bsp_texture_t *faceTexture = &world->textures[face->textureId]; |
|
|
|
|
|
// STVECTOR *curVec = vecs; |
|
|
|
|
|
// for (int vertIdx = 0; vertIdx < face->numFaceVertices; ++vertIdx, ++faceVertex, ++curVec) |
|
|
|
|
|
// { |
|
|
|
|
|
// const ps1bsp_vertex_t *vert = &world->vertices[faceVertex->index]; |
|
|
|
|
|
// *((SVECTOR*)curVec) = *((SVECTOR*)vert); |
|
|
|
|
|
// curVec->u = (u_short)faceVertex->u; |
|
|
|
|
|
// curVec->v = (u_short)faceVertex->v; |
|
|
|
|
|
// curVec->pad = faceVertex->light; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// draw_quad_strip_tex(vecs, face->numFaceVertices, faceTexture->tpage); |
|
|
|
|
|
// } |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void world_drawnode(const world_t *world, short nodeIdx, u_char *pvs) |
|
|
static void world_drawnode(const world_t *world, short nodeIdx, u_char *pvs) |
|
|
|