new defaults: snd_khz 44/gl_overbright 1/r_lightmap_shift 1, merge mdl alias frame code, report .bsp missing instead of .cm

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3744 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2011-03-03 17:09:15 +00:00
parent c75305f9bf
commit b558134529
7 changed files with 108 additions and 262 deletions

View file

@ -121,15 +121,10 @@ typedef struct {
typedef struct {
dtrivertx_t bboxmin; // lightnormal isn't used
dtrivertx_t bboxmax; // lightnormal isn't used
// qtest stops here
char name[16]; // frame name from grabbing
} daliasframe_t;
typedef struct {
dtrivertx_t bboxmin; // lightnormal isn't used
dtrivertx_t bboxmax; // lightnormal isn't used
// no name[16]!
} qtestaliasframe_t;
typedef struct {
int numframes;
dtrivertx_t bboxmin; // lightnormal isn't used

View file

@ -64,6 +64,21 @@ int Surf_LightmapShift (model_t *model)
return 0;
}
void Surf_RebuildLightmap (void)
{
int i;
msurface_t *surf;
if (cl.worldmodel)
for (i=0, surf = cl.worldmodel->surfaces; i<cl.worldmodel->numsurfaces ; i++, surf++)
surf->cached_dlight=-1;//force it
}
void Surf_RebuildLightmap_Callback (struct cvar_s *var, char *oldvalue)
{
Surf_RebuildLightmap();
}
//radius, x y z, r g b
void Surf_StainSurf (msurface_t *surf, float *parms)
{
@ -256,15 +271,6 @@ void Surf_LessenStains(void)
static float time;
extern cvar_t gl_lightmap_shift;
if (gl_lightmap_shift.modified)
{
gl_lightmap_shift.modified = 0;
for (i=0, surf = cl.worldmodel->surfaces; i<cl.worldmodel->numsurfaces ; i++, surf++)
surf->cached_dlight=-1;//force it
}
if (!r_stains.value)
return;

View file

@ -208,7 +208,7 @@ extern texid_t *deluxmap_textures;
extern int lightmap_bytes; // 1, 3, or 4
extern qboolean lightmap_bgra; /*true=bgra, false=rgba*/
#endif
void Surf_RebuildLightmap_Callback (struct cvar_s *var, char *oldvalue);
void R_SetSky(char *skyname); /*override all sky shaders*/

View file

@ -260,8 +260,9 @@ cvar_t gl_font = SCVARF ("gl_font", "",
CVAR_RENDERERCALLBACK);
cvar_t gl_lateswap = SCVAR ("gl_lateswap", "0");
cvar_t gl_lerpimages = SCVAR ("gl_lerpimages", "1");
cvar_t gl_lightmap_shift = SCVARF ("gl_lightmap_shift", "0",
CVAR_ARCHIVE);
cvar_t gl_lightmap_shift = CVARFC ("gl_lightmap_shift", "1",
CVAR_ARCHIVE,
Surf_RebuildLightmap_Callback);
//cvar_t gl_lightmapmode = SCVARF("gl_lightmapmode", "",
// CVAR_ARCHIVE);
cvar_t gl_load24bit = SCVARF ("gl_load24bit", "1",
@ -281,7 +282,7 @@ cvar_t gl_mindist = SCVARF ("gl_mindist", "4",
cvar_t gl_motionblur = SCVARF ("gl_motionblur", "0",
CVAR_ARCHIVE);
cvar_t gl_motionblurscale = SCVAR ("gl_motionblurscale", "1");
cvar_t gl_overbright = SCVARF ("gl_overbright", "0",
cvar_t gl_overbright = SCVARF ("gl_overbright", "1",
CVAR_ARCHIVE);
cvar_t gl_overbright_all = SCVARF ("gl_overbright_all", "0",
CVAR_ARCHIVE);

View file

@ -76,7 +76,7 @@ cvar_t snd_noextraupdate = CVARAF( "s_noextraupdate", "0",
"snd_noextraupdate", 0);
cvar_t snd_show = CVARAF( "s_show", "0",
"snd_show", 0);
cvar_t snd_khz = CVARAF( "s_khz", "11",
cvar_t snd_khz = CVARAF( "s_khz", "44",
"snd_khz", CVAR_ARCHIVE);
cvar_t snd_inactive = CVARAF( "s_inactive", "0",
"snd_inactive", 0); //set if you want sound even when tabbed out.

View file

@ -1875,76 +1875,8 @@ static galiasinfo_t *galias;
static dmdl_t *pq1inmodel;
#define NUMVERTEXNORMALS 162
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
static void *QTest_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
{
galiaspose_t *pose;
galiasgroup_t *frame;
dtrivertx_t *pinframe;
qtestaliasframe_t *frameinfo;
int i, j;
vec3_t *normals, *svec, *tvec;
vecV_t *verts;
frame = (galiasgroup_t*)((char *)galias + galias->groupofs);
for (i = 0; i < pq1inmodel->numframes; i++)
{
switch(LittleLong(pframetype->type))
{
case ALIAS_SINGLE:
frameinfo = (qtestaliasframe_t*)((char *)(pframetype+1));
pinframe = (dtrivertx_t*)((char*)frameinfo+sizeof(qtestaliasframe_t));
pose = (galiaspose_t *)Hunk_Alloc(sizeof(galiaspose_t) + (sizeof(vecV_t)+sizeof(vec3_t)*3)*galias->numverts);
frame->poseofs = (char *)pose - (char *)frame;
frame->numposes = 1;
galias->groups++;
frame->name[0] = '\0';
verts = (vecV_t *)(pose+1);
normals = &verts[galias->numverts];
pose->ofsverts = (char *)verts - (char *)pose;
#ifndef SERVERONLY
normals = (vec3_t*)&verts[galias->numverts];
svec = &normals[galias->numverts];
tvec = &svec[galias->numverts];
pose->ofsnormals = (char *)normals - (char *)pose;
pose->ofssvector = (char *)svec - (char *)pose;
pose->ofstvector = (char *)tvec - (char *)pose;
#endif
for (j = 0; j < pq1inmodel->numverts; j++)
{
verts[j][0] = pinframe[j].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[j].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[j].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[j].lightnormalindex], normals[j]);
#endif
if (seamremaps[j] != j)
{
VectorCopy(verts[j], verts[seamremaps[j]]);
#ifndef SERVERONLY
VectorCopy(normals[j], normals[seamremaps[j]]);
#endif
}
}
// GL_GenerateNormals((float*)verts, (float*)normals, (int *)((char *)galias + galias->ofs_indexes), galias->numindexes/3, galias->numverts);
pframetype = (daliasframetype_t *)&pinframe[pq1inmodel->numverts];
break;
default:
Con_Printf(CON_ERROR "Bad frame type for QTest model in %s\n", loadmodel->name);
return NULL;
}
frame++;
}
return pframetype;
}
static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
// mdltype 0 = q1, 1 = qtest, 2 = rapo/h2
static void *Alias_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps, int mdltype)
{
galiaspose_t *pose;
galiasgroup_t *frame;
@ -1957,6 +1889,9 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
vec3_t *normals, *svec, *tvec;
vecV_t *verts;
int aliasframesize;
aliasframesize = (mdltype == 1) ? sizeof(daliasframe_t)-16 : sizeof(daliasframe_t);
frame = (galiasgroup_t*)((char *)galias + galias->groupofs);
@ -1965,14 +1900,17 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
switch(LittleLong(pframetype->type))
{
case ALIAS_SINGLE:
frameinfo = (daliasframe_t*)((char *)(pframetype+1));
pinframe = (dtrivertx_t*)((char*)frameinfo+sizeof(daliasframe_t));
frameinfo = (daliasframe_t*)((char *)(pframetype+1)); // qtest aliasframe is a subset
pinframe = (dtrivertx_t*)((char*)frameinfo+aliasframesize);
pose = (galiaspose_t *)Hunk_Alloc(sizeof(galiaspose_t) + (sizeof(vecV_t)+sizeof(vec3_t)*3)*galias->numverts);
frame->poseofs = (char *)pose - (char *)frame;
frame->numposes = 1;
galias->groups++;
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
if (mdltype == 1)
frame->name[0] = '\0';
else
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
verts = (vecV_t *)(pose+1);
pose->ofsverts = (char *)verts - (char *)pose;
@ -1987,22 +1925,37 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
#pragma message("wasted memory")
#endif
for (j = 0; j < pq1inmodel->numverts; j++)
if (mdltype == 2)
{
verts[j][0] = pinframe[j].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[j].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[j].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[j].lightnormalindex], normals[j]);
#endif
if (seamremaps[j] != j)
for (j = 0; j < galias->numverts; j++)
{
VectorCopy(verts[j], verts[seamremaps[j]]);
verts[j][0] = pinframe[seamremaps[j]].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[seamremaps[j]].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[seamremaps[j]].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(normals[j], normals[seamremaps[j]]);
VectorCopy(r_avertexnormals[pinframe[seamremaps[j]].lightnormalindex], normals[j]);
#endif
}
}
else
{
for (j = 0; j < pq1inmodel->numverts; j++)
{
verts[j][0] = pinframe[j].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[j].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[j].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[j].lightnormalindex], normals[j]);
#endif
if (seamremaps[j] != j)
{
VectorCopy(verts[j], verts[seamremaps[j]]);
#ifndef SERVERONLY
VectorCopy(normals[j], normals[seamremaps[j]]);
#endif
}
}
}
// GL_GenerateNormals((float*)verts, (float*)normals, (int *)((char *)galias + galias->ofs_indexes), galias->numindexes/3, galias->numverts);
@ -2046,27 +1999,48 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
#endif
frameinfo = (daliasframe_t*)pinframe;
pinframe = (dtrivertx_t *)((char *)frameinfo + sizeof(daliasframe_t));
pinframe = (dtrivertx_t *)((char *)frameinfo + aliasframesize);
if (k == 0)
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
for (j = 0; j < pq1inmodel->numverts; j++)
{
verts[j][0] = pinframe[j].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[j].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[j].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[j].lightnormalindex], normals[j]);
#endif
if (seamremaps[j] != j)
if (mdltype == 1)
frame->name[0] = '\0';
else
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
}
if (mdltype == 2)
{
for (j = 0; j < galias->numverts; j++)
{
VectorCopy(verts[j], verts[seamremaps[j]]);
verts[j][0] = pinframe[seamremaps[j]].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[seamremaps[j]].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[seamremaps[j]].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(normals[j], normals[seamremaps[j]]);
VectorCopy(r_avertexnormals[pinframe[seamremaps[j]].lightnormalindex], normals[j]);
#endif
}
}
else
{
for (j = 0; j < pq1inmodel->numverts; j++)
{
verts[j][0] = pinframe[j].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[j].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[j].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[j].lightnormalindex], normals[j]);
#endif
if (seamremaps[j] != j)
{
VectorCopy(verts[j], verts[seamremaps[j]]);
#ifndef SERVERONLY
VectorCopy(normals[j], normals[seamremaps[j]]);
#endif
}
}
}
#ifndef SERVERONLY
verts = (vecV_t*)&tvec[galias->numverts];
normals = (vec3_t*)&verts[galias->numverts];
@ -2093,132 +2067,6 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
return pframetype;
}
static void *H2_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
{
galiaspose_t *pose;
galiasgroup_t *frame;
dtrivertx_t *pinframe;
daliasframe_t *frameinfo;
int i, j, k;
daliasgroup_t *ingroup;
daliasinterval_t *intervals;
float sinter;
vec3_t *normals, *svec, *tvec;
vecV_t *verts;
frame = (galiasgroup_t*)((char *)galias + galias->groupofs);
for (i = 0; i < pq1inmodel->numframes; i++)
{
switch(LittleLong(pframetype->type))
{
case ALIAS_SINGLE:
frameinfo = (daliasframe_t*)((char *)(pframetype+1));
pinframe = (dtrivertx_t*)((char*)frameinfo+sizeof(daliasframe_t));
pose = (galiaspose_t *)Hunk_Alloc(sizeof(galiaspose_t) + (sizeof(vecV_t)+sizeof(vec3_t)*3)*galias->numverts);
frame->poseofs = (char *)pose - (char *)frame;
frame->numposes = 1;
galias->groups++;
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
verts = (vecV_t *)(pose+1);
normals = (vec3_t*)&verts[galias->numverts];
svec = &normals[galias->numverts];
tvec = &svec[galias->numverts];
pose->ofsverts = (char *)verts - (char *)pose;
#ifndef SERVERONLY
pose->ofsnormals = (char *)normals - (char *)pose;
pose->ofssvector = (char *)svec - (char *)pose;
pose->ofstvector = (char *)tvec - (char *)pose;
#else
#pragma message("wasted memory")
#endif
for (j = 0; j < galias->numverts; j++)
{
verts[j][0] = pinframe[seamremaps[j]].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[seamremaps[j]].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[seamremaps[j]].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[seamremaps[j]].lightnormalindex], normals[j]);
#endif
}
// GL_GenerateNormals((float*)verts, (float*)normals, (int *)((char *)galias + galias->ofs_indexes), galias->numindexes/3, galias->numverts);
pframetype = (daliasframetype_t *)&pinframe[pq1inmodel->numverts];
break;
case ALIAS_GROUP:
case ALIAS_GROUP_SWAPPED: // prerelease
ingroup = (daliasgroup_t *)(pframetype+1);
pose = (galiaspose_t *)Hunk_Alloc(LittleLong(ingroup->numframes)*(sizeof(galiaspose_t) + (sizeof(vecV_t)+sizeof(vec3_t)*3)*galias->numverts));
frame->poseofs = (char *)pose - (char *)frame;
frame->numposes = LittleLong(ingroup->numframes);
frame->loop = true;
galias->groups++;
verts = (vecV_t *)(pose+frame->numposes);
normals = (vec3_t*)&verts[galias->numverts];
svec = &normals[galias->numverts];
tvec = &svec[galias->numverts];
intervals = (daliasinterval_t *)(ingroup+1);
sinter = LittleFloat(intervals->interval);
if (sinter <= 0)
sinter = 0.1;
frame->rate = 1/sinter;
pinframe = (dtrivertx_t *)(intervals+frame->numposes);
for (k = 0; k < frame->numposes; k++)
{
pose->ofsverts = (char *)verts - (char *)pose;
#ifndef SERVERONLY
pose->ofsnormals = (char *)normals - (char *)pose;
pose->ofssvector = (char *)svec - (char *)pose;
pose->ofstvector = (char *)tvec - (char *)pose;
#endif
frameinfo = (daliasframe_t*)pinframe;
pinframe = (dtrivertx_t *)((char *)frameinfo + sizeof(daliasframe_t));
if (k == 0)
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
for (j = 0; j < galias->numverts; j++)
{
verts[j][0] = pinframe[seamremaps[j]].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
verts[j][1] = pinframe[seamremaps[j]].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
verts[j][2] = pinframe[seamremaps[j]].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
#ifndef SERVERONLY
VectorCopy(r_avertexnormals[pinframe[seamremaps[j]].lightnormalindex], normals[j]);
#endif
}
verts = (vecV_t*)&tvec[galias->numverts];
normals = (vec3_t*)&verts[galias->numverts];
svec = &normals[galias->numverts];
tvec = &svec[galias->numverts];
pose++;
pinframe += pq1inmodel->numverts;
}
// GL_GenerateNormals((float*)verts, (float*)normals, (int *)((char *)galias + galias->ofs_indexes), galias->numindexes/3, galias->numverts);
pframetype = (daliasframetype_t *)pinframe;
break;
default:
Con_Printf(CON_ERROR "Bad frame type in %s\n", loadmodel->name);
return NULL;
}
frame++;
}
return pframetype;
}
//greatly reduced version of Q1_LoadSkins
//just skips over the data
static void *Q1_LoadSkins_SV (daliasskintype_t *pskintype, qboolean alpha)
@ -2518,6 +2366,8 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer)
int size;
unsigned int hdrsize;
void *end;
qboolean qtest = false;
qboolean rapo = false;
loadmodel=mod;
@ -2532,10 +2382,14 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer)
version = LittleLong(pq1inmodel->version);
if (version == QTESTALIAS_VERSION)
{
hdrsize = sizeof(dmdl_t) - sizeof(int)*3;
hdrsize = (unsigned int)&((dmdl_t*)NULL)->flags;
qtest = true;
}
else if (version == 50)
{
hdrsize = sizeof(dmdl_t);
rapo = true;
}
else if (version != ALIAS_VERSION)
{
Con_Printf (CON_ERROR "%s has wrong version number (%i should be %i)\n",
@ -2561,7 +2415,7 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer)
return false;
}
if (hdrsize <= (unsigned int)&((dmdl_t*)NULL)->flags)
if (qtest)
mod->flags = 0; // Qtest has no flags in header
else
mod->flags = pq1inmodel->flags;
@ -2604,7 +2458,7 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer)
break;
}
if (hdrsize == sizeof(dmdl_t))
if (rapo)
{
/*each triangle can use one coord and one st, for each vert, that's a lot of combinations*/
#ifdef SERVERONLY
@ -2680,7 +2534,7 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer)
#endif
end = &pinh2triangles[pq1inmodel->numtris];
if (H2_LoadFrameGroup((daliasframetype_t *)end, seamremap) == NULL)
if (Alias_LoadFrameGroup((daliasframetype_t *)end, seamremap, 2) == NULL)
{
BZ_Free(seamremap);
Hunk_FreeToLowMark (hunkstart);
@ -2756,23 +2610,11 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer)
end = &pinq1triangles[pq1inmodel->numtris];
//frames
if (hdrsize <= (unsigned int)&((dmdl_t*)NULL)->flags)
if (Alias_LoadFrameGroup((daliasframetype_t *)end, seamremap, qtest ? 1 : 0) == NULL)
{
if (QTest_LoadFrameGroup((daliasframetype_t *)end, seamremap) == NULL)
{
BZ_Free(seamremap);
Hunk_FreeToLowMark (hunkstart);
return false;
}
}
else
{
if (Q1_LoadFrameGroup((daliasframetype_t *)end, seamremap) == NULL)
{
BZ_Free(seamremap);
Hunk_FreeToLowMark (hunkstart);
return false;
}
BZ_Free(seamremap);
Hunk_FreeToLowMark (hunkstart);
return false;
}
BZ_Free(seamremap);
}

View file

@ -539,6 +539,8 @@ void SV_Map_f (void)
snprintf (expanded, sizeof(expanded), "maps/%s.cm", level);
if (!COM_FCheckExists (expanded))
{
// FTE is still a Quake engine so report BSP missing
snprintf (expanded, sizeof(expanded), "maps/%s.bsp", level);
Con_TPrintf (STL_CANTFINDMAP, expanded);
return;
}