mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 22:10:59 +00:00
maps: cache QBSP in collision map list
This commit is contained in:
parent
98cc9c1ea0
commit
bf81d4e427
16 changed files with 40 additions and 86 deletions
|
@ -103,7 +103,6 @@ cvar_t *r_customwidth;
|
|||
cvar_t *r_customheight;
|
||||
|
||||
cvar_t *r_retexturing;
|
||||
cvar_t *r_maptype;
|
||||
cvar_t *r_scale8bittextures;
|
||||
|
||||
cvar_t *r_nolerp_list;
|
||||
|
@ -1242,7 +1241,6 @@ R_Register(void)
|
|||
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
|
||||
r_validation = ri.Cvar_Get("r_validation", "0", CVAR_ARCHIVE);
|
||||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
|
||||
|
||||
/* don't bilerp characters and crosshairs */
|
||||
r_nolerp_list = ri.Cvar_Get("r_nolerp_list", DEFAULT_NOLERP_LIST, CVAR_ARCHIVE);
|
||||
|
|
|
@ -295,12 +295,10 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||
{
|
||||
int lightgridsize = 0, hunkSize;
|
||||
const bspx_header_t *bspx_header;
|
||||
size_t modfilelen;
|
||||
maptype_t maptype;
|
||||
dheader_t *header;
|
||||
byte *mod_base;
|
||||
|
||||
|
@ -309,10 +307,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
|||
Com_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__);
|
||||
}
|
||||
|
||||
/* Can't detect will use provided */
|
||||
maptype = r_maptype->value;
|
||||
|
||||
mod_base = Mod_Load2QBSP(mod->name, (byte *)buffer, filelen, &modfilelen, &maptype);
|
||||
mod_base = (byte *)buffer;
|
||||
header = (dheader_t *)mod_base;
|
||||
|
||||
/* check for BSPX extensions */
|
||||
|
@ -373,9 +368,6 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
|||
&header->lumps[LUMP_NODES], header->ident);
|
||||
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
|
||||
/* Free QBSP temporary info */
|
||||
free(mod_base);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -494,10 +486,7 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
|
|||
};
|
||||
break;
|
||||
|
||||
case IDBSPHEADER:
|
||||
/* fall through */
|
||||
case RBSPHEADER:
|
||||
/* fall through */
|
||||
/* should have only preloaded formats for maps */
|
||||
case QBSPHEADER:
|
||||
Mod_LoadBrushModel(mod, buf, modfilelen);
|
||||
break;
|
||||
|
|
|
@ -175,7 +175,6 @@ extern cvar_t *r_customwidth;
|
|||
extern cvar_t *r_customheight;
|
||||
|
||||
extern cvar_t *r_retexturing;
|
||||
extern cvar_t *r_maptype;
|
||||
extern cvar_t *r_scale8bittextures;
|
||||
extern cvar_t *r_validation;
|
||||
|
||||
|
|
|
@ -83,7 +83,6 @@ cvar_t *gl_msaa_samples;
|
|||
cvar_t *gl_version_override;
|
||||
cvar_t *r_vsync;
|
||||
cvar_t *r_retexturing;
|
||||
cvar_t *r_maptype;
|
||||
cvar_t *r_scale8bittextures;
|
||||
cvar_t *vid_fullscreen;
|
||||
cvar_t *r_mode;
|
||||
|
@ -212,7 +211,6 @@ GL3_Register(void)
|
|||
gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
|
||||
gl_version_override = ri.Cvar_Get ( "gl_version_override", "0", CVAR_ARCHIVE );
|
||||
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
|
||||
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
|
||||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||
gl3_debugcontext = ri.Cvar_Get("gl3_debugcontext", "0", 0);
|
||||
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
|
||||
|
|
|
@ -296,12 +296,10 @@ Mod_LoadQFaces(gl3model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int filelen)
|
||||
Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
|
||||
{
|
||||
int lightgridsize = 0, hunkSize;
|
||||
const bspx_header_t *bspx_header;
|
||||
size_t modfilelen;
|
||||
maptype_t maptype;
|
||||
dheader_t *header;
|
||||
byte *mod_base;
|
||||
|
||||
|
@ -310,10 +308,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int filelen)
|
|||
Com_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__);
|
||||
}
|
||||
|
||||
/* Can't detect will use provided */
|
||||
maptype = r_maptype->value;
|
||||
|
||||
mod_base = Mod_Load2QBSP(mod->name, (byte *)buffer, filelen, &modfilelen, &maptype);
|
||||
mod_base = (byte *)buffer;
|
||||
header = (dheader_t *)mod_base;
|
||||
|
||||
/* check for BSPX extensions */
|
||||
|
@ -374,9 +369,6 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int filelen)
|
|||
&header->lumps[LUMP_NODES], header->ident);
|
||||
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
|
||||
/* Free QBSP temporary info */
|
||||
free(mod_base);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -495,10 +487,7 @@ Mod_ForName(const char *name, gl3model_t *parent_model, qboolean crash)
|
|||
};
|
||||
break;
|
||||
|
||||
case IDBSPHEADER:
|
||||
/* fall through */
|
||||
case RBSPHEADER:
|
||||
/* fall through */
|
||||
/* should have only preloaded formats for maps */
|
||||
case QBSPHEADER:
|
||||
Mod_LoadBrushModel(mod, buf, modfilelen);
|
||||
break;
|
||||
|
|
|
@ -509,7 +509,6 @@ extern cvar_t *gl_msaa_samples;
|
|||
extern cvar_t *gl_version_override;
|
||||
extern cvar_t *r_vsync;
|
||||
extern cvar_t *r_retexturing;
|
||||
extern cvar_t *r_maptype;
|
||||
extern cvar_t *r_scale8bittextures;
|
||||
extern cvar_t *vid_fullscreen;
|
||||
extern cvar_t *r_mode;
|
||||
|
|
|
@ -79,7 +79,6 @@ cvar_t *gl_msaa_samples;
|
|||
cvar_t *gl_version_override;
|
||||
cvar_t *r_vsync;
|
||||
cvar_t *r_retexturing;
|
||||
cvar_t *r_maptype;
|
||||
cvar_t *r_scale8bittextures;
|
||||
cvar_t *vid_fullscreen;
|
||||
cvar_t *r_mode;
|
||||
|
@ -208,7 +207,6 @@ GL4_Register(void)
|
|||
gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
|
||||
gl_version_override = ri.Cvar_Get ( "gl_version_override", "0", CVAR_ARCHIVE );
|
||||
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
|
||||
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
|
||||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||
gl4_debugcontext = ri.Cvar_Get("gl4_debugcontext", "0", 0);
|
||||
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
|
||||
|
|
|
@ -296,12 +296,10 @@ Mod_LoadQFaces(gl4model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int filelen)
|
||||
Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
|
||||
{
|
||||
int lightgridsize = 0, hunkSize;
|
||||
const bspx_header_t *bspx_header;
|
||||
size_t modfilelen;
|
||||
maptype_t maptype;
|
||||
dheader_t *header;
|
||||
byte *mod_base;
|
||||
|
||||
|
@ -310,10 +308,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int filelen)
|
|||
Com_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__);
|
||||
}
|
||||
|
||||
/* Can't detect will use provided */
|
||||
maptype = r_maptype->value;
|
||||
|
||||
mod_base = Mod_Load2QBSP(mod->name, (byte *)buffer, filelen, &modfilelen, &maptype);
|
||||
mod_base = (byte *)buffer;
|
||||
header = (dheader_t *)mod_base;
|
||||
|
||||
/* check for BSPX extensions */
|
||||
|
@ -374,9 +369,6 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int filelen)
|
|||
&header->lumps[LUMP_NODES], header->ident);
|
||||
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
|
||||
/* Free QBSP temporary info */
|
||||
free(mod_base);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -495,10 +487,7 @@ Mod_ForName(const char *name, gl4model_t *parent_model, qboolean crash)
|
|||
};
|
||||
break;
|
||||
|
||||
case IDBSPHEADER:
|
||||
/* fall through */
|
||||
case RBSPHEADER:
|
||||
/* fall through */
|
||||
/* should have only preloaded formats for maps */
|
||||
case QBSPHEADER:
|
||||
Mod_LoadBrushModel(mod, buf, modfilelen);
|
||||
break;
|
||||
|
|
|
@ -499,7 +499,6 @@ extern cvar_t *gl_msaa_samples;
|
|||
extern cvar_t *gl_version_override;
|
||||
extern cvar_t *r_vsync;
|
||||
extern cvar_t *r_retexturing;
|
||||
extern cvar_t *r_maptype;
|
||||
extern cvar_t *r_scale8bittextures;
|
||||
extern cvar_t *vid_fullscreen;
|
||||
extern cvar_t *r_mode;
|
||||
|
|
|
@ -398,7 +398,6 @@ extern cvar_t *sw_waterwarp;
|
|||
extern cvar_t *sw_gunzposition;
|
||||
extern cvar_t *r_validation;
|
||||
extern cvar_t *r_retexturing;
|
||||
extern cvar_t *r_maptype;
|
||||
extern cvar_t *r_scale8bittextures;
|
||||
extern cvar_t *r_palettedtexture;
|
||||
|
||||
|
|
|
@ -152,7 +152,6 @@ cvar_t *sw_custom_particles;
|
|||
static cvar_t *sw_anisotropic;
|
||||
cvar_t *sw_texture_filtering;
|
||||
cvar_t *r_retexturing;
|
||||
cvar_t *r_maptype;
|
||||
cvar_t *r_scale8bittextures;
|
||||
cvar_t *sw_gunzposition;
|
||||
cvar_t *r_validation;
|
||||
|
@ -387,7 +386,6 @@ R_RegisterVariables (void)
|
|||
sw_texture_filtering = ri.Cvar_Get("sw_texture_filtering", "0", CVAR_ARCHIVE);
|
||||
sw_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
|
||||
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
|
||||
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
|
||||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||
sw_gunzposition = ri.Cvar_Get("sw_gunzposition", "8", CVAR_ARCHIVE);
|
||||
r_validation = ri.Cvar_Get("r_validation", "0", CVAR_ARCHIVE);
|
||||
|
|
|
@ -303,12 +303,10 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||
{
|
||||
int lightgridsize = 0, hunkSize;
|
||||
const bspx_header_t *bspx_header;
|
||||
size_t modfilelen;
|
||||
maptype_t maptype;
|
||||
dheader_t *header;
|
||||
byte *mod_base;
|
||||
|
||||
|
@ -317,10 +315,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
|||
Com_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__);
|
||||
}
|
||||
|
||||
/* Can't detect will use provided */
|
||||
maptype = r_maptype->value;
|
||||
|
||||
mod_base = Mod_Load2QBSP(mod->name, (byte *)buffer, filelen, &modfilelen, &maptype);
|
||||
mod_base = (byte *)buffer;
|
||||
header = (dheader_t *)mod_base;
|
||||
|
||||
/* check for BSPX extensions */
|
||||
|
@ -381,9 +376,6 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
|||
mod->numframes = 2; /* regular and alternate animation */
|
||||
|
||||
R_InitSkyBox(mod);
|
||||
|
||||
/* Free QBSP temporary info */
|
||||
free(mod_base);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -502,10 +494,7 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
|
|||
};
|
||||
break;
|
||||
|
||||
case IDBSPHEADER:
|
||||
/* fall through */
|
||||
case RBSPHEADER:
|
||||
/* fall through */
|
||||
/* should have only preloaded formats for maps */
|
||||
case QBSPHEADER:
|
||||
Mod_LoadBrushModel(mod, buf, modfilelen);
|
||||
break;
|
||||
|
|
|
@ -142,7 +142,6 @@ extern cvar_t *vk_molten_fastmath;
|
|||
extern cvar_t *vk_molten_metalbuffers;
|
||||
#endif
|
||||
extern cvar_t *r_retexturing;
|
||||
extern cvar_t *r_maptype;
|
||||
extern cvar_t *r_scale8bittextures;
|
||||
extern cvar_t *r_nolerp_list;
|
||||
extern cvar_t *r_lerp_list;
|
||||
|
|
|
@ -132,7 +132,6 @@ cvar_t *vk_mip_nearfilter;
|
|||
cvar_t *vk_sampleshading;
|
||||
cvar_t *vk_device_idx;
|
||||
cvar_t *r_retexturing;
|
||||
cvar_t *r_maptype;
|
||||
cvar_t *r_scale8bittextures;
|
||||
static cvar_t *vk_underwater;
|
||||
cvar_t *r_nolerp_list;
|
||||
|
@ -1178,7 +1177,6 @@ R_Register(void)
|
|||
vk_molten_metalbuffers = ri.Cvar_Get("vk_molten_metalbuffer", "0", CVAR_ARCHIVE);
|
||||
#endif
|
||||
r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
|
||||
r_maptype = ri.Cvar_Get("maptype", "0", CVAR_ARCHIVE);
|
||||
r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE);
|
||||
vk_underwater = ri.Cvar_Get("vk_underwater", "1", CVAR_ARCHIVE);
|
||||
/* don't bilerp characters and crosshairs */
|
||||
|
|
|
@ -270,12 +270,10 @@ Mod_LoadQFaces(model_t *loadmodel, const byte *mod_base, const lump_t *l,
|
|||
}
|
||||
|
||||
static void
|
||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
||||
Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
|
||||
{
|
||||
int lightgridsize = 0, hunkSize;
|
||||
const bspx_header_t *bspx_header;
|
||||
size_t modfilelen;
|
||||
maptype_t maptype;
|
||||
dheader_t *header;
|
||||
byte *mod_base;
|
||||
|
||||
|
@ -284,10 +282,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
|||
Com_Error(ERR_DROP, "%s: Loaded a brush model after the world", __func__);
|
||||
}
|
||||
|
||||
/* Can't detect will use provided */
|
||||
maptype = r_maptype->value;
|
||||
|
||||
mod_base = Mod_Load2QBSP(mod->name, (byte *)buffer, filelen, &modfilelen, &maptype);
|
||||
mod_base = (byte *)buffer;
|
||||
header = (dheader_t *)mod_base;
|
||||
|
||||
/* check for BSPX extensions */
|
||||
|
@ -348,9 +343,6 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int filelen)
|
|||
&header->lumps[LUMP_NODES], header->ident);
|
||||
Mod_LoadSubmodels(mod, mod_base, &header->lumps[LUMP_MODELS]);
|
||||
mod->numframes = 2; /* regular and alternate animation */
|
||||
|
||||
/* Free QBSP temporary info */
|
||||
free(mod_base);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -478,10 +470,7 @@ Mod_ForName(const char *name, model_t *parent_model, qboolean crash)
|
|||
};
|
||||
break;
|
||||
|
||||
case IDBSPHEADER:
|
||||
/* fall through */
|
||||
case RBSPHEADER:
|
||||
/* fall through */
|
||||
/* should have only preloaded formats for maps */
|
||||
case QBSPHEADER:
|
||||
Mod_LoadBrushModel(mod, buf, modfilelen);
|
||||
break;
|
||||
|
|
|
@ -71,6 +71,8 @@ typedef struct
|
|||
{
|
||||
char name[MAX_QPATH];
|
||||
unsigned checksum;
|
||||
char *cache; /* raw converted map */
|
||||
int cache_size;
|
||||
|
||||
cleaf_t *map_leafs;
|
||||
int emptyleaf;
|
||||
|
@ -1743,7 +1745,7 @@ CM_ModFreeAll(void)
|
|||
static void
|
||||
CM_LoadCachedMap(const char *name, model_t *mod)
|
||||
{
|
||||
int filelen, hunkSize = 0;
|
||||
int filelen, hunkSize;
|
||||
byte *cmod_base, *filebuf;
|
||||
maptype_t maptype;
|
||||
dheader_t *header;
|
||||
|
@ -1767,6 +1769,7 @@ CM_LoadCachedMap(const char *name, model_t *mod)
|
|||
/* load into heap */
|
||||
strcpy(mod->name, name);
|
||||
|
||||
hunkSize = length; /* allocate memory for future maps cache */
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_TEXINFO],
|
||||
sizeof(xtexinfo_t), sizeof(mapsurface_t), EXTRA_LUMP_TEXINFO);
|
||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
|
||||
|
@ -1794,6 +1797,10 @@ CM_LoadCachedMap(const char *name, model_t *mod)
|
|||
|
||||
mod->extradata = Hunk_Begin(hunkSize);
|
||||
|
||||
mod->cache = Hunk_Alloc(length);
|
||||
memcpy(mod->cache, cmod_base, length);
|
||||
mod->cache_size = length;
|
||||
|
||||
CMod_LoadSurfaces(mod->name, &mod->map_surfaces, &mod->numtexinfo,
|
||||
cmod_base, &header->lumps[LUMP_TEXINFO]);
|
||||
CMod_LoadLeafs(mod->name, &mod->map_leafs, &mod->numleafs, &mod->emptyleaf,
|
||||
|
@ -2120,5 +2127,22 @@ CM_ClusterPHS(int cluster)
|
|||
int
|
||||
CM_LoadFile(const char *path, void **buffer)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_MOD_KNOWN; i++)
|
||||
{
|
||||
/* we have already cached */
|
||||
if (!strcmp(path, models[i].name) &&
|
||||
models[i].cache &&
|
||||
models[i].extradatasize)
|
||||
{
|
||||
*buffer = Z_Malloc(models[i].cache_size);
|
||||
memcpy(*buffer, models[i].cache, models[i].cache_size);
|
||||
return models[i].cache_size;
|
||||
}
|
||||
}
|
||||
|
||||
Com_Printf("%s: render asked about '%s' but have loaded it yet?\n",
|
||||
__func__, path);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue