|
|
@ -79,17 +79,17 @@ static INLINE char world_cull_backface(const world_t *world, const ps1bsp_face_t |
|
|
cam_vec.vy = face->center.vy - cam_pos.vy; |
|
|
cam_vec.vy = face->center.vy - cam_pos.vy; |
|
|
cam_vec.vz = face->center.vz - cam_pos.vz; |
|
|
cam_vec.vz = face->center.vz - cam_pos.vz; |
|
|
|
|
|
|
|
|
|
|
|
// Check if the face's plane points towards the camera |
|
|
|
|
|
const ps1bsp_plane_t *plane = &world->planes[face->planeId]; |
|
|
|
|
|
*dot = world_planeDot(&cam_vec, plane); |
|
|
|
|
|
if ((*dot >= 0) ^ face->side) |
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
// Check if the face is behind the camera |
|
|
// Check if the face is behind the camera |
|
|
// TODO: this may cull faces close to the camera, use VectorNormalS to normalize and check for angles < -60 degrees |
|
|
// TODO: this may cull faces close to the camera, use VectorNormalS to normalize and check for angles < -60 degrees |
|
|
// TODO: or, just check against all corners of the face... |
|
|
// TODO: or, just check against all corners of the face... |
|
|
short camDot = m_dot12(cam_vec, cam_dir); |
|
|
short camDot = m_dot12(cam_vec, cam_dir); |
|
|
if (camDot < 0) |
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
|
|
|
// Check if the face's plane points towards the camera |
|
|
|
|
|
const ps1bsp_plane_t *plane = &world->planes[face->planeId]; |
|
|
|
|
|
*dot = world_planeDot(&cam_vec, plane); |
|
|
|
|
|
return ((*dot >= 0) ^ face->side); |
|
|
|
|
|
|
|
|
return camDot < 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void world_drawface_fast(const world_t *world, const ps1bsp_face_t *face) |
|
|
static void world_drawface_fast(const world_t *world, const ps1bsp_face_t *face) |
|
|
@ -107,7 +107,9 @@ static void world_drawface_fast(const world_t *world, const ps1bsp_face_t *face) |
|
|
for (u_char vertIdx = 0; vertIdx < face->numFaceVertices; ++vertIdx, ++faceVertex, ++curVert) |
|
|
for (u_char vertIdx = 0; vertIdx < face->numFaceVertices; ++vertIdx, ++faceVertex, ++curVert) |
|
|
{ |
|
|
{ |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[faceVertex->index]; |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[faceVertex->index]; |
|
|
*curVert = *((SVECTOR*)vert); |
|
|
|
|
|
|
|
|
curVert->vx = vert->x; |
|
|
|
|
|
curVert->vy = vert->y; |
|
|
|
|
|
curVert->vz = vert->z; |
|
|
curVert->pad = (unsigned short)(size_t)face & 0xFF; // TODO: apply averaged light * color value |
|
|
curVert->pad = (unsigned short)(size_t)face & 0xFF; // TODO: apply averaged light * color value |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -135,7 +137,9 @@ static void world_drawface_lit(const world_t *world, const ps1bsp_face_t *face) |
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++polyVertex, ++curVert) |
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++polyVertex, ++curVert) |
|
|
{ |
|
|
{ |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[polyVertex->index]; |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[polyVertex->index]; |
|
|
*curVert = *((SVECTOR*)vert); |
|
|
|
|
|
|
|
|
curVert->vx = vert->x; |
|
|
|
|
|
curVert->vy = vert->y; |
|
|
|
|
|
curVert->vz = vert->z; |
|
|
curVert->pad = polyVertex->light; |
|
|
curVert->pad = polyVertex->light; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -169,7 +173,9 @@ static void world_drawface_textured(const world_t *world, const ps1bsp_face_t *f |
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++polyVertex, ++curVert) |
|
|
for (u_char vertIdx = 0; vertIdx < poly->numPolyVertices; ++vertIdx, ++polyVertex, ++curVert) |
|
|
{ |
|
|
{ |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[polyVertex->index]; |
|
|
const ps1bsp_vertex_t *vert = &world->vertices[polyVertex->index]; |
|
|
*((SVECTOR*)curVert) = *((SVECTOR*)vert); |
|
|
|
|
|
|
|
|
curVert->vx = vert->x; |
|
|
|
|
|
curVert->vy = vert->y; |
|
|
|
|
|
curVert->vz = vert->z; |
|
|
curVert->u = (u_short)polyVertex->u; |
|
|
curVert->u = (u_short)polyVertex->u; |
|
|
curVert->v = (u_short)polyVertex->v; |
|
|
curVert->v = (u_short)polyVertex->v; |
|
|
curVert->pad = polyVertex->light; |
|
|
curVert->pad = polyVertex->light; |
|
|
|