|
|
|
@ -4,7 +4,7 @@ |
|
|
|
|
|
|
|
#include <inline_c.h> |
|
|
|
|
|
|
|
static SVECTOR *left, *right, *top, *bottom; |
|
|
|
static SVECTOR *left, *right, *top, *bottom, *front; |
|
|
|
|
|
|
|
static INLINE void frustum_buildPlane(MATRIX *rot_matrix, VECTOR *normal, SVECTOR *outPlane) |
|
|
|
{ |
|
|
|
@ -15,7 +15,7 @@ static INLINE void frustum_buildPlane(MATRIX *rot_matrix, VECTOR *normal, SVECTO |
|
|
|
|
|
|
|
void frustum_update(int width, int height) |
|
|
|
{ |
|
|
|
VECTOR l, r, t, b; |
|
|
|
VECTOR l, r, t, b, f; |
|
|
|
|
|
|
|
int near; |
|
|
|
gte_ReadGeomScreen(&near); |
|
|
|
@ -41,6 +41,10 @@ void frustum_update(int width, int height) |
|
|
|
t.vy = ONE; |
|
|
|
t.vz = -b.vz; |
|
|
|
|
|
|
|
f.vx = 0; |
|
|
|
f.vy = ONE; |
|
|
|
f.vz = 0; |
|
|
|
|
|
|
|
MATRIX rot_matrix; |
|
|
|
RotMatrixQ(&cam_rot, &rot_matrix); |
|
|
|
|
|
|
|
@ -49,11 +53,14 @@ void frustum_update(int width, int height) |
|
|
|
right = (SVECTOR*)(scratchpad + sizeof(SVECTOR) * 1); |
|
|
|
top = (SVECTOR*)(scratchpad + sizeof(SVECTOR) * 2); |
|
|
|
bottom = (SVECTOR*)(scratchpad + sizeof(SVECTOR) * 3); |
|
|
|
front = (SVECTOR*)(scratchpad + sizeof(SVECTOR) * 4); |
|
|
|
|
|
|
|
frustum_buildPlane(&rot_matrix, &l, left); |
|
|
|
frustum_buildPlane(&rot_matrix, &r, right); |
|
|
|
frustum_buildPlane(&rot_matrix, &t, top); |
|
|
|
frustum_buildPlane(&rot_matrix, &b, bottom); |
|
|
|
frustum_buildPlane(&rot_matrix, &f, front); |
|
|
|
front->pad -= near >> 1; |
|
|
|
|
|
|
|
// FntPrint(-1, "l = %d %d, r = %d %d, t = %d %d, b = %d %d\n", |
|
|
|
// left.vx, left.pad, right.vx, right.pad, top.vz, top.pad, bottom.vz, bottom.pad); |
|
|
|
@ -99,3 +106,8 @@ u_char frustum_boxInside(const SVECTOR *min, const SVECTOR *max) |
|
|
|
if (frustum_pointInside_((SVECTOR) { max->vx, max->vy, max->vz })) return 1; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int frustum_pointDepth(const SVECTOR *point) |
|
|
|
{ |
|
|
|
return m_dot12(front, point) + front->pad; |
|
|
|
} |