diff --git a/tools/qflight/include/light.h b/tools/qflight/include/light.h index f0bd2e28d..436a660b7 100644 --- a/tools/qflight/include/light.h +++ b/tools/qflight/include/light.h @@ -122,6 +122,8 @@ extern vec3_t *surfaceorgs; extern struct entity_s **novislights; extern int num_novislights; +const char *get_tex_name (int texindex); + //@} #endif// __light_h diff --git a/tools/qflight/include/options.h b/tools/qflight/include/options.h index 8c5086456..22443ccae 100644 --- a/tools/qflight/include/options.h +++ b/tools/qflight/include/options.h @@ -41,6 +41,7 @@ typedef struct { int novis; int extrabit; int attenuation; + int solid_sky; vec_t extrascale; vec_t distance; vec_t range; diff --git a/tools/qflight/source/ltface.c b/tools/qflight/source/ltface.c index 5e0115078..d26344332 100644 --- a/tools/qflight/source/ltface.c +++ b/tools/qflight/source/ltface.c @@ -61,6 +61,24 @@ int c_bad; int c_culldistplane, c_proper; +const char * +get_tex_name (int texindex) +{ + dmiptexlump_t *mtl; + miptex_t *mt; + int miptex; + + if (bsp->texdatasize) { + mtl = (dmiptexlump_t *) bsp->texdata; + miptex = bsp->texinfo[texindex].miptex; + if (mtl->dataofs[miptex] != -1) { + mt = (miptex_t *) (bsp->texdata + mtl->dataofs[miptex]); + return mt->name; + } + } + return "notex"; +} + /* SAMPLE POINT DETERMINATION diff --git a/tools/qflight/source/options.c b/tools/qflight/source/options.c index 049941f94..88a3584b9 100644 --- a/tools/qflight/source/options.c +++ b/tools/qflight/source/options.c @@ -65,6 +65,7 @@ static struct option const long_options[] = { {"distance", required_argument, 0, 'd'}, {"range", required_argument, 0, 'r'}, {"file", required_argument, 0, 'f'}, + {"solid-sky", no_argument, 0, 'S'}, {NULL, 0, NULL, 0} }; @@ -83,6 +84,7 @@ static const char *short_options = "r:" // scale range "P:" // properties file "f:" + "S" // solid-sky ; void @@ -106,7 +108,9 @@ usage (int status) " -n, --noise [factor] Scale noise. 0 (default) to disable\n" " -c, --cutoff [scale] Scale cutoff. 0 to disable\n" " -P, --properties [file] Properties file\n" - " -f, --file [bspfile] BSP file\n\n"); + " -f, --file [bspfile] BSP file\n" + " -S, --solid-sky Enable solid sky brushes\n" + "\n"); exit (status); } @@ -188,6 +192,8 @@ DecodeArgs (int argc, char **argv) case 'P': options.properties_filename = strdup (optarg); break; + case 'S': + options.solid_sky = true; default: usage (1); } diff --git a/tools/qflight/source/trace.c b/tools/qflight/source/trace.c index f976a6b52..39d17ceb0 100644 --- a/tools/qflight/source/trace.c +++ b/tools/qflight/source/trace.c @@ -49,7 +49,9 @@ #include "QF/dstring.h" #include "QF/quakefs.h" #include "QF/sys.h" + #include "light.h" +#include "options.h" typedef struct { int type; @@ -98,9 +100,14 @@ MakeTnode (int nodenum) t->dist = plane->dist; for (i = 0; i < 2; i++) { - if (node->children[i] < 0) + if (node->children[i] < 0) { t->children[i] = bsp->leafs[-node->children[i] - 1].contents; - else { + if (options.solid_sky && t->children[i] == CONTENTS_SOLID) { + dface_t *face = &bsp->faces[node->firstface]; + if (!strncmp (get_tex_name (face->texinfo), "sky", 3)) + t->children[i] = CONTENTS_SKY; // Simulate real sky + } + } else { t->children[i] = tnode_p - tnodes; MakeTnode (node->children[i]); }