mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-21 23:50:58 +00:00
this might work a little better :/ I hate duplicate code, but making the
enter/leave face functions use common code would be a pain.
This commit is contained in:
parent
05f66b4c66
commit
1ed9378fa4
1 changed files with 39 additions and 25 deletions
|
@ -391,8 +391,8 @@ set_vertex (glpoly_t *p, vec3_t v, int face)
|
||||||
find_cube_vertex
|
find_cube_vertex
|
||||||
|
|
||||||
get the coords of the vertex common to the three specified faces of the
|
get the coords of the vertex common to the three specified faces of the
|
||||||
cube. NOTE: this WILL break if the three faces are do not share a
|
cube. NOTE: this WILL break if the three faces do not share a common
|
||||||
common vertex.
|
vertex.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
find_cube_vertex (int face1, int face2, int face3, vec3_t v)
|
find_cube_vertex (int face1, int face2, int face3, vec3_t v)
|
||||||
|
@ -402,16 +402,46 @@ find_cube_vertex (int face1, int face2, int face3, vec3_t v)
|
||||||
v[face3 % 3] = 1024 * (1 - 2 * (face3 / 3));
|
v[face3 % 3] = 1024 * (1 - 2 * (face3 / 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct box_def {
|
||||||
|
int tex, enter, leave;
|
||||||
|
glpoly_t poly;
|
||||||
|
float verts[32][VERTEXSIZE];
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
enter_face (struct box_def *box, int prev_face, int face)
|
||||||
|
{
|
||||||
|
if (box[face].leave >=0 && box[face].leave != prev_face) {
|
||||||
|
vec3_t t;
|
||||||
|
find_cube_vertex (prev_face, face, box[face].leave, t);
|
||||||
|
set_vertex(&box[face].poly, t, prev_face);
|
||||||
|
box[face].enter = -1;
|
||||||
|
} else {
|
||||||
|
box[face].enter = face;
|
||||||
|
}
|
||||||
|
box[face].leave = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
leave_face (struct box_def *box, int prev_face, int face)
|
||||||
|
{
|
||||||
|
if (box[prev_face].enter >=0 && box[prev_face].enter != face) {
|
||||||
|
vec3_t t;
|
||||||
|
find_cube_vertex (prev_face, face, box[prev_face].enter, t);
|
||||||
|
set_vertex(&box[prev_face].poly, t, prev_face);
|
||||||
|
box[prev_face].leave = -1;
|
||||||
|
} else {
|
||||||
|
box[prev_face].leave = face;
|
||||||
|
}
|
||||||
|
box[prev_face].enter = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_DrawSkyBoxPoly (glpoly_t *poly)
|
R_DrawSkyBoxPoly (glpoly_t *poly)
|
||||||
{
|
{
|
||||||
static int skytex_offs[] = {3, 0, 4, 1, 2, 5};
|
static int skytex_offs[] = {3, 0, 4, 1, 2, 5};
|
||||||
vec3_t v, last_v;
|
vec3_t v, last_v;
|
||||||
struct {
|
struct box_def box[6];
|
||||||
int tex, enter, leave;
|
|
||||||
glpoly_t poly;
|
|
||||||
float verts[32][VERTEXSIZE];
|
|
||||||
} box[6];
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int face, prev_face;
|
int face, prev_face;
|
||||||
|
|
||||||
|
@ -440,24 +470,8 @@ R_DrawSkyBoxPoly (glpoly_t *poly)
|
||||||
find_intersect (prev_face, last_v, face, v, l);
|
find_intersect (prev_face, last_v, face, v, l);
|
||||||
|
|
||||||
set_vertex(&box[prev_face].poly, l, prev_face);
|
set_vertex(&box[prev_face].poly, l, prev_face);
|
||||||
if (box[prev_face].enter >=0 && box[prev_face].enter != face) {
|
leave_face (box, prev_face, face);
|
||||||
vec3_t t;
|
enter_face (box, prev_face, face);
|
||||||
find_cube_vertex (prev_face, face, box[face].enter, t);
|
|
||||||
set_vertex(&box[prev_face].poly, t, prev_face);
|
|
||||||
box[prev_face].enter = -1;
|
|
||||||
} else {
|
|
||||||
box[prev_face].enter = -1;
|
|
||||||
box[prev_face].leave = face;
|
|
||||||
}
|
|
||||||
if (box[face].leave >=0 && box[face].leave != prev_face) {
|
|
||||||
vec3_t t;
|
|
||||||
find_cube_vertex (prev_face, face, box[face].leave, t);
|
|
||||||
set_vertex(&box[face].poly, t, face);
|
|
||||||
box[face].leave = -1;
|
|
||||||
} else {
|
|
||||||
box[face].enter = prev_face;
|
|
||||||
box[face].leave = -1;
|
|
||||||
}
|
|
||||||
set_vertex(&box[face].poly, l, face);
|
set_vertex(&box[face].poly, l, face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue