|
|
|
@ -205,10 +205,22 @@ static INLINE void drawface_quad_strip(const ps1bsp_face_t *face, SVECTOR *vecs) |
|
|
|
|
|
|
|
static INLINE short world_pointPlaneDist(const VECTOR *point, const ps1bsp_plane_t *plane) |
|
|
|
{ |
|
|
|
// TODO: can be optimized for axis-aligned planes, no need for a dot product there |
|
|
|
// Make use of axis-aligned planes to skip the need for a dot product |
|
|
|
if (plane->type < 3) |
|
|
|
return (short)(((int*)point)[plane->type] - plane->dist); |
|
|
|
|
|
|
|
return m_pointPlaneDist2(*point, plane->normal, plane->dist); |
|
|
|
} |
|
|
|
|
|
|
|
static INLINE short world_planeDot(const SVECTOR *dir, const ps1bsp_plane_t *plane) |
|
|
|
{ |
|
|
|
// Make use of axis-aligned planes to skip the need for a dot product |
|
|
|
if (plane->type < 3) |
|
|
|
return ((short*)dir)[plane->type]; |
|
|
|
|
|
|
|
return m_dot12s(*dir, plane->normal); |
|
|
|
} |
|
|
|
|
|
|
|
static void world_drawface(const world_t *world, const ps1bsp_face_t *face) |
|
|
|
{ |
|
|
|
// Backface culling using the face's plane and center point |
|
|
|
@ -219,7 +231,7 @@ static void world_drawface(const world_t *world, const ps1bsp_face_t *face) |
|
|
|
cam_vec.vz = center.vz - cam_pos.vz; |
|
|
|
|
|
|
|
const ps1bsp_plane_t *plane = &world->planes[face->planeId]; |
|
|
|
short dot = m_dot12s(cam_vec, plane->normal); |
|
|
|
short dot = world_planeDot(&cam_vec, plane); |
|
|
|
if ((dot >= 0) ^ face->side) |
|
|
|
return; |
|
|
|
|
|
|
|
|