light: remove bsp30 support and automatically generate .lit when needed
Check whether any of the entities have colored fields set and if so, enable colored light output. Can still be overridden from the command line if needed. Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
65b38c4952
commit
8ce739fe3f
|
|
@ -242,8 +242,8 @@ LoadBSPFile(const char *filename)
|
|||
bsp_version = (int)header->version;
|
||||
logprint("BSP is version %i\n", bsp_version);
|
||||
|
||||
if (bsp_version != 29 && bsp_version != 30)
|
||||
Error("Sorry, only bsp versions 29 & 30 supported.");
|
||||
if (bsp_version != 29)
|
||||
Error("Sorry, only bsp version 29 supported.");
|
||||
|
||||
nummodels = CopyLump(LUMP_MODELS, &dmodels, sizeof(dmodel_t));
|
||||
numvertexes = CopyLump(LUMP_VERTEXES, &dvertexes, sizeof(dvertex_t));
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ void MakeTnodes(void);
|
|||
extern float scaledist;
|
||||
extern float rangescale;
|
||||
extern int worldminlight;
|
||||
extern const vec3_t vec3_white;
|
||||
extern vec3_t minlight_color;
|
||||
extern int sunlight;
|
||||
extern vec3_t sunlight_color;
|
||||
|
|
|
|||
|
|
@ -154,11 +154,14 @@ CheckEntityFields(entity_t *entity)
|
|||
}
|
||||
entity->formula = LF_LINEAR;
|
||||
}
|
||||
if (!entity->lightcolor[0] && !entity->lightcolor[1]
|
||||
&& !entity->lightcolor[2]) {
|
||||
entity->lightcolor[0] = 255;
|
||||
entity->lightcolor[1] = 255;
|
||||
entity->lightcolor[2] = 255;
|
||||
if (!VectorCompare(entity->lightcolor, vec3_origin)) {
|
||||
if (!colored) {
|
||||
colored = true;
|
||||
logprint("Colored light entities detected: "
|
||||
".lit output enabled.\n");
|
||||
}
|
||||
} else {
|
||||
VectorCopy(vec3_white, entity->lightcolor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -181,6 +184,7 @@ LoadEntities(void)
|
|||
data = dentdata;
|
||||
|
||||
/* start parsing */
|
||||
memset(entities, 0, sizeof(entity_t) * MAX_MAP_ENTITIES);
|
||||
num_entities = 0;
|
||||
num_lights = 0;
|
||||
|
||||
|
|
@ -295,6 +299,16 @@ LoadEntities(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!VectorCompare(sunlight_color, vec3_white) ||
|
||||
!VectorCompare(minlight_color, vec3_white)) {
|
||||
if (!colored) {
|
||||
colored = true;
|
||||
logprint("Colored light entities detected: "
|
||||
".lit output enabled.\n");
|
||||
}
|
||||
}
|
||||
|
||||
logprint("%d entities read, %d are lights.\n", num_entities, num_lights);
|
||||
MatchTargets();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@
|
|||
float scaledist = 1.0;
|
||||
float rangescale = 0.5;
|
||||
int worldminlight = 0;
|
||||
vec3_t minlight_color = { 255, 255, 255 }; /* defaults to white light */
|
||||
int sunlight = 0;
|
||||
const vec3_t vec3_white = { 255, 255, 255 };
|
||||
vec3_t minlight_color = { 255, 255, 255 }; /* defaults to white light */
|
||||
vec3_t sunlight_color = { 255, 255, 255 }; /* defaults to white light */
|
||||
vec3_t sunmangle = { 0, 0, 16384 }; /* defaults to straight down */
|
||||
|
||||
|
|
@ -38,8 +39,6 @@ static byte *lit_file_end; // end of space for litfile data
|
|||
qboolean extrasamples;
|
||||
qboolean compress_ents;
|
||||
qboolean colored;
|
||||
qboolean bsp30;
|
||||
qboolean litfile;
|
||||
qboolean nominlimit;
|
||||
|
||||
qboolean nolightface[MAX_MAP_FACES];
|
||||
|
|
@ -159,14 +158,14 @@ LightWorld(void)
|
|||
Error("%s: allocation of %i bytes failed.", __func__, lightdatasize);
|
||||
memset(dlightdata, 0, lightdatasize + 16);
|
||||
|
||||
if (litfile)
|
||||
if (colored)
|
||||
lightdatasize /= 4;
|
||||
|
||||
/* align filebase to a 4 byte boundary */
|
||||
filebase = file_p = (byte *)(((unsigned long)dlightdata + 3) & ~3);
|
||||
file_end = filebase + lightdatasize;
|
||||
|
||||
if (colored && litfile) {
|
||||
if (colored) {
|
||||
/* litfile data stored in dlightdata, after the white light */
|
||||
lit_filebase = file_end + 12 - ((unsigned long)file_end % 12);
|
||||
lit_file_p = lit_filebase;
|
||||
|
|
@ -223,13 +222,8 @@ main(int argc, const char **argv)
|
|||
} else if (!strcmp(argv[i], "-compress")) {
|
||||
compress_ents = true;
|
||||
logprint("light entity compression enabled\n");
|
||||
} else if (!strcmp(argv[i], "-colored") ||
|
||||
!strcmp(argv[i], "-coloured")) {
|
||||
colored = true;
|
||||
} else if (!strcmp(argv[i], "-bsp30")) {
|
||||
bsp30 = true;
|
||||
} else if (!strcmp(argv[i], "-lit")) {
|
||||
litfile = true;
|
||||
colored = true;
|
||||
} else if (!strcmp(argv[i], "-nominlimit")) {
|
||||
nominlimit = true;
|
||||
} else if (argv[i][0] == '-')
|
||||
|
|
@ -240,29 +234,13 @@ main(int argc, const char **argv)
|
|||
|
||||
if (numthreads > 1)
|
||||
logprint("running with %d threads\n", numthreads);
|
||||
|
||||
// Switch on colored flag if specifying -lit or -bsp30
|
||||
if (bsp30 || litfile)
|
||||
colored = true;
|
||||
|
||||
// Check the colored options
|
||||
if (colored) {
|
||||
if (!bsp30 && !litfile) {
|
||||
logprint("colored output format not specified -> using bsp 30\n");
|
||||
bsp30 = true;
|
||||
} else if (bsp30 && litfile) {
|
||||
Error("Two colored output formats specified");
|
||||
} else if (litfile) {
|
||||
logprint("colored output format: lit\n");
|
||||
} else if (bsp30) {
|
||||
logprint("colored output format: bsp30\n");
|
||||
}
|
||||
}
|
||||
if (colored)
|
||||
logprint(".lit colored light output requested on command line.\n");
|
||||
|
||||
if (i != argc - 1)
|
||||
Error("usage: light [-threads num] [-light num] [-extra]\n"
|
||||
" [-colored] [-bsp30] [-lit]\n"
|
||||
" [-nocount] [-compress] [-nominlimit] bspfile\n");
|
||||
" [-dist n] [-range n] [-lit] [-compress]\n"
|
||||
" [-nominlimit] bspfile\n");
|
||||
|
||||
start = I_FloatTime();
|
||||
|
||||
|
|
@ -277,13 +255,8 @@ main(int argc, const char **argv)
|
|||
LightWorld();
|
||||
|
||||
WriteEntitiesToString();
|
||||
|
||||
if (colored && bsp30)
|
||||
WriteBSPFile(source, 30);
|
||||
else
|
||||
WriteBSPFile(source, bsp_version);
|
||||
|
||||
if (colored && litfile)
|
||||
WriteBSPFile(source, bsp_version);
|
||||
if (colored)
|
||||
WriteLitFile(source, LIT_VERSION);
|
||||
|
||||
end = I_FloatTime();
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ LightFace(int surfnum, qboolean nolight, const vec3_t faceoffset)
|
|||
int lightmapwidth;
|
||||
int lightmapsize;
|
||||
byte *out;
|
||||
byte *lit_out;
|
||||
byte *lit_out = NULL;
|
||||
vec_t *light;
|
||||
|
||||
vec3_t *lightcolor;
|
||||
|
|
@ -1037,18 +1037,10 @@ LightFace(int surfnum, qboolean nolight, const vec3_t faceoffset)
|
|||
for (i = 0; i < MAXLIGHTMAPS; i++)
|
||||
face->styles[i] = l.lightstyles[i];
|
||||
|
||||
/* Extra room for BSP30 lightmaps */
|
||||
if (colored && bsp30)
|
||||
lightmapsize = size * l.numlightstyles * 4;
|
||||
else
|
||||
lightmapsize = size * l.numlightstyles;
|
||||
|
||||
lightmapsize = size * l.numlightstyles;
|
||||
out = GetFileSpace(lightmapsize);
|
||||
|
||||
if (litfile)
|
||||
if (colored)
|
||||
lit_out = GetLitFileSpace(lightmapsize * 3);
|
||||
else
|
||||
lit_out = NULL; /* Fix compiler warning... */
|
||||
|
||||
face->lightofs = out - filebase;
|
||||
|
||||
|
|
@ -1121,12 +1113,7 @@ LightFace(int surfnum, qboolean nolight, const vec3_t faceoffset)
|
|||
}
|
||||
|
||||
/* Write out the lightmap in the appropriate format */
|
||||
if (colored && bsp30) {
|
||||
*out++ = colors[0];
|
||||
*out++ = colors[1];
|
||||
*out++ = colors[2];
|
||||
}
|
||||
if (colored && litfile) {
|
||||
if (colored) {
|
||||
*lit_out++ = colors[0];
|
||||
*lit_out++ = colors[1];
|
||||
*lit_out++ = colors[2];
|
||||
|
|
|
|||
Loading…
Reference in New Issue