this should take care of the case of a cube vertex being enclosed by a sky

polygon. If not, oh well, I won't know till tonight :/ (at least it compiles)
This commit is contained in:
Bill Currie 2000-11-13 17:07:57 +00:00
parent 602912aeb2
commit d251d03252

View file

@ -387,6 +387,21 @@ set_vertex (glpoly_t *p, vec3_t v, int face)
}
}
/*
find_cube_vertex
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
common vertex.
*/
static void
find_cube_vertex (int face1, int face2, int face3, vec3_t v)
{
v[face1 % 3] = 1024 * (1 - 2 * (face1 / 3));
v[face2 % 3] = 1024 * (1 - 2 * (face2 / 3));
v[face3 % 3] = 1024 * (1 - 2 * (face3 / 3));
}
void
R_DrawSkyBoxPoly (glpoly_t *poly)
{
@ -421,18 +436,26 @@ R_DrawSkyBoxPoly (glpoly_t *poly)
if (face != prev_face) {
if (face % 3 == prev_face % 3) {
} else {
vec3_t l, t;
vec3_t l;
find_intersect (prev_face, last_v, face, v, l);
set_vertex(&box[prev_face].poly, l, prev_face);
if (box[prev_face].enter >= 0 && box[prev_face].leave == -1) {
if (box[prev_face].enter >=0 && box[prev_face].enter != face) {
vec3_t t;
find_cube_vertex (prev_face, face, box[face].enter, t);
set_vertex(&box[prev_face].poly, t, prev_face);
} else {
box[prev_face].enter = -1;
box[prev_face].leave = face;
}
box[prev_face].leave = face;
if (box[face].enter == -1 && box[face].leave >= 0) {
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);
} else {
box[face].enter = prev_face;
box[face].leave = -1;
}
box[prev_face].leave = face;
set_vertex(&box[face].poly, l, face);
}
}