mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[models] Move brush data into its own struct
This is a big step towards a cleaner api. The struct reference in model_t really should be a pointer, but bsp submodel(?) loading messed that up, though that's just a matter of taking more care in the loading code. It seems sensible to make that a separate step.
This commit is contained in:
parent
6969adf02c
commit
34dc7cf2df
54 changed files with 607 additions and 527 deletions
|
@ -50,6 +50,6 @@ void gl_lightmap_init (void);
|
|||
void GL_BuildLightmaps (struct model_s **models, int num_models);
|
||||
void R_BlendLightmaps (void);
|
||||
void R_CalcLightmaps (void);
|
||||
extern void (*R_BuildLightMap) (msurface_t *surf);
|
||||
extern void (*R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
||||
|
||||
#endif // __QF_GL_lightmap_h
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
void glsl_lightmap_init (void);
|
||||
void glsl_R_BuildLightmaps (struct model_s **models, int num_models);
|
||||
void glsl_R_CalcLightmaps (void);
|
||||
extern void (*glsl_R_BuildLightMap) (msurface_t *surf);
|
||||
extern void (*glsl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
||||
int glsl_R_LightmapTexture (void) __attribute__((pure));
|
||||
void glsl_R_FlushLightmaps (void);
|
||||
|
||||
|
|
|
@ -36,12 +36,13 @@
|
|||
|
||||
struct vulkan_ctx_s;
|
||||
struct model_s;
|
||||
struct mod_brush_s;
|
||||
struct msurface_s;
|
||||
|
||||
void Vulkan_lightmap_init (struct vulkan_ctx_s *ctx);
|
||||
void Vulkan_BuildLightmaps (struct model_s **models, int num_models, struct vulkan_ctx_s *ctx);
|
||||
void Vulkan_CalcLightmaps (struct vulkan_ctx_s *ctx);
|
||||
void Vulkan_BuildLightMap (struct msurface_s *surf, struct vulkan_ctx_s *ctx);
|
||||
void Vulkan_BuildLightMap (struct mod_brush_s *brush, struct msurface_s *surf, struct vulkan_ctx_s *ctx);
|
||||
VkImageView Vulkan_LightmapImageView (struct vulkan_ctx_s *ctx) __attribute__((pure));
|
||||
void Vulkan_FlushLightmaps (struct vulkan_ctx_s *ctx);
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ typedef struct efrag_s {
|
|||
struct efrag_s *entnext;
|
||||
} efrag_t;
|
||||
|
||||
|
||||
// in memory representation ===================================================
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
|
@ -228,6 +227,58 @@ typedef struct hull_s {
|
|||
int depth; ///< maximum depth of the tree
|
||||
} hull_t;
|
||||
|
||||
typedef struct mod_brush_s {
|
||||
int firstmodelsurface, nummodelsurfaces;
|
||||
|
||||
int numsubmodels;
|
||||
dmodel_t *submodels;
|
||||
|
||||
int numplanes;
|
||||
plane_t *planes;
|
||||
|
||||
int numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *leafs;
|
||||
|
||||
int numvertexes;
|
||||
mvertex_t *vertexes;
|
||||
|
||||
int numedges;
|
||||
medge_t *edges;
|
||||
|
||||
int numnodes;
|
||||
mnode_t *nodes;
|
||||
int depth; ///< maximum depth of the tree
|
||||
|
||||
int numtexinfo;
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
int numsurfaces;
|
||||
msurface_t *surfaces;
|
||||
|
||||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int numclipnodes;
|
||||
mclipnode_t *clipnodes;
|
||||
|
||||
int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
hull_t hulls[MAX_MAP_HULLS];
|
||||
hull_t *hull_list[MAX_MAP_HULLS];
|
||||
|
||||
int numtextures;
|
||||
texture_t **textures;
|
||||
texture_t *skytexture;
|
||||
|
||||
byte *visdata;
|
||||
byte *lightdata;
|
||||
char *entities; //FIXME should not be here
|
||||
|
||||
unsigned int checksum;
|
||||
unsigned int checksum2;
|
||||
} mod_brush_t;
|
||||
|
||||
// SPRITE MODELS ==============================================================
|
||||
|
||||
// FIXME: shorten these?
|
||||
|
@ -375,55 +426,8 @@ typedef struct model_s {
|
|||
vec3_t clipmins, clipmaxs;
|
||||
|
||||
// brush model
|
||||
int firstmodelsurface, nummodelsurfaces;
|
||||
|
||||
int numsubmodels;
|
||||
dmodel_t *submodels;
|
||||
|
||||
int numplanes;
|
||||
plane_t *planes;
|
||||
|
||||
int numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *leafs;
|
||||
|
||||
int numvertexes;
|
||||
mvertex_t *vertexes;
|
||||
|
||||
int numedges;
|
||||
medge_t *edges;
|
||||
|
||||
int numnodes;
|
||||
mnode_t *nodes;
|
||||
int depth; ///< maximum depth of the tree
|
||||
|
||||
int numtexinfo;
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
int numsurfaces;
|
||||
msurface_t *surfaces;
|
||||
|
||||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int numclipnodes;
|
||||
mclipnode_t *clipnodes;
|
||||
|
||||
int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
hull_t hulls[MAX_MAP_HULLS];
|
||||
hull_t *hull_list[MAX_MAP_HULLS];
|
||||
|
||||
int numtextures;
|
||||
texture_t **textures;
|
||||
texture_t *skytexture;
|
||||
|
||||
byte *visdata;
|
||||
byte *lightdata;
|
||||
char *entities;
|
||||
|
||||
unsigned int checksum;
|
||||
unsigned int checksum2;
|
||||
//FIXME should be a pointer (submodels make things tricky)
|
||||
mod_brush_t brush;
|
||||
|
||||
// additional model data
|
||||
cache_user_t cache;
|
||||
|
|
|
@ -149,7 +149,7 @@ typedef struct vid_render_funcs_s {
|
|||
void (*R_ClearState) (void);
|
||||
void (*R_LoadSkys) (const char *);
|
||||
void (*R_NewMap) (model_t *worldmodel, model_t **models, int num_models);
|
||||
void (*R_AddEfrags) (entity_t *ent);
|
||||
void (*R_AddEfrags) (mod_brush_t *brush, entity_t *ent);
|
||||
void (*R_RemoveEfrags) (entity_t *ent);
|
||||
void (*R_EnqueueEntity) (struct entity_s *ent); //FIXME should not be here
|
||||
void (*R_LineGraph) (int x, int y, int *h_vals, int count);
|
||||
|
|
|
@ -83,7 +83,7 @@ void R_RenderView (void); // must set r_refdef first
|
|||
void R_ViewChanged (float aspect); // must set r_refdef first
|
||||
// called whenever r_refdef or vid change
|
||||
|
||||
void R_AddEfrags (entity_t *ent);
|
||||
void R_AddEfrags (mod_brush_t *, entity_t *ent);
|
||||
void R_RemoveEfrags (entity_t *ent);
|
||||
|
||||
void R_NewMap (model_t *worldmodel, model_t **models, int num_models);
|
||||
|
|
|
@ -182,7 +182,7 @@ void R_RemoveEdges (edge_t *pedge);
|
|||
void R_AddTexture (texture_t *tex);
|
||||
struct vulkan_ctx_s;
|
||||
void R_ClearTextures (void);
|
||||
void R_InitSurfaceChains (model_t *model);
|
||||
void R_InitSurfaceChains (mod_brush_t *brush);
|
||||
|
||||
extern void R_Surf8Start (void);
|
||||
extern void R_Surf8End (void);
|
||||
|
@ -303,13 +303,13 @@ void R_ZGraph (void);
|
|||
void R_PrintAliasStats (void);
|
||||
void R_PrintTimes (void);
|
||||
void R_AnimateLight (void);
|
||||
int R_LightPoint (const vec3_t p);
|
||||
int R_LightPoint (mod_brush_t *brush, const vec3_t p);
|
||||
void R_SetupFrame (void);
|
||||
void R_cshift_f (void);
|
||||
void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1);
|
||||
void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip);
|
||||
void R_RecursiveMarkLights (const vec3_t lightorigin, struct dlight_s *light,
|
||||
int bit, mnode_t *node);
|
||||
void R_RecursiveMarkLights (mod_brush_t *brush, const vec3_t lightorigin,
|
||||
struct dlight_s *light, int bit, mnode_t *node);
|
||||
void R_MarkLights (const vec3_t lightorigin, struct dlight_s *light, int bit,
|
||||
model_t *model);
|
||||
|
||||
|
|
|
@ -150,9 +150,10 @@ gl_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
|
|||
size_t i;
|
||||
int ver;
|
||||
QFile *lit_file;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
dstring_copystr (litfilename, mod->path);
|
||||
mod->lightdata = NULL;
|
||||
brush->lightdata = NULL;
|
||||
if (mod_lightmap_bytes > 1) {
|
||||
// LordHavoc: check for a .lit file to load
|
||||
QFS_StripExtension (litfilename->str, litfilename->str);
|
||||
|
@ -165,7 +166,7 @@ gl_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
|
|||
ver = LittleLong (((int32_t *) data)[1]);
|
||||
if (ver == 1) {
|
||||
Sys_MaskPrintf (SYS_DEV, "%s loaded", litfilename->str);
|
||||
mod->lightdata = data + 8;
|
||||
brush->lightdata = data + 8;
|
||||
return;
|
||||
} else
|
||||
Sys_MaskPrintf (SYS_DEV,
|
||||
|
@ -179,10 +180,10 @@ gl_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
|
|||
dstring_delete (litfilename);
|
||||
return;
|
||||
}
|
||||
mod->lightdata = Hunk_AllocName (bsp->lightdatasize * mod_lightmap_bytes,
|
||||
litfilename->str);
|
||||
brush->lightdata = Hunk_AllocName (bsp->lightdatasize * mod_lightmap_bytes,
|
||||
litfilename->str);
|
||||
in = bsp->lightdata;
|
||||
out = mod->lightdata;
|
||||
out = brush->lightdata;
|
||||
|
||||
if (mod_lightmap_bytes > 1)
|
||||
for (i = 0; i < bsp->lightdatasize ; i++) {
|
||||
|
@ -308,18 +309,19 @@ gl_Mod_SubdivideSurface (model_t *mod, msurface_t *fa)
|
|||
float *vec;
|
||||
int lindex, numverts, i;
|
||||
vec3_t verts[64];
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
warpface = fa;
|
||||
|
||||
// convert edges back to a normal polygon
|
||||
numverts = 0;
|
||||
for (i = 0; i < fa->numedges; i++) {
|
||||
lindex = mod->surfedges[fa->firstedge + i];
|
||||
lindex = brush->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0)
|
||||
vec = mod->vertexes[mod->edges[lindex].v[0]].position;
|
||||
vec = brush->vertexes[brush->edges[lindex].v[0]].position;
|
||||
else
|
||||
vec = mod->vertexes[mod->edges[-lindex].v[1]].position;
|
||||
vec = brush->vertexes[brush->edges[-lindex].v[1]].position;
|
||||
VectorCopy (vec, verts[numverts]);
|
||||
numverts++;
|
||||
}
|
||||
|
|
|
@ -65,13 +65,14 @@ static void
|
|||
glsl_brush_clear (model_t *m, void *data)
|
||||
{
|
||||
int i;
|
||||
mod_brush_t *brush = &m->brush;
|
||||
|
||||
m->needload = true;
|
||||
for (i = 0; i < m->numtextures; i++) {
|
||||
for (i = 0; i < brush->numtextures; i++) {
|
||||
// NOTE: some maps (eg e1m2) have empty texture slots
|
||||
glsltex_t *tex = 0;
|
||||
if (m->textures[i]) {
|
||||
tex = m->textures[i]->render;
|
||||
if (brush->textures[i]) {
|
||||
tex = brush->textures[i]->render;
|
||||
}
|
||||
if (tex && tex->gl_texturenum) {
|
||||
GLSL_ReleaseTexture (tex->gl_texturenum);
|
||||
|
@ -80,10 +81,10 @@ glsl_brush_clear (model_t *m, void *data)
|
|||
tex->gl_texturenum = 0;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < m->numsurfaces; i++) {
|
||||
if (m->surfaces[i].polys) {
|
||||
free (m->surfaces[i].polys);
|
||||
m->surfaces[i].polys = 0;
|
||||
for (i = 0; i < brush->numsurfaces; i++) {
|
||||
if (brush->surfaces[i].polys) {
|
||||
free (brush->surfaces[i].polys);
|
||||
brush->surfaces[i].polys = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,9 +152,9 @@ glsl_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
|
|||
mod->clear = glsl_brush_clear;
|
||||
mod_lightmap_bytes = 1;
|
||||
if (!bsp->lightdatasize) {
|
||||
mod->lightdata = NULL;
|
||||
mod->brush.lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
mod->lightdata = Hunk_AllocName (bsp->lightdatasize, mod->name);
|
||||
memcpy (mod->lightdata, bsp->lightdata, bsp->lightdatasize);
|
||||
mod->brush.lightdata = Hunk_AllocName (bsp->lightdatasize, mod->name);
|
||||
memcpy (mod->brush.lightdata, bsp->lightdata, bsp->lightdatasize);
|
||||
}
|
||||
|
|
|
@ -67,10 +67,10 @@ Mod_PointInLeaf (const vec3_t p, model_t *model)
|
|||
mnode_t *node;
|
||||
plane_t *plane;
|
||||
|
||||
if (!model || !model->nodes)
|
||||
if (!model || !model->brush.nodes)
|
||||
Sys_Error ("Mod_PointInLeaf: bad model");
|
||||
|
||||
node = model->nodes;
|
||||
node = model->brush.nodes;
|
||||
while (1) {
|
||||
if (node->contents < 0)
|
||||
return (mleaf_t *) node;
|
||||
|
@ -86,13 +86,13 @@ Mod_PointInLeaf (const vec3_t p, model_t *model)
|
|||
}
|
||||
|
||||
static inline byte *
|
||||
Mod_DecompressVis (byte * in, model_t *model)
|
||||
Mod_DecompressVis (byte * in, mod_brush_t *brush)
|
||||
{
|
||||
static byte decompressed[MAX_MAP_LEAFS / 8];
|
||||
byte *out;
|
||||
int row, c;
|
||||
|
||||
row = (model->numleafs + 7) >> 3;
|
||||
row = (brush->numleafs + 7) >> 3;
|
||||
out = decompressed;
|
||||
|
||||
if (!in) { // no vis info, so make all visible
|
||||
|
@ -123,13 +123,13 @@ Mod_DecompressVis (byte * in, model_t *model)
|
|||
VISIBLE byte *
|
||||
Mod_LeafPVS (mleaf_t *leaf, model_t *model)
|
||||
{
|
||||
if (leaf == model->leafs) {
|
||||
if (leaf == model->brush.leafs) {
|
||||
if (!mod_novis[0]) {
|
||||
memset (mod_novis, 0xff, sizeof (mod_novis));
|
||||
}
|
||||
return mod_novis;
|
||||
}
|
||||
return Mod_DecompressVis (leaf->compressed_vis, model);
|
||||
return Mod_DecompressVis (leaf->compressed_vis, &model->brush);
|
||||
}
|
||||
|
||||
// BRUSHMODEL LOADING =========================================================
|
||||
|
@ -170,16 +170,17 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
|
|||
miptex_t *mt;
|
||||
texture_t *tx, *tx2;
|
||||
texture_t *anims[10], *altanims[10];
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
if (!bsp->texdatasize) {
|
||||
mod->textures = NULL;
|
||||
brush->textures = NULL;
|
||||
return;
|
||||
}
|
||||
m = (dmiptexlump_t *) bsp->texdata;
|
||||
|
||||
mod->numtextures = m->nummiptex;
|
||||
mod->textures = Hunk_AllocName (m->nummiptex * sizeof (*mod->textures),
|
||||
mod->name);
|
||||
brush->numtextures = m->nummiptex;
|
||||
brush->textures = Hunk_AllocName (m->nummiptex * sizeof (*brush->textures),
|
||||
mod->name);
|
||||
|
||||
for (i = 0; i < m->nummiptex; i++) {
|
||||
if (m->dataofs[i] == -1)
|
||||
|
@ -195,10 +196,10 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
|
|||
pixels = mt->width * mt->height / 64 * 85;
|
||||
tx = Hunk_AllocName (sizeof (texture_t) + pixels, mod->name);
|
||||
|
||||
mod->textures[i] = tx;
|
||||
brush->textures[i] = tx;
|
||||
|
||||
tx->name = strndup(mt->name, sizeof (mt->name));
|
||||
mod_unique_miptex_name (mod->textures, tx, i);
|
||||
mod_unique_miptex_name (brush->textures, tx, i);
|
||||
tx->width = mt->width;
|
||||
tx->height = mt->height;
|
||||
for (j = 0; j < MIPLEVELS; j++)
|
||||
|
@ -208,7 +209,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
|
|||
memcpy (tx + 1, mt + 1, pixels);
|
||||
|
||||
if (!strncmp (mt->name, "sky", 3))
|
||||
mod->skytexture = tx;
|
||||
brush->skytexture = tx;
|
||||
}
|
||||
if (mod_funcs && mod_funcs->Mod_ProcessTexture) {
|
||||
size_t render_size = mod_funcs->texture_render_size;
|
||||
|
@ -218,7 +219,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
|
|||
mod->name);
|
||||
}
|
||||
for (i = 0; i < m->nummiptex; i++) {
|
||||
tx = mod->textures[i];
|
||||
tx = brush->textures[i];
|
||||
tx->render = render_data;
|
||||
render_data += render_size;
|
||||
mod_funcs->Mod_ProcessTexture (mod, tx);
|
||||
|
@ -229,7 +230,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
|
|||
|
||||
// sequence the animations
|
||||
for (i = 0; i < m->nummiptex; i++) {
|
||||
tx = mod->textures[i];
|
||||
tx = brush->textures[i];
|
||||
if (!tx || tx->name[0] != '+')
|
||||
continue;
|
||||
if (tx->anim_next)
|
||||
|
@ -256,7 +257,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp)
|
|||
Sys_Error ("Bad animating texture %s", tx->name);
|
||||
|
||||
for (j = i + 1; j < m->nummiptex; j++) {
|
||||
tx2 = mod->textures[j];
|
||||
tx2 = brush->textures[j];
|
||||
if (!tx2 || tx2->name[0] != '+')
|
||||
continue;
|
||||
if (strcmp (tx2->name + 2, tx->name + 2))
|
||||
|
@ -310,22 +311,22 @@ static void
|
|||
Mod_LoadVisibility (model_t *mod, bsp_t *bsp)
|
||||
{
|
||||
if (!bsp->visdatasize) {
|
||||
mod->visdata = NULL;
|
||||
mod->brush.visdata = NULL;
|
||||
return;
|
||||
}
|
||||
mod->visdata = Hunk_AllocName (bsp->visdatasize, mod->name);
|
||||
memcpy (mod->visdata, bsp->visdata, bsp->visdatasize);
|
||||
mod->brush.visdata = Hunk_AllocName (bsp->visdatasize, mod->name);
|
||||
memcpy (mod->brush.visdata, bsp->visdata, bsp->visdatasize);
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_LoadEntities (model_t *mod, bsp_t *bsp)
|
||||
{
|
||||
if (!bsp->entdatasize) {
|
||||
mod->entities = NULL;
|
||||
mod->brush.entities = NULL;
|
||||
return;
|
||||
}
|
||||
mod->entities = Hunk_AllocName (bsp->entdatasize, mod->name);
|
||||
memcpy (mod->entities, bsp->entdata, bsp->entdatasize);
|
||||
mod->brush.entities = Hunk_AllocName (bsp->entdatasize, mod->name);
|
||||
memcpy (mod->brush.entities, bsp->entdata, bsp->entdatasize);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -339,8 +340,8 @@ Mod_LoadVertexes (model_t *mod, bsp_t *bsp)
|
|||
count = bsp->numvertexes;
|
||||
out = Hunk_AllocName (count * sizeof (*out), mod->name);
|
||||
|
||||
mod->vertexes = out;
|
||||
mod->numvertexes = count;
|
||||
mod->brush.vertexes = out;
|
||||
mod->brush.numvertexes = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++)
|
||||
VectorCopy (in->point, out->position);
|
||||
|
@ -351,13 +352,14 @@ Mod_LoadSubmodels (model_t *mod, bsp_t *bsp)
|
|||
{
|
||||
dmodel_t *in, *out;
|
||||
int count, i, j;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->models;
|
||||
count = bsp->nummodels;
|
||||
out = Hunk_AllocName (count * sizeof (*out), mod->name);
|
||||
|
||||
mod->submodels = out;
|
||||
mod->numsubmodels = count;
|
||||
brush->submodels = out;
|
||||
brush->numsubmodels = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++) {
|
||||
static vec3_t offset = {1, 1, 1};
|
||||
|
@ -372,7 +374,7 @@ Mod_LoadSubmodels (model_t *mod, bsp_t *bsp)
|
|||
out->numfaces = in->numfaces;
|
||||
}
|
||||
|
||||
out = mod->submodels;
|
||||
out = brush->submodels;
|
||||
|
||||
if (out->visleafs > MAX_MAP_LEAFS) {
|
||||
Sys_Error ("Mod_LoadSubmodels: too many visleafs (%d, max = %d) in %s",
|
||||
|
@ -396,8 +398,8 @@ Mod_LoadEdges (model_t *mod, bsp_t *bsp)
|
|||
count = bsp->numedges;
|
||||
out = Hunk_AllocName ((count + 1) * sizeof (*out), mod->name);
|
||||
|
||||
mod->edges = out;
|
||||
mod->numedges = count;
|
||||
mod->brush.edges = out;
|
||||
mod->brush.numedges = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++) {
|
||||
out->v[0] = in->v[0];
|
||||
|
@ -417,8 +419,8 @@ Mod_LoadTexinfo (model_t *mod, bsp_t *bsp)
|
|||
count = bsp->numtexinfo;
|
||||
out = Hunk_AllocName (count * sizeof (*out), mod->name);
|
||||
|
||||
mod->texinfo = out;
|
||||
mod->numtexinfo = count;
|
||||
mod->brush.texinfo = out;
|
||||
mod->brush.numtexinfo = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
|
@ -441,13 +443,13 @@ Mod_LoadTexinfo (model_t *mod, bsp_t *bsp)
|
|||
miptex = in->miptex;
|
||||
out->flags = in->flags;
|
||||
|
||||
if (!mod->textures) {
|
||||
if (!mod->brush.textures) {
|
||||
out->texture = r_notexture_mip; // checkerboard texture
|
||||
out->flags = 0;
|
||||
} else {
|
||||
if (miptex >= mod->numtextures)
|
||||
Sys_Error ("miptex >= mod->numtextures");
|
||||
out->texture = mod->textures[miptex];
|
||||
if (miptex >= mod->brush.numtextures)
|
||||
Sys_Error ("miptex >= mod->brush.numtextures");
|
||||
out->texture = mod->brush.textures[miptex];
|
||||
if (!out->texture) {
|
||||
out->texture = r_notexture_mip; // texture not found
|
||||
out->flags = 0;
|
||||
|
@ -469,6 +471,7 @@ CalcSurfaceExtents (model_t *mod, msurface_t *s)
|
|||
int bmins[2], bmaxs[2];
|
||||
mtexinfo_t *tex;
|
||||
mvertex_t *v;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
mins[0] = mins[1] = 999999;
|
||||
maxs[0] = maxs[1] = -99999;
|
||||
|
@ -476,11 +479,11 @@ CalcSurfaceExtents (model_t *mod, msurface_t *s)
|
|||
tex = s->texinfo;
|
||||
|
||||
for (i = 0; i < s->numedges; i++) {
|
||||
e = mod->surfedges[s->firstedge + i];
|
||||
e = brush->surfedges[s->firstedge + i];
|
||||
if (e >= 0)
|
||||
v = &mod->vertexes[mod->edges[e].v[0]];
|
||||
v = &brush->vertexes[brush->edges[e].v[0]];
|
||||
else
|
||||
v = &mod->vertexes[mod->edges[-e].v[1]];
|
||||
v = &brush->vertexes[brush->edges[-e].v[1]];
|
||||
|
||||
for (j = 0; j < 2; j++) {
|
||||
val = v->position[0] * tex->vecs[j][0] +
|
||||
|
@ -512,6 +515,7 @@ Mod_LoadFaces (model_t *mod, bsp_t *bsp)
|
|||
dface_t *in;
|
||||
int count, planenum, side, surfnum, i;
|
||||
msurface_t *out;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->faces;
|
||||
count = bsp->numfaces;
|
||||
|
@ -522,8 +526,8 @@ Mod_LoadFaces (model_t *mod, bsp_t *bsp)
|
|||
"%i faces exceeds standard limit of 32767.\n", count);
|
||||
}
|
||||
|
||||
mod->surfaces = out;
|
||||
mod->numsurfaces = count;
|
||||
brush->surfaces = out;
|
||||
brush->numsurfaces = count;
|
||||
|
||||
for (surfnum = 0; surfnum < count; surfnum++, in++, out++) {
|
||||
out->firstedge = in->firstedge;
|
||||
|
@ -535,9 +539,9 @@ Mod_LoadFaces (model_t *mod, bsp_t *bsp)
|
|||
if (side)
|
||||
out->flags |= SURF_PLANEBACK;
|
||||
|
||||
out->plane = mod->planes + planenum;
|
||||
out->plane = brush->planes + planenum;
|
||||
|
||||
out->texinfo = mod->texinfo + in->texinfo;
|
||||
out->texinfo = brush->texinfo + in->texinfo;
|
||||
|
||||
CalcSurfaceExtents (mod, out);
|
||||
|
||||
|
@ -549,7 +553,7 @@ Mod_LoadFaces (model_t *mod, bsp_t *bsp)
|
|||
if (i == -1)
|
||||
out->samples = NULL;
|
||||
else
|
||||
out->samples = mod->lightdata + (i * mod_lightmap_bytes);
|
||||
out->samples = brush->lightdata + (i * mod_lightmap_bytes);
|
||||
|
||||
// set the drawing flags flag
|
||||
if (!out->texinfo->texture || !out->texinfo->texture->name)
|
||||
|
@ -596,6 +600,7 @@ Mod_LoadNodes (model_t *mod, bsp_t *bsp)
|
|||
dnode_t *in;
|
||||
int count, i, j, p;
|
||||
mnode_t *out;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->nodes;
|
||||
count = bsp->numnodes;
|
||||
|
@ -606,8 +611,8 @@ Mod_LoadNodes (model_t *mod, bsp_t *bsp)
|
|||
"%i nodes exceeds standard limit of 32767.\n", count);
|
||||
}
|
||||
|
||||
mod->nodes = out;
|
||||
mod->numnodes = count;
|
||||
brush->nodes = out;
|
||||
brush->numnodes = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
|
@ -616,7 +621,7 @@ Mod_LoadNodes (model_t *mod, bsp_t *bsp)
|
|||
}
|
||||
|
||||
p = in->planenum;
|
||||
out->plane = mod->planes + p;
|
||||
out->plane = brush->planes + p;
|
||||
|
||||
out->firstsurface = in->firstface;
|
||||
out->numsurfaces = in->numfaces;
|
||||
|
@ -625,23 +630,23 @@ Mod_LoadNodes (model_t *mod, bsp_t *bsp)
|
|||
p = in->children[j];
|
||||
// this check is for extended bsp 29 files
|
||||
if (p >= 0) {
|
||||
out->children[j] = mod->nodes + p;
|
||||
out->children[j] = brush->nodes + p;
|
||||
} else {
|
||||
p = ~p;
|
||||
if (p < mod->numleafs) {
|
||||
out->children[j] = (mnode_t *) (mod->leafs + p);
|
||||
if (p < brush->numleafs) {
|
||||
out->children[j] = (mnode_t *) (brush->leafs + p);
|
||||
} else {
|
||||
Sys_Printf ("Mod_LoadNodes: invalid leaf index %i "
|
||||
"(file has only %i leafs)\n", p,
|
||||
mod->numleafs);
|
||||
brush->numleafs);
|
||||
//map it to the solid leaf
|
||||
out->children[j] = (mnode_t *)(mod->leafs);
|
||||
out->children[j] = (mnode_t *)(brush->leafs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mod_SetParent (mod->nodes, NULL); // sets nodes and leafs
|
||||
Mod_SetParent (brush->nodes, NULL); // sets nodes and leafs
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -651,13 +656,14 @@ Mod_LoadLeafs (model_t *mod, bsp_t *bsp)
|
|||
int count, i, j, p;
|
||||
mleaf_t *out;
|
||||
qboolean isnotmap = true;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->leafs;
|
||||
count = bsp->numleafs;
|
||||
out = Hunk_AllocName (count * sizeof (*out), mod->name);
|
||||
|
||||
mod->leafs = out;
|
||||
mod->numleafs = count;
|
||||
brush->leafs = out;
|
||||
brush->numleafs = count;
|
||||
// snprintf(s, sizeof (s), "maps/%s.bsp",
|
||||
// Info_ValueForKey(cl.serverinfo,"map"));
|
||||
if (!strncmp ("maps/", mod->path, 5))
|
||||
|
@ -671,14 +677,14 @@ Mod_LoadLeafs (model_t *mod, bsp_t *bsp)
|
|||
p = in->contents;
|
||||
out->contents = p;
|
||||
|
||||
out->firstmarksurface = mod->marksurfaces + in->firstmarksurface;
|
||||
out->firstmarksurface = brush->marksurfaces + in->firstmarksurface;
|
||||
out->nummarksurfaces = in->nummarksurfaces;
|
||||
|
||||
p = in->visofs;
|
||||
if (p == -1)
|
||||
out->compressed_vis = NULL;
|
||||
else
|
||||
out->compressed_vis = mod->visdata + p;
|
||||
out->compressed_vis = brush->visdata + p;
|
||||
out->efrags = NULL;
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
|
@ -703,6 +709,7 @@ Mod_LoadClipnodes (model_t *mod, bsp_t *bsp)
|
|||
mclipnode_t *out;
|
||||
hull_t *hull;
|
||||
int count, i;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->clipnodes;
|
||||
count = bsp->numclipnodes;
|
||||
|
@ -714,15 +721,15 @@ Mod_LoadClipnodes (model_t *mod, bsp_t *bsp)
|
|||
count);
|
||||
}
|
||||
|
||||
mod->clipnodes = out;
|
||||
mod->numclipnodes = count;
|
||||
brush->clipnodes = out;
|
||||
brush->numclipnodes = count;
|
||||
|
||||
hull = &mod->hulls[1];
|
||||
mod->hull_list[1] = hull;
|
||||
hull = &brush->hulls[1];
|
||||
brush->hull_list[1] = hull;
|
||||
hull->clipnodes = out;
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = count - 1;
|
||||
hull->planes = mod->planes;
|
||||
hull->planes = brush->planes;
|
||||
hull->clip_mins[0] = -16;
|
||||
hull->clip_mins[1] = -16;
|
||||
hull->clip_mins[2] = -24;
|
||||
|
@ -730,12 +737,12 @@ Mod_LoadClipnodes (model_t *mod, bsp_t *bsp)
|
|||
hull->clip_maxs[1] = 16;
|
||||
hull->clip_maxs[2] = 32;
|
||||
|
||||
hull = &mod->hulls[2];
|
||||
mod->hull_list[2] = hull;
|
||||
hull = &brush->hulls[2];
|
||||
brush->hull_list[2] = hull;
|
||||
hull->clipnodes = out;
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = count - 1;
|
||||
hull->planes = mod->planes;
|
||||
hull->planes = brush->planes;
|
||||
hull->clip_mins[0] = -32;
|
||||
hull->clip_mins[1] = -32;
|
||||
hull->clip_mins[2] = -24;
|
||||
|
@ -745,7 +752,7 @@ Mod_LoadClipnodes (model_t *mod, bsp_t *bsp)
|
|||
|
||||
for (i = 0; i < count; i++, out++, in++) {
|
||||
out->planenum = in->planenum;
|
||||
if (out->planenum < 0 || out->planenum >= mod->numplanes)
|
||||
if (out->planenum < 0 || out->planenum >= brush->numplanes)
|
||||
Sys_Error ("Mod_LoadClipnodes: planenum out of bounds");
|
||||
out->children[0] = in->children[0];
|
||||
out->children[1] = in->children[1];
|
||||
|
@ -776,27 +783,28 @@ Mod_MakeHull0 (model_t *mod)
|
|||
hull_t *hull;
|
||||
int count, i, j;
|
||||
mnode_t *in, *child;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
hull = &mod->hulls[0];
|
||||
mod->hull_list[0] = hull;
|
||||
hull = &brush->hulls[0];
|
||||
brush->hull_list[0] = hull;
|
||||
|
||||
in = mod->nodes;
|
||||
count = mod->numnodes;
|
||||
in = brush->nodes;
|
||||
count = brush->numnodes;
|
||||
out = Hunk_AllocName (count * sizeof (*out), mod->name);
|
||||
|
||||
hull->clipnodes = out;
|
||||
hull->firstclipnode = 0;
|
||||
hull->lastclipnode = count - 1;
|
||||
hull->planes = mod->planes;
|
||||
hull->planes = brush->planes;
|
||||
|
||||
for (i = 0; i < count; i++, out++, in++) {
|
||||
out->planenum = in->plane - mod->planes;
|
||||
out->planenum = in->plane - brush->planes;
|
||||
for (j = 0; j < 2; j++) {
|
||||
child = in->children[j];
|
||||
if (child->contents < 0)
|
||||
out->children[j] = child->contents;
|
||||
else
|
||||
out->children[j] = child - mod->nodes;
|
||||
out->children[j] = child - brush->nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -807,6 +815,7 @@ Mod_LoadMarksurfaces (model_t *mod, bsp_t *bsp)
|
|||
int count, i, j;
|
||||
msurface_t **out;
|
||||
uint32_t *in;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->marksurfaces;
|
||||
count = bsp->nummarksurfaces;
|
||||
|
@ -818,14 +827,14 @@ Mod_LoadMarksurfaces (model_t *mod, bsp_t *bsp)
|
|||
count);
|
||||
}
|
||||
|
||||
mod->marksurfaces = out;
|
||||
mod->nummarksurfaces = count;
|
||||
brush->marksurfaces = out;
|
||||
brush->nummarksurfaces = count;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
j = in[i];
|
||||
if (j >= mod->numsurfaces)
|
||||
if (j >= brush->numsurfaces)
|
||||
Sys_Error ("Mod_ParseMarksurfaces: bad surface number");
|
||||
out[i] = mod->surfaces + j;
|
||||
out[i] = brush->surfaces + j;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -835,13 +844,14 @@ Mod_LoadSurfedges (model_t *mod, bsp_t *bsp)
|
|||
int count, i;
|
||||
int32_t *in;
|
||||
int *out;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->surfedges;
|
||||
count = bsp->numsurfedges;
|
||||
out = Hunk_AllocName (count * sizeof (*out), mod->name);
|
||||
|
||||
mod->surfedges = out;
|
||||
mod->numsurfedges = count;
|
||||
brush->surfedges = out;
|
||||
brush->numsurfedges = count;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
out[i] = in[i];
|
||||
|
@ -853,13 +863,14 @@ Mod_LoadPlanes (model_t *mod, bsp_t *bsp)
|
|||
dplane_t *in;
|
||||
int bits, count, i, j;
|
||||
plane_t *out;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
in = bsp->planes;
|
||||
count = bsp->numplanes;
|
||||
out = Hunk_AllocName (count * 2 * sizeof (*out), mod->name);
|
||||
|
||||
mod->planes = out;
|
||||
mod->numplanes = count;
|
||||
brush->planes = out;
|
||||
brush->numplanes = count;
|
||||
|
||||
for (i = 0; i < count; i++, in++, out++) {
|
||||
bits = 0;
|
||||
|
@ -881,12 +892,13 @@ do_checksums (const bsp_t *bsp, void *_mod)
|
|||
int i;
|
||||
model_t *mod = (model_t *) _mod;
|
||||
byte *base;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
base = (byte *) bsp->header;
|
||||
|
||||
// checksum all of the map, except for entities
|
||||
mod->checksum = 0;
|
||||
mod->checksum2 = 0;
|
||||
brush->checksum = 0;
|
||||
brush->checksum2 = 0;
|
||||
for (i = 0; i < HEADER_LUMPS; i++) {
|
||||
lump_t *lump = bsp->header->lumps + i;
|
||||
int csum;
|
||||
|
@ -894,30 +906,30 @@ do_checksums (const bsp_t *bsp, void *_mod)
|
|||
if (i == LUMP_ENTITIES)
|
||||
continue;
|
||||
csum = Com_BlockChecksum (base + lump->fileofs, lump->filelen);
|
||||
mod->checksum ^= csum;
|
||||
brush->checksum ^= csum;
|
||||
|
||||
if (i != LUMP_VISIBILITY && i != LUMP_LEAFS && i != LUMP_NODES)
|
||||
mod->checksum2 ^= csum;
|
||||
brush->checksum2 ^= csum;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
recurse_draw_tree (model_t *mod, mnode_t *node, int depth)
|
||||
recurse_draw_tree (mod_brush_t *brush, mnode_t *node, int depth)
|
||||
{
|
||||
if (!node || node->contents < 0) {
|
||||
if (depth > mod->depth)
|
||||
mod->depth = depth;
|
||||
if (depth > brush->depth)
|
||||
brush->depth = depth;
|
||||
return;
|
||||
}
|
||||
recurse_draw_tree (mod, node->children[0], depth + 1);
|
||||
recurse_draw_tree (mod, node->children[1], depth + 1);
|
||||
recurse_draw_tree (brush, node->children[0], depth + 1);
|
||||
recurse_draw_tree (brush, node->children[1], depth + 1);
|
||||
}
|
||||
|
||||
static void
|
||||
Mod_FindDrawDepth (model_t *mod)
|
||||
Mod_FindDrawDepth (mod_brush_t *brush)
|
||||
{
|
||||
mod->depth = 0;
|
||||
recurse_draw_tree (mod, mod->nodes, 1);
|
||||
brush->depth = 0;
|
||||
recurse_draw_tree (brush, brush->nodes, 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -954,35 +966,35 @@ Mod_LoadBrushModel (model_t *mod, void *buffer)
|
|||
|
||||
Mod_MakeHull0 (mod);
|
||||
|
||||
Mod_FindDrawDepth (mod);
|
||||
Mod_FindDrawDepth (&mod->brush);
|
||||
for (i = 0; i < MAX_MAP_HULLS; i++)
|
||||
Mod_FindClipDepth (&mod->hulls[i]);
|
||||
Mod_FindClipDepth (&mod->brush.hulls[i]);
|
||||
|
||||
mod->numframes = 2; // regular and alternate animation
|
||||
|
||||
// set up the submodels (FIXME: this is confusing)
|
||||
for (i = 0; i < mod->numsubmodels; i++) {
|
||||
bm = &mod->submodels[i];
|
||||
for (i = 0; i < mod->brush.numsubmodels; i++) {
|
||||
bm = &mod->brush.submodels[i];
|
||||
|
||||
mod->hulls[0].firstclipnode = bm->headnode[0];
|
||||
mod->hull_list[0] = &mod->hulls[0];
|
||||
mod->brush.hulls[0].firstclipnode = bm->headnode[0];
|
||||
mod->brush.hull_list[0] = &mod->brush.hulls[0];
|
||||
for (j = 1; j < MAX_MAP_HULLS; j++) {
|
||||
mod->hulls[j].firstclipnode = bm->headnode[j];
|
||||
mod->hulls[j].lastclipnode = mod->numclipnodes - 1;
|
||||
mod->hull_list[j] = &mod->hulls[j];
|
||||
mod->brush.hulls[j].firstclipnode = bm->headnode[j];
|
||||
mod->brush.hulls[j].lastclipnode = mod->brush.numclipnodes - 1;
|
||||
mod->brush.hull_list[j] = &mod->brush.hulls[j];
|
||||
}
|
||||
|
||||
mod->firstmodelsurface = bm->firstface;
|
||||
mod->nummodelsurfaces = bm->numfaces;
|
||||
mod->brush.firstmodelsurface = bm->firstface;
|
||||
mod->brush.nummodelsurfaces = bm->numfaces;
|
||||
|
||||
VectorCopy (bm->maxs, mod->maxs);
|
||||
VectorCopy (bm->mins, mod->mins);
|
||||
|
||||
mod->radius = RadiusFromBounds (mod->mins, mod->maxs);
|
||||
|
||||
mod->numleafs = bm->visleafs;
|
||||
mod->brush.numleafs = bm->visleafs;
|
||||
|
||||
if (i < mod->numsubmodels - 1) {
|
||||
if (i < mod->brush.numsubmodels - 1) {
|
||||
// duplicate the basic information
|
||||
char name[12];
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ sw_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
|
|||
{
|
||||
mod_lightmap_bytes = 1;
|
||||
if (!bsp->lightdatasize) {
|
||||
mod->lightdata = NULL;
|
||||
mod->brush.lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
mod->lightdata = Hunk_AllocName (bsp->lightdatasize, mod->name);
|
||||
memcpy (mod->lightdata, bsp->lightdata, bsp->lightdatasize);
|
||||
mod->brush.lightdata = Hunk_AllocName (bsp->lightdatasize, mod->name);
|
||||
memcpy (mod->brush.lightdata, bsp->lightdata, bsp->lightdatasize);
|
||||
}
|
||||
|
|
|
@ -69,9 +69,10 @@ static void vulkan_brush_clear (model_t *mod, void *data)
|
|||
vulkan_ctx_t *ctx = mctx->ctx;
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
for (int i = 0; i < mod->numtextures; i++) {
|
||||
texture_t *tx = mod->textures[i];
|
||||
for (int i = 0; i < brush->numtextures; i++) {
|
||||
texture_t *tx = brush->textures[i];
|
||||
if (!tx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -180,12 +181,13 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
|
|||
modelctx_t *mctx = mod->data;
|
||||
VkImage image = 0;
|
||||
byte *buffer;
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
size_t image_count = 0;
|
||||
size_t copy_count = 0;
|
||||
size_t memsize = 0;
|
||||
for (int i = 0; i < mod->numtextures; i++) {
|
||||
texture_t *tx = mod->textures[i];
|
||||
for (int i = 0; i < brush->numtextures; i++) {
|
||||
texture_t *tx = brush->textures[i];
|
||||
if (!tx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -221,8 +223,8 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
|
|||
qfv_packet_t *packet = QFV_PacketAcquire (stage);
|
||||
buffer = QFV_PacketExtend (packet, memsize);
|
||||
|
||||
for (int i = 0; i < mod->numtextures; i++) {
|
||||
texture_t *tx = mod->textures[i];
|
||||
for (int i = 0; i < brush->numtextures; i++) {
|
||||
texture_t *tx = brush->textures[i];
|
||||
byte *palette = vid.palette32;
|
||||
if (!tx) {
|
||||
continue;
|
||||
|
@ -275,8 +277,8 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
|
|||
|
||||
__auto_type barriers = QFV_AllocImageBarrierSet (image_count, malloc);
|
||||
barriers->size = 0;
|
||||
for (int i = 0; i < mod->numtextures; i++) {
|
||||
texture_t *tx = mod->textures[i];
|
||||
for (int i = 0; i < brush->numtextures; i++) {
|
||||
texture_t *tx = brush->textures[i];
|
||||
if (!tx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -296,8 +298,8 @@ load_textures (model_t *mod, vulkan_ctx_t *ctx)
|
|||
dfunc->vkCmdPipelineBarrier (packet->cmd, stages.src, stages.dst,
|
||||
0, 0, 0, 0, 0,
|
||||
barriers->size, barriers->a);
|
||||
for (int i = 0, j = 0; i < mod->numtextures; i++) {
|
||||
texture_t *tx = mod->textures[i];
|
||||
for (int i = 0, j = 0; i < brush->numtextures; i++) {
|
||||
texture_t *tx = brush->textures[i];
|
||||
if (!tx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -401,9 +403,11 @@ Vulkan_Mod_ProcessTexture (model_t *mod, texture_t *tx, vulkan_ctx_t *ctx)
|
|||
void
|
||||
Vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp, vulkan_ctx_t *ctx)
|
||||
{
|
||||
mod_brush_t *brush = &mod->brush;
|
||||
|
||||
mod_lightmap_bytes = 3;
|
||||
if (!bsp->lightdatasize) {
|
||||
mod->lightdata = NULL;
|
||||
brush->lightdata = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -413,7 +417,7 @@ Vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp, vulkan_ctx_t *ctx)
|
|||
int ver;
|
||||
QFile *lit_file;
|
||||
|
||||
mod->lightdata = 0;
|
||||
brush->lightdata = 0;
|
||||
if (mod_lightmap_bytes > 1) {
|
||||
// LordHavoc: check for a .lit file to load
|
||||
dstring_t *litfilename = dstring_new ();
|
||||
|
@ -428,7 +432,7 @@ Vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp, vulkan_ctx_t *ctx)
|
|||
ver = LittleLong (((int32_t *) data)[1]);
|
||||
if (ver == 1) {
|
||||
Sys_MaskPrintf (SYS_DEV, "%s loaded", litfilename->str);
|
||||
mod->lightdata = data + 8;
|
||||
brush->lightdata = data + 8;
|
||||
} else {
|
||||
Sys_MaskPrintf (SYS_DEV,
|
||||
"Unknown .lit file version (%d)\n", ver);
|
||||
|
@ -439,13 +443,13 @@ Vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp, vulkan_ctx_t *ctx)
|
|||
}
|
||||
dstring_delete (litfilename);
|
||||
}
|
||||
if (mod->lightdata || !bsp->lightdatasize) {
|
||||
if (brush->lightdata || !bsp->lightdatasize) {
|
||||
return;
|
||||
}
|
||||
// LordHavoc: oh well, expand the white lighting data
|
||||
mod->lightdata = Hunk_AllocName (bsp->lightdatasize * 3, mod->name);
|
||||
brush->lightdata = Hunk_AllocName (bsp->lightdatasize * 3, mod->name);
|
||||
in = bsp->lightdata;
|
||||
out = mod->lightdata;
|
||||
out = brush->lightdata;
|
||||
|
||||
for (i = 0; i < bsp->lightdatasize ; i++) {
|
||||
d = *in++;
|
||||
|
|
|
@ -74,7 +74,7 @@ glRect_t gl_lightmap_rectchange[MAX_LIGHTMAPS];
|
|||
|
||||
static int lmshift = 7;
|
||||
|
||||
void (*gl_R_BuildLightMap) (msurface_t *surf);
|
||||
void (*gl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
||||
|
||||
extern void gl_multitexture_f (cvar_t *var);
|
||||
|
||||
|
@ -240,7 +240,7 @@ R_AddDynamicLights_3 (msurface_t *surf)
|
|||
}
|
||||
|
||||
static void
|
||||
R_BuildLightMap_1 (msurface_t *surf)
|
||||
R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
||||
{
|
||||
byte *dest;
|
||||
int maps, size, stride, smax, tmax, i, j;
|
||||
|
@ -254,7 +254,7 @@ R_BuildLightMap_1 (msurface_t *surf)
|
|||
size = smax * tmax * gl_internalformat;
|
||||
|
||||
// set to full bright if no light data
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!brush->lightdata) {
|
||||
memset (&blocklights[0], 0xff, size * sizeof(int));
|
||||
goto store;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ R_BuildLightMap_1 (msurface_t *surf)
|
|||
}
|
||||
|
||||
static void
|
||||
R_BuildLightMap_3 (msurface_t *surf)
|
||||
R_BuildLightMap_3 (mod_brush_t *brush, msurface_t *surf)
|
||||
{
|
||||
byte *dest;
|
||||
int maps, size, stride, smax, tmax, i, j;
|
||||
|
@ -314,7 +314,7 @@ R_BuildLightMap_3 (msurface_t *surf)
|
|||
size = smax * tmax * gl_internalformat;
|
||||
|
||||
// set to full bright if no light data
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!brush->lightdata) {
|
||||
memset (&blocklights[0], 0xff, size * sizeof(int));
|
||||
goto store;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ R_BuildLightMap_3 (msurface_t *surf)
|
|||
}
|
||||
|
||||
static void
|
||||
R_BuildLightMap_4 (msurface_t *surf)
|
||||
R_BuildLightMap_4 (mod_brush_t *brush, msurface_t *surf)
|
||||
{
|
||||
byte *dest;
|
||||
int maps, size, smax, tmax, i, j, stride;
|
||||
|
@ -379,7 +379,7 @@ R_BuildLightMap_4 (msurface_t *surf)
|
|||
size = smax * tmax * gl_internalformat;
|
||||
|
||||
// set to full bright if no light data
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!brush->lightdata) {
|
||||
memset (&blocklights[0], 0xff, size * sizeof(int));
|
||||
goto store;
|
||||
}
|
||||
|
@ -535,6 +535,7 @@ gl_overbright_f (cvar_t *var)
|
|||
model_t *m;
|
||||
msurface_t *fa;
|
||||
entity_t *ent;
|
||||
mod_brush_t *brush;
|
||||
|
||||
if (!var)
|
||||
return;
|
||||
|
@ -588,7 +589,8 @@ gl_overbright_f (cvar_t *var)
|
|||
if (m->path[0] == '*')
|
||||
continue;
|
||||
|
||||
for (j = 0, fa = m->surfaces; j < m->numsurfaces; j++, fa++) {
|
||||
brush = &m->brush;
|
||||
for (j = 0, fa = brush->surfaces; j < brush->numsurfaces; j++, fa++) {
|
||||
if (fa->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
|
||||
continue;
|
||||
|
||||
|
@ -599,13 +601,13 @@ gl_overbright_f (cvar_t *var)
|
|||
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
||||
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
||||
|
||||
gl_R_BuildLightMap (fa);
|
||||
gl_R_BuildLightMap (brush, fa);
|
||||
}
|
||||
}
|
||||
|
||||
m = r_worldentity.model;
|
||||
brush = &r_worldentity.model->brush;
|
||||
|
||||
for (i = 0, fa = m->surfaces; i < m->numsurfaces; i++, fa++) {
|
||||
for (i = 0, fa = brush->surfaces; i < brush->numsurfaces; i++, fa++) {
|
||||
if (fa->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
|
||||
continue;
|
||||
|
||||
|
@ -616,7 +618,7 @@ gl_overbright_f (cvar_t *var)
|
|||
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
||||
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
||||
|
||||
gl_R_BuildLightMap (fa);
|
||||
gl_R_BuildLightMap (brush, fa);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,7 +667,7 @@ AllocBlock (int w, int h, int *x, int *y)
|
|||
}
|
||||
|
||||
static void
|
||||
GL_CreateSurfaceLightmap (msurface_t *surf)
|
||||
GL_CreateSurfaceLightmap (mod_brush_t *brush, msurface_t *surf)
|
||||
{
|
||||
int smax, tmax;
|
||||
|
||||
|
@ -677,7 +679,7 @@ GL_CreateSurfaceLightmap (msurface_t *surf)
|
|||
|
||||
surf->lightmaptexturenum =
|
||||
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
||||
gl_R_BuildLightMap (surf);
|
||||
gl_R_BuildLightMap (brush, surf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -690,6 +692,7 @@ GL_BuildLightmaps (model_t **models, int num_models)
|
|||
{
|
||||
int i, j;
|
||||
model_t *m;
|
||||
mod_brush_t *brush;
|
||||
|
||||
memset (allocated, 0, sizeof (allocated));
|
||||
|
||||
|
@ -732,21 +735,22 @@ GL_BuildLightmaps (model_t **models, int num_models)
|
|||
m = models[j];
|
||||
if (!m)
|
||||
break;
|
||||
if (m->path[0] == '*') {
|
||||
if (m->path[0] == '*' || m->type != mod_brush) {
|
||||
// sub model surfaces are processed as part of the main model
|
||||
continue;
|
||||
}
|
||||
r_pcurrentvertbase = m->vertexes;
|
||||
brush = &m->brush;
|
||||
r_pcurrentvertbase = brush->vertexes;
|
||||
gl_currentmodel = m;
|
||||
// non-bsp models don't have surfaces.
|
||||
for (i = 0; i < m->numsurfaces; i++) {
|
||||
if (m->surfaces[i].flags & SURF_DRAWTURB)
|
||||
for (i = 0; i < brush->numsurfaces; i++) {
|
||||
if (brush->surfaces[i].flags & SURF_DRAWTURB)
|
||||
continue;
|
||||
if (gl_sky_divide->int_val && (m->surfaces[i].flags &
|
||||
if (gl_sky_divide->int_val && (brush->surfaces[i].flags &
|
||||
SURF_DRAWSKY))
|
||||
continue;
|
||||
GL_CreateSurfaceLightmap (m->surfaces + i);
|
||||
GL_BuildSurfaceDisplayList (m->surfaces + i);
|
||||
GL_CreateSurfaceLightmap (brush, brush->surfaces + i);
|
||||
GL_BuildSurfaceDisplayList (brush->surfaces + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ gl_R_DrawAliasModel (entity_t *e)
|
|||
float lightadj;
|
||||
|
||||
// get lighting information
|
||||
R_LightPoint (e->origin);
|
||||
R_LightPoint (&r_worldentity.model->brush, e->origin);
|
||||
|
||||
lightadj = (ambientcolor[0] + ambientcolor[1] + ambientcolor[2]) / 765.0;
|
||||
|
||||
|
|
|
@ -167,13 +167,13 @@ gl_R_Init (void)
|
|||
}
|
||||
|
||||
static void
|
||||
register_textures (model_t *model)
|
||||
register_textures (mod_brush_t *brush)
|
||||
{
|
||||
int i;
|
||||
texture_t *tex;
|
||||
|
||||
for (i = 0; i < model->numtextures; i++) {
|
||||
tex = model->textures[i];
|
||||
for (i = 0; i < brush->numtextures; i++) {
|
||||
tex = brush->textures[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
gl_R_AddTexture (tex);
|
||||
|
@ -185,18 +185,20 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
{
|
||||
int i;
|
||||
texture_t *tex;
|
||||
mod_brush_t *brush;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
|
||||
memset (&r_worldentity, 0, sizeof (r_worldentity));
|
||||
r_worldentity.model = worldmodel;
|
||||
brush = &worldmodel->brush;
|
||||
|
||||
R_FreeAllEntities ();
|
||||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
for (i = 0; i < r_worldentity.model->numleafs; i++)
|
||||
r_worldentity.model->leafs[i].efrags = NULL;
|
||||
for (i = 0; i < brush->numleafs; i++)
|
||||
brush->leafs[i].efrags = NULL;
|
||||
|
||||
// Force a vis update
|
||||
r_viewleaf = NULL;
|
||||
|
@ -209,8 +211,8 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
// identify sky texture
|
||||
gl_mirrortexturenum = -1;
|
||||
gl_R_ClearTextures ();
|
||||
for (i = 0; i < r_worldentity.model->numtextures; i++) {
|
||||
tex = r_worldentity.model->textures[i];
|
||||
for (i = 0; i < brush->numtextures; i++) {
|
||||
tex = brush->textures[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
if (!strncmp (tex->name, "sky", 3)) {
|
||||
|
@ -220,16 +222,16 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
gl_mirrortexturenum = i;
|
||||
}
|
||||
|
||||
gl_R_InitSurfaceChains (r_worldentity.model);
|
||||
gl_R_InitSurfaceChains (brush);
|
||||
gl_R_AddTexture (r_notexture_mip);
|
||||
register_textures (r_worldentity.model);
|
||||
register_textures (brush);
|
||||
for (i = 0; i < num_models; i++) {
|
||||
if (!models[i])
|
||||
continue;
|
||||
if (*models[i]->path == '*')
|
||||
continue;
|
||||
if (models[i] != r_worldentity.model && models[i]->type == mod_brush)
|
||||
register_textures (models[i]);
|
||||
register_textures (&models[i]->brush);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,15 +146,15 @@ gl_R_AddTexture (texture_t *tx)
|
|||
}
|
||||
|
||||
void
|
||||
gl_R_InitSurfaceChains (model_t *model)
|
||||
gl_R_InitSurfaceChains (mod_brush_t *brush)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (static_chains)
|
||||
free (static_chains);
|
||||
static_chains = calloc (model->nummodelsurfaces, sizeof (instsurf_t));
|
||||
for (i = 0; i < model->nummodelsurfaces; i++)
|
||||
model->surfaces[i].instsurf = static_chains + i;
|
||||
static_chains = calloc (brush->nummodelsurfaces, sizeof (instsurf_t));
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++)
|
||||
brush->surfaces[i].instsurf = static_chains + i;
|
||||
|
||||
release_instsurfs ();
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ R_RenderBrushPoly_1 (msurface_t *fa)
|
|||
}
|
||||
|
||||
static inline void
|
||||
R_AddToLightmapChain (msurface_t *fa)
|
||||
R_AddToLightmapChain (mod_brush_t *brush, msurface_t *fa)
|
||||
{
|
||||
int maps, smax, tmax;
|
||||
glRect_t *theRect;
|
||||
|
@ -306,7 +306,7 @@ R_AddToLightmapChain (msurface_t *fa)
|
|||
theRect->w = (fa->light_s - theRect->l) + smax;
|
||||
if ((theRect->h + theRect->t) < (fa->light_t + tmax))
|
||||
theRect->h = (fa->light_t - theRect->t) + tmax;
|
||||
gl_R_BuildLightMap (fa);
|
||||
gl_R_BuildLightMap (brush, fa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +490,8 @@ clear_texture_chains (void)
|
|||
}
|
||||
|
||||
static inline void
|
||||
chain_surface (msurface_t *surf, vec_t *transform, float *color)
|
||||
chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
||||
float *color)
|
||||
{
|
||||
instsurf_t *sc;
|
||||
|
||||
|
@ -509,7 +510,7 @@ chain_surface (msurface_t *surf, vec_t *transform, float *color)
|
|||
tex = tx->render;
|
||||
CHAIN_SURF_F2B (surf, tex->tex_chain);
|
||||
|
||||
R_AddToLightmapChain (surf);
|
||||
R_AddToLightmapChain (brush, surf);
|
||||
}
|
||||
if (!(sc = surf->instsurf))
|
||||
sc = surf->tinst;
|
||||
|
@ -528,8 +529,10 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
msurface_t *psurf;
|
||||
qboolean rotated;
|
||||
vec3_t mins, maxs;
|
||||
mod_brush_t *brush;
|
||||
|
||||
model = e->model;
|
||||
brush = &model->brush;
|
||||
|
||||
if (e->transform[0] != 1 || e->transform[5] != 1 || e->transform[10] != 1) {
|
||||
rotated = true;
|
||||
|
@ -565,7 +568,7 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
}
|
||||
|
||||
// calculate dynamic lighting for bmodel if it's not an instanced model
|
||||
if (model->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
if (brush->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
|
@ -574,8 +577,8 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
continue;
|
||||
|
||||
VectorSubtract (r_dlights[k].origin, e->origin, lightorigin);
|
||||
R_RecursiveMarkLights (lightorigin, &r_dlights[k], k,
|
||||
model->nodes + model->hulls[0].firstclipnode);
|
||||
R_RecursiveMarkLights (brush, lightorigin, &r_dlights[k], k,
|
||||
brush->nodes + brush->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,10 +587,10 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
qfglGetFloatv (GL_MODELVIEW_MATRIX, e->full_transform);
|
||||
qfglPopMatrix ();
|
||||
|
||||
psurf = &model->surfaces[model->firstmodelsurface];
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
|
||||
// draw texture
|
||||
for (i = 0; i < model->nummodelsurfaces; i++, psurf++) {
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
pplane = psurf->plane;
|
||||
|
||||
|
@ -596,7 +599,7 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
// draw the polygon
|
||||
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||
chain_surface (psurf, e->full_transform, e->colormod);
|
||||
chain_surface (brush, psurf, e->full_transform, e->colormod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -623,7 +626,7 @@ get_side (mnode_t *node)
|
|||
}
|
||||
|
||||
static inline void
|
||||
visit_node (mnode_t *node, int side)
|
||||
visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
||||
{
|
||||
int c;
|
||||
msurface_t *surf;
|
||||
|
@ -632,7 +635,7 @@ visit_node (mnode_t *node, int side)
|
|||
side = (~side + 1) & SURF_PLANEBACK;
|
||||
// draw stuff
|
||||
if ((c = node->numsurfaces)) {
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (; c; c--, surf++) {
|
||||
if (surf->visframe != r_visframecount)
|
||||
continue;
|
||||
|
@ -641,7 +644,7 @@ visit_node (mnode_t *node, int side)
|
|||
if (side ^ (surf->flags & SURF_PLANEBACK))
|
||||
continue; // wrong side
|
||||
|
||||
chain_surface (surf, 0, 0);
|
||||
chain_surface (brush, surf, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -659,7 +662,7 @@ test_node (mnode_t *node)
|
|||
}
|
||||
|
||||
static void
|
||||
R_VisitWorldNodes (model_t *model)
|
||||
R_VisitWorldNodes (mod_brush_t *brush)
|
||||
{
|
||||
typedef struct {
|
||||
mnode_t *node;
|
||||
|
@ -671,9 +674,9 @@ R_VisitWorldNodes (model_t *model)
|
|||
mnode_t *front;
|
||||
int side;
|
||||
|
||||
node = model->nodes;
|
||||
node = brush->nodes;
|
||||
// +2 for paranoia
|
||||
node_stack = alloca ((model->depth + 2) * sizeof (rstack_t));
|
||||
node_stack = alloca ((brush->depth + 2) * sizeof (rstack_t));
|
||||
node_ptr = node_stack;
|
||||
|
||||
while (1) {
|
||||
|
@ -689,7 +692,7 @@ R_VisitWorldNodes (model_t *model)
|
|||
}
|
||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||
visit_leaf ((mleaf_t *) front);
|
||||
visit_node (node, side);
|
||||
visit_node (brush, node, side);
|
||||
node = node->children[!side];
|
||||
}
|
||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||
|
@ -698,7 +701,7 @@ R_VisitWorldNodes (model_t *model)
|
|||
node_ptr--;
|
||||
node = node_ptr->node;
|
||||
side = node_ptr->side;
|
||||
visit_node (node, side);
|
||||
visit_node (brush, node, side);
|
||||
node = node->children[!side];
|
||||
continue;
|
||||
}
|
||||
|
@ -726,7 +729,7 @@ gl_R_DrawWorld (void)
|
|||
gl_R_DrawSky ();
|
||||
}
|
||||
|
||||
R_VisitWorldNodes (r_worldentity.model);
|
||||
R_VisitWorldNodes (&r_worldentity.model->brush);
|
||||
if (r_drawentities->int_val) {
|
||||
entity_t *ent;
|
||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||
|
@ -821,7 +824,7 @@ GL_BuildSurfaceDisplayList (msurface_t *fa)
|
|||
medge_t *pedges, *r_pedge;
|
||||
|
||||
// reconstruct the polygon
|
||||
pedges = gl_currentmodel->edges;
|
||||
pedges = gl_currentmodel->brush.edges;
|
||||
lnumverts = fa->numedges;
|
||||
|
||||
// draw texture
|
||||
|
@ -833,7 +836,7 @@ GL_BuildSurfaceDisplayList (msurface_t *fa)
|
|||
poly->numverts = lnumverts;
|
||||
|
||||
for (i = 0; i < lnumverts; i++) {
|
||||
lindex = gl_currentmodel->surfedges[fa->firstedge + i];
|
||||
lindex = gl_currentmodel->brush.surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0) {
|
||||
r_pedge = &pedges[lindex];
|
||||
|
|
|
@ -159,7 +159,7 @@ calc_lighting (entity_t *ent, float *ambient, float *shadelight,
|
|||
int light;
|
||||
|
||||
VectorSet ( -1, 0, 0, lightvec); //FIXME
|
||||
light = R_LightPoint (ent->origin);
|
||||
light = R_LightPoint (&r_worldentity.model->brush, ent->origin);
|
||||
*ambient = max (light, max (ent->model->min_light, ent->min_light) * 128);
|
||||
*shadelight = *ambient;
|
||||
|
||||
|
|
|
@ -311,17 +311,17 @@ glsl_R_AddTexture (texture_t *tx)
|
|||
tex->elechain_tail = &tex->elechain;
|
||||
}
|
||||
|
||||
void
|
||||
glsl_R_InitSurfaceChains (model_t *model)
|
||||
static void
|
||||
glsl_R_InitSurfaceChains (mod_brush_t *brush)
|
||||
{
|
||||
int i;
|
||||
|
||||
release_static_instsurfs ();
|
||||
release_instsurfs ();
|
||||
|
||||
for (i = 0; i < model->nummodelsurfaces; i++) {
|
||||
model->surfaces[i].instsurf = get_static_instsurf ();
|
||||
model->surfaces[i].instsurf->surface = &model->surfaces[i];
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++) {
|
||||
brush->surfaces[i].instsurf = get_static_instsurf ();
|
||||
brush->surfaces[i].instsurf->surface = &brush->surfaces[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ glsl_R_ClearElements (void)
|
|||
}
|
||||
|
||||
static void
|
||||
update_lightmap (msurface_t *surf)
|
||||
update_lightmap (mod_brush_t *brush, msurface_t *surf)
|
||||
{
|
||||
int maps;
|
||||
|
||||
|
@ -369,12 +369,13 @@ update_lightmap (msurface_t *surf)
|
|||
if ((surf->dlightframe == r_framecount) || surf->cached_dlight) {
|
||||
dynamic:
|
||||
if (r_dynamic->int_val)
|
||||
glsl_R_BuildLightMap (surf);
|
||||
glsl_R_BuildLightMap (brush, surf);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
chain_surface (msurface_t *surf, vec_t *transform, float *color)
|
||||
chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
||||
float *color)
|
||||
{
|
||||
instsurf_t *is;
|
||||
|
||||
|
@ -393,7 +394,7 @@ chain_surface (msurface_t *surf, vec_t *transform, float *color)
|
|||
tex = tx->render;
|
||||
CHAIN_SURF_F2B (surf, tex->tex_chain);
|
||||
|
||||
update_lightmap (surf);
|
||||
update_lightmap (brush, surf);
|
||||
}
|
||||
if (!(is = surf->instsurf))
|
||||
is = surf->tinst;
|
||||
|
@ -402,13 +403,13 @@ chain_surface (msurface_t *surf, vec_t *transform, float *color)
|
|||
}
|
||||
|
||||
static void
|
||||
register_textures (model_t *model)
|
||||
register_textures (mod_brush_t *brush)
|
||||
{
|
||||
int i;
|
||||
texture_t *tex;
|
||||
|
||||
for (i = 0; i < model->numtextures; i++) {
|
||||
tex = model->textures[i];
|
||||
for (i = 0; i < brush->numtextures; i++) {
|
||||
tex = brush->textures[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
glsl_R_AddTexture (tex);
|
||||
|
@ -426,11 +427,12 @@ glsl_R_RegisterTextures (model_t **models, int num_models)
|
|||
{
|
||||
int i;
|
||||
model_t *m;
|
||||
mod_brush_t *brush;
|
||||
|
||||
glsl_R_ClearTextures ();
|
||||
glsl_R_InitSurfaceChains (r_worldentity.model);
|
||||
glsl_R_InitSurfaceChains (&r_worldentity.model->brush);
|
||||
glsl_R_AddTexture (r_notexture_mip);
|
||||
register_textures (r_worldentity.model);
|
||||
register_textures (&r_worldentity.model->brush);
|
||||
for (i = 0; i < num_models; i++) {
|
||||
m = models[i];
|
||||
if (!m)
|
||||
|
@ -441,8 +443,9 @@ glsl_R_RegisterTextures (model_t **models, int num_models)
|
|||
// world has already been done, not interested in non-brush models
|
||||
if (m == r_worldentity.model || m->type != mod_brush)
|
||||
continue;
|
||||
m->numsubmodels = 1; // no support for submodels in non-world model
|
||||
register_textures (m);
|
||||
brush = &m->brush;
|
||||
brush->numsubmodels = 1; // no support for submodels in non-world model
|
||||
register_textures (brush);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,16 +481,17 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
glslpoly_t *poly;
|
||||
GLushort *ind;
|
||||
float s, t;
|
||||
mod_brush_t *brush;
|
||||
|
||||
if (fa->ec_index < 0) {
|
||||
vertices = models[-fa->ec_index - 1]->vertexes;
|
||||
edges = models[-fa->ec_index - 1]->edges;
|
||||
surfedges = models[-fa->ec_index - 1]->surfedges;
|
||||
brush = &models[-fa->ec_index - 1]->brush;
|
||||
} else {
|
||||
vertices = r_worldentity.model->vertexes;
|
||||
edges = r_worldentity.model->edges;
|
||||
surfedges = r_worldentity.model->surfedges;
|
||||
brush = &r_worldentity.model->brush;
|
||||
}
|
||||
vertices = brush->vertexes;
|
||||
edges = brush->edges;
|
||||
surfedges = brush->surfedges;
|
||||
|
||||
numverts = fa->numedges;
|
||||
numtris = numverts - 2;
|
||||
numindices = numtris * 3;
|
||||
|
@ -545,6 +549,7 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
|
|||
dmodel_t *dm;
|
||||
msurface_t *surf;
|
||||
dstring_t *vertices;
|
||||
mod_brush_t *brush;
|
||||
|
||||
QuatSet (0, 0, sqrt(0.5), sqrt(0.5), sky_fix); // proper skies
|
||||
QuatSet (0, 0, 0, 1, sky_rotation[0]);
|
||||
|
@ -561,24 +566,25 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
|
|||
if (!m)
|
||||
continue;
|
||||
// sub-models are done as part of the main model
|
||||
if (*m->path == '*')
|
||||
if (*m->path == '*' || m->type != mod_brush)
|
||||
continue;
|
||||
brush = &m->brush;
|
||||
// non-bsp models don't have surfaces.
|
||||
dm = m->submodels;
|
||||
for (j = 0; j < m->numsurfaces; j++) {
|
||||
dm = brush->submodels;
|
||||
for (j = 0; j < brush->numsurfaces; j++) {
|
||||
glsltex_t *tex;
|
||||
if (j == dm->firstface + dm->numfaces) {
|
||||
dm++;
|
||||
if (dm - m->submodels == m->numsubmodels) {
|
||||
if (dm - brush->submodels == brush->numsubmodels) {
|
||||
// limit the surfaces
|
||||
// probably never hit
|
||||
Sys_Printf ("R_BuildDisplayLists: too many surfaces\n");
|
||||
m->numsurfaces = j;
|
||||
brush->numsurfaces = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
surf = m->surfaces + j;
|
||||
surf->ec_index = dm - m->submodels;
|
||||
surf = brush->surfaces + j;
|
||||
surf->ec_index = dm - brush->submodels;
|
||||
if (!surf->ec_index && m != r_worldentity.model)
|
||||
surf->ec_index = -1 - i; // instanced model
|
||||
tex = surf->texinfo->texture->render;
|
||||
|
@ -654,8 +660,10 @@ R_DrawBrushModel (entity_t *e)
|
|||
msurface_t *surf;
|
||||
qboolean rotated;
|
||||
vec3_t mins, maxs, org;
|
||||
mod_brush_t *brush;
|
||||
|
||||
model = e->model;
|
||||
brush = &model->brush;
|
||||
if (e->transform[0] != 1 || e->transform[5] != 1 || e->transform[10] != 1) {
|
||||
rotated = true;
|
||||
radius = model->radius;
|
||||
|
@ -680,7 +688,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
}
|
||||
|
||||
// calculate dynamic lighting for bmodel if it's not an instanced model
|
||||
if (model->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
if (brush->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
|
@ -689,14 +697,14 @@ R_DrawBrushModel (entity_t *e)
|
|||
continue;
|
||||
|
||||
VectorSubtract (r_dlights[k].origin, e->origin, lightorigin);
|
||||
R_RecursiveMarkLights (lightorigin, &r_dlights[k], k,
|
||||
model->nodes + model->hulls[0].firstclipnode);
|
||||
R_RecursiveMarkLights (brush, lightorigin, &r_dlights[k], k,
|
||||
brush->nodes + brush->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
|
||||
surf = &model->surfaces[model->firstmodelsurface];
|
||||
surf = &brush->surfaces[brush->firstmodelsurface];
|
||||
|
||||
for (i = 0; i < model->nummodelsurfaces; i++, surf++) {
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++, surf++) {
|
||||
// find the node side on which we are
|
||||
plane = surf->plane;
|
||||
|
||||
|
@ -705,7 +713,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
// enqueue the polygon
|
||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON))
|
||||
|| (!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||
chain_surface (surf, e->transform, e->colormod);
|
||||
chain_surface (brush, surf, e->transform, e->colormod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -730,7 +738,7 @@ get_side (mnode_t *node)
|
|||
}
|
||||
|
||||
static inline void
|
||||
visit_node (mnode_t *node, int side)
|
||||
visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
||||
{
|
||||
int c;
|
||||
msurface_t *surf;
|
||||
|
@ -739,7 +747,7 @@ visit_node (mnode_t *node, int side)
|
|||
side = (~side + 1) & SURF_PLANEBACK;
|
||||
// draw stuff
|
||||
if ((c = node->numsurfaces)) {
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (; c; c--, surf++) {
|
||||
if (surf->visframe != r_visframecount)
|
||||
continue;
|
||||
|
@ -748,7 +756,7 @@ visit_node (mnode_t *node, int side)
|
|||
if (side ^ (surf->flags & SURF_PLANEBACK))
|
||||
continue; // wrong side
|
||||
|
||||
chain_surface (surf, 0, 0);
|
||||
chain_surface (brush, surf, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +774,7 @@ test_node (mnode_t *node)
|
|||
}
|
||||
|
||||
static void
|
||||
R_VisitWorldNodes (model_t *model)
|
||||
R_VisitWorldNodes (mod_brush_t *brush)
|
||||
{
|
||||
typedef struct {
|
||||
mnode_t *node;
|
||||
|
@ -778,9 +786,9 @@ R_VisitWorldNodes (model_t *model)
|
|||
mnode_t *front;
|
||||
int side;
|
||||
|
||||
node = model->nodes;
|
||||
node = brush->nodes;
|
||||
// +2 for paranoia
|
||||
node_stack = alloca ((model->depth + 2) * sizeof (rstack_t));
|
||||
node_stack = alloca ((brush->depth + 2) * sizeof (rstack_t));
|
||||
node_ptr = node_stack;
|
||||
|
||||
while (1) {
|
||||
|
@ -796,7 +804,7 @@ R_VisitWorldNodes (model_t *model)
|
|||
}
|
||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||
visit_leaf ((mleaf_t *) front);
|
||||
visit_node (node, side);
|
||||
visit_node (brush, node, side);
|
||||
node = node->children[!side];
|
||||
}
|
||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||
|
@ -805,7 +813,7 @@ R_VisitWorldNodes (model_t *model)
|
|||
node_ptr--;
|
||||
node = node_ptr->node;
|
||||
side = node_ptr->side;
|
||||
visit_node (node, side);
|
||||
visit_node (brush, node, side);
|
||||
node = node->children[!side];
|
||||
continue;
|
||||
}
|
||||
|
@ -1123,7 +1131,7 @@ glsl_R_DrawWorld (void)
|
|||
|
||||
currententity = &worldent;
|
||||
|
||||
R_VisitWorldNodes (worldent.model);
|
||||
R_VisitWorldNodes (&worldent.model->brush);
|
||||
if (r_drawentities->int_val) {
|
||||
entity_t *ent;
|
||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||
|
|
|
@ -217,7 +217,7 @@ glsl_R_DrawIQM (void)
|
|||
float blend;
|
||||
iqmframe_t *frame;
|
||||
|
||||
R_LightPoint (ent->origin); //FIXME min_light?
|
||||
R_LightPoint (&r_worldentity.model->brush, ent->origin);//FIXME min_light?
|
||||
VectorScale (ambientcolor, 1/255.0, ambientcolor);
|
||||
R_FindNearLights (ent->origin, MAX_IQM_LIGHTS, lights);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static scrap_t *light_scrap;
|
|||
static unsigned *blocklights;
|
||||
static int bl_extents[2];
|
||||
|
||||
void (*glsl_R_BuildLightMap) (msurface_t *surf);
|
||||
void (*glsl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
||||
|
||||
static void
|
||||
R_AddDynamicLights_1 (msurface_t *surf)
|
||||
|
@ -121,7 +121,7 @@ R_AddDynamicLights_1 (msurface_t *surf)
|
|||
}
|
||||
|
||||
static void
|
||||
R_BuildLightMap_1 (msurface_t *surf)
|
||||
R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
||||
{
|
||||
int smax, tmax, size;
|
||||
unsigned scale;
|
||||
|
@ -138,7 +138,7 @@ R_BuildLightMap_1 (msurface_t *surf)
|
|||
|
||||
// clear to no light
|
||||
memset (blocklights, 0, size * sizeof (blocklights[0]));
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!brush->lightdata) {
|
||||
// because we by-pass the inversion, "no light" = "full bright"
|
||||
GLSL_SubpicUpdate (surf->lightpic, (byte *) blocklights, 1);
|
||||
return;
|
||||
|
@ -196,6 +196,7 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
|
|||
{
|
||||
int i, j, size;
|
||||
model_t *m;
|
||||
mod_brush_t *brush;
|
||||
|
||||
//FIXME RGB support
|
||||
if (!light_scrap) {
|
||||
|
@ -210,13 +211,14 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
|
|||
m = models[j];
|
||||
if (!m)
|
||||
break;
|
||||
if (m->path[0] == '*') {
|
||||
if (m->path[0] == '*' || m->type != mod_brush) {
|
||||
// sub model surfaces are processed as part of the main model
|
||||
continue;
|
||||
}
|
||||
brush = &m->brush;
|
||||
// non-bsp models don't have surfaces.
|
||||
for (i = 0; i < m->numsurfaces; i++) {
|
||||
msurface_t *surf = m->surfaces + i;
|
||||
for (i = 0; i < brush->numsurfaces; i++) {
|
||||
msurface_t *surf = brush->surfaces + i;
|
||||
surf->lightpic = 0; // paranoia
|
||||
if (surf->flags & SURF_DRAWTURB)
|
||||
continue;
|
||||
|
@ -231,15 +233,16 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
|
|||
m = models[j];
|
||||
if (!m)
|
||||
break;
|
||||
if (m->path[0] == '*') {
|
||||
if (m->path[0] == '*' || m->type != mod_brush) {
|
||||
// sub model surfaces are processed as part of the main model
|
||||
continue;
|
||||
}
|
||||
brush = &m->brush;
|
||||
// non-bsp models don't have surfaces.
|
||||
for (i = 0; i < m->numsurfaces; i++) {
|
||||
msurface_t *surf = m->surfaces + i;
|
||||
for (i = 0; i < brush->numsurfaces; i++) {
|
||||
msurface_t *surf = brush->surfaces + i;
|
||||
if (surf->lightpic)
|
||||
glsl_R_BuildLightMap (surf);
|
||||
glsl_R_BuildLightMap (brush, surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#define R_InitParticles glsl_R_InitParticles
|
||||
#define R_InitSky glsl_R_InitSky
|
||||
#define R_InitSprites glsl_R_InitSprites
|
||||
#define R_InitSurfaceChains glsl_R_InitSurfaceChains
|
||||
#define R_LineGraph glsl_R_LineGraph
|
||||
#define R_LoadSky_f glsl_R_LoadSky_f
|
||||
#define R_LoadSkys glsl_R_LoadSkys
|
||||
|
|
|
@ -67,13 +67,13 @@ R_MarkLeaves (void)
|
|||
r_oldviewleaf = 0; // so vis will be recalcualted when novis gets
|
||||
// turned off
|
||||
vis = solid;
|
||||
memset (solid, 0xff, (r_worldentity.model->numleafs + 7) >> 3);
|
||||
memset (solid, 0xff, (r_worldentity.model->brush.numleafs + 7) >> 3);
|
||||
} else
|
||||
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.model);
|
||||
|
||||
for (i = 0; (int) i < r_worldentity.model->numleafs; i++) {
|
||||
for (i = 0; (int) i < r_worldentity.model->brush.numleafs; i++) {
|
||||
if (vis[i >> 3] & (1 << (i & 7))) {
|
||||
leaf = &r_worldentity.model->leafs[i + 1];
|
||||
leaf = &r_worldentity.model->brush.leafs[i + 1];
|
||||
if ((c = leaf->nummarksurfaces)) {
|
||||
mark = leaf->firstmarksurface;
|
||||
do {
|
||||
|
|
|
@ -195,7 +195,7 @@ R_SplitEntityOnNode (mnode_t *node)
|
|||
}
|
||||
|
||||
void
|
||||
R_AddEfrags (entity_t *ent)
|
||||
R_AddEfrags (mod_brush_t *brush, entity_t *ent)
|
||||
{
|
||||
model_t *entmodel;
|
||||
|
||||
|
@ -215,7 +215,7 @@ R_AddEfrags (entity_t *ent)
|
|||
VectorAdd (ent->origin, entmodel->mins, r_emins);
|
||||
VectorAdd (ent->origin, entmodel->maxs, r_emaxs);
|
||||
|
||||
R_SplitEntityOnNode (r_worldentity.model->nodes);
|
||||
R_SplitEntityOnNode (brush->nodes);
|
||||
|
||||
ent->topnode = r_pefragtopnode;
|
||||
}
|
||||
|
|
|
@ -203,8 +203,8 @@ mark_surfaces (msurface_t *surf, const vec3_t lightorigin, dlight_t *light,
|
|||
// LordHavoc: heavily modified, to eliminate unnecessary texture uploads,
|
||||
// and support bmodel lighting better
|
||||
void
|
||||
R_RecursiveMarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum,
|
||||
mnode_t *node)
|
||||
R_RecursiveMarkLights (mod_brush_t *brush, const vec3_t lightorigin,
|
||||
dlight_t *light, int lightnum, mnode_t *node)
|
||||
{
|
||||
unsigned i;
|
||||
float ndist, maxdist;
|
||||
|
@ -240,14 +240,14 @@ loc0:
|
|||
}
|
||||
|
||||
// mark the polygons
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (i = 0; i < node->numsurfaces; i++, surf++) {
|
||||
mark_surfaces (surf, lightorigin, light, lightnum);
|
||||
}
|
||||
|
||||
if (node->children[0]->contents >= 0) {
|
||||
if (node->children[1]->contents >= 0)
|
||||
R_RecursiveMarkLights (lightorigin, light, lightnum,
|
||||
R_RecursiveMarkLights (brush, lightorigin, light, lightnum,
|
||||
node->children[1]);
|
||||
node = node->children[0];
|
||||
goto loc0;
|
||||
|
@ -262,11 +262,12 @@ void
|
|||
R_MarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum,
|
||||
model_t *model)
|
||||
{
|
||||
mod_brush_t *brush = &model->brush;
|
||||
mleaf_t *pvsleaf = Mod_PointInLeaf (lightorigin, model);
|
||||
|
||||
if (!pvsleaf->compressed_vis) {
|
||||
mnode_t *node = model->nodes + model->hulls[0].firstclipnode;
|
||||
R_RecursiveMarkLights (lightorigin, light, lightnum, node);
|
||||
mnode_t *node = brush->nodes + brush->hulls[0].firstclipnode;
|
||||
R_RecursiveMarkLights (brush, lightorigin, light, lightnum, node);
|
||||
} else {
|
||||
float radius = light->radius;
|
||||
vec3_t mins, maxs;
|
||||
|
@ -280,16 +281,16 @@ R_MarkLights (const vec3_t lightorigin, dlight_t *light, int lightnum,
|
|||
maxs[0] = lightorigin[0] + radius;
|
||||
maxs[1] = lightorigin[1] + radius;
|
||||
maxs[2] = lightorigin[2] + radius;
|
||||
while (leafnum < model->numleafs) {
|
||||
while (leafnum < brush->numleafs) {
|
||||
int b;
|
||||
if (!(vis_bits = *in++)) {
|
||||
leafnum += (*in++) * 8;
|
||||
continue;
|
||||
}
|
||||
for (b = 1; b < 256 && leafnum < model->numleafs;
|
||||
for (b = 1; b < 256 && leafnum < brush->numleafs;
|
||||
b <<= 1, leafnum++) {
|
||||
int m;
|
||||
mleaf_t *leaf = &model->leafs[leafnum + 1];
|
||||
mleaf_t *leaf = &brush->leafs[leafnum + 1];
|
||||
if (!(vis_bits & b))
|
||||
continue;
|
||||
if (leaf->visframe != r_visframecount)
|
||||
|
@ -400,7 +401,8 @@ calc_lighting_3 (msurface_t *surf, int ds, int dt)
|
|||
}
|
||||
|
||||
static int
|
||||
RecursiveLightPoint (mnode_t *node, const vec3_t start, const vec3_t end)
|
||||
RecursiveLightPoint (mod_brush_t *brush, mnode_t *node, const vec3_t start,
|
||||
const vec3_t end)
|
||||
{
|
||||
unsigned i;
|
||||
int r, s, t, ds, dt, side;
|
||||
|
@ -430,7 +432,7 @@ loop:
|
|||
mid[2] = start[2] + (end[2] - start[2]) * frac;
|
||||
|
||||
// go down front side
|
||||
r = RecursiveLightPoint (node->children[side], start, mid);
|
||||
r = RecursiveLightPoint (brush, node->children[side], start, mid);
|
||||
if (r >= 0)
|
||||
return r; // hit something
|
||||
|
||||
|
@ -441,7 +443,7 @@ loop:
|
|||
VectorCopy (mid, lightspot);
|
||||
lightplane = plane;
|
||||
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (i = 0; i < node->numsurfaces; i++, surf++) {
|
||||
if (surf->flags & SURF_DRAWTILED)
|
||||
continue; // no lightmaps
|
||||
|
@ -472,16 +474,16 @@ loop:
|
|||
}
|
||||
|
||||
// go down back side
|
||||
return RecursiveLightPoint (node->children[!side], mid, end);
|
||||
return RecursiveLightPoint (brush, node->children[!side], mid, end);
|
||||
}
|
||||
|
||||
int
|
||||
R_LightPoint (const vec3_t p)
|
||||
R_LightPoint (mod_brush_t *brush, const vec3_t p)
|
||||
{
|
||||
vec3_t end;
|
||||
int r;
|
||||
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!brush->lightdata) {
|
||||
// allow dlights to have some effect, so don't go /quite/ fullbright
|
||||
ambientcolor[2] = ambientcolor[1] = ambientcolor[0] = 200;
|
||||
return 200;
|
||||
|
@ -491,7 +493,7 @@ R_LightPoint (const vec3_t p)
|
|||
end[1] = p[1];
|
||||
end[2] = p[2] - 2048;
|
||||
|
||||
r = RecursiveLightPoint (r_worldentity.model->nodes, p, end);
|
||||
r = RecursiveLightPoint (brush, brush->nodes, p, end);
|
||||
|
||||
if (r == -1)
|
||||
r = 0;
|
||||
|
|
|
@ -237,7 +237,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
|
|||
|
||||
|
||||
void
|
||||
R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
||||
R_DrawSolidClippedSubmodelPolygons (model_t *model)
|
||||
{
|
||||
int i, j, lindex;
|
||||
vec_t dot;
|
||||
|
@ -247,12 +247,13 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
|||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
|
||||
medge_t *pedge, *pedges;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
pedges = pmodel->edges;
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
numsurfaces = brush->nummodelsurfaces;
|
||||
pedges = brush->edges;
|
||||
|
||||
for (i = 0; i < numsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
|
@ -278,7 +279,7 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
|||
numbedges += psurf->numedges;
|
||||
|
||||
for (j = 0; j < psurf->numedges; j++) {
|
||||
lindex = pmodel->surfedges[psurf->firstedge + j];
|
||||
lindex = brush->surfedges[psurf->firstedge + j];
|
||||
|
||||
if (lindex > 0) {
|
||||
pedge = &pedges[lindex];
|
||||
|
@ -306,18 +307,19 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
|||
|
||||
|
||||
void
|
||||
R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
|
||||
R_DrawSubmodelPolygons (model_t *model, int clipflags)
|
||||
{
|
||||
int i;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
plane_t *pplane;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
numsurfaces = brush->nummodelsurfaces;
|
||||
|
||||
for (i = 0; i < numsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
|
@ -358,7 +360,7 @@ get_side (mnode_t *node)
|
|||
}
|
||||
|
||||
static void
|
||||
visit_node (mnode_t *node, int side, int clipflags)
|
||||
visit_node (mod_brush_t *brush, mnode_t *node, int side, int clipflags)
|
||||
{
|
||||
int c;
|
||||
msurface_t *surf;
|
||||
|
@ -367,7 +369,7 @@ visit_node (mnode_t *node, int side, int clipflags)
|
|||
side = (~side + 1) & SURF_PLANEBACK;
|
||||
// draw stuff
|
||||
if ((c = node->numsurfaces)) {
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (; c; c--, surf++) {
|
||||
if (surf->visframe != r_visframecount)
|
||||
continue;
|
||||
|
@ -444,7 +446,7 @@ test_node (mnode_t *node, int *clipflags)
|
|||
}
|
||||
|
||||
static void
|
||||
R_VisitWorldNodes (model_t *model, int clipflags)
|
||||
R_VisitWorldNodes (mod_brush_t *brush, int clipflags)
|
||||
{
|
||||
typedef struct {
|
||||
mnode_t *node;
|
||||
|
@ -456,9 +458,9 @@ R_VisitWorldNodes (model_t *model, int clipflags)
|
|||
mnode_t *front;
|
||||
int side, cf;
|
||||
|
||||
node = model->nodes;
|
||||
node = brush->nodes;
|
||||
// +2 for paranoia
|
||||
node_stack = alloca ((model->depth + 2) * sizeof (rstack_t));
|
||||
node_stack = alloca ((brush->depth + 2) * sizeof (rstack_t));
|
||||
node_ptr = node_stack;
|
||||
|
||||
cf = clipflags;
|
||||
|
@ -478,7 +480,7 @@ R_VisitWorldNodes (model_t *model, int clipflags)
|
|||
}
|
||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||
visit_leaf ((mleaf_t *) front);
|
||||
visit_node (node, side, clipflags);
|
||||
visit_node (brush, node, side, clipflags);
|
||||
node = node->children[!side];
|
||||
}
|
||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||
|
@ -488,7 +490,7 @@ R_VisitWorldNodes (model_t *model, int clipflags)
|
|||
node = node_ptr->node;
|
||||
side = node_ptr->side;
|
||||
clipflags = node_ptr->clipflags;
|
||||
visit_node (node, side, clipflags);
|
||||
visit_node (brush, node, side, clipflags);
|
||||
node = node->children[!side];
|
||||
continue;
|
||||
}
|
||||
|
@ -502,17 +504,17 @@ void
|
|||
R_RenderWorld (void)
|
||||
{
|
||||
int i;
|
||||
model_t *clmodel;
|
||||
btofpoly_t btofpolys[MAX_BTOFPOLYS];
|
||||
mod_brush_t *brush;
|
||||
|
||||
pbtofpolys = btofpolys;
|
||||
|
||||
currententity = &r_worldentity;
|
||||
VectorCopy (r_origin, modelorg);
|
||||
clmodel = currententity->model;
|
||||
r_pcurrentvertbase = clmodel->vertexes;
|
||||
brush = ¤tentity->model->brush;
|
||||
r_pcurrentvertbase = brush->vertexes;
|
||||
|
||||
R_VisitWorldNodes (clmodel, 15);
|
||||
R_VisitWorldNodes (brush, 15);
|
||||
|
||||
// if the driver wants the polygons back to front, play the visible ones
|
||||
// back in that order
|
||||
|
|
|
@ -353,6 +353,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
|
|||
vec3_t p_normal;
|
||||
medge_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
mod_brush_t *brush = ¤tentity->model->brush;
|
||||
|
||||
// skip out if no more surfs
|
||||
if ((surface_p) >= surf_max) {
|
||||
|
@ -382,11 +383,11 @@ R_RenderFace (msurface_t *fa, int clipflags)
|
|||
r_nearzi = 0;
|
||||
r_nearzionly = false;
|
||||
makeleftedge = makerightedge = false;
|
||||
pedges = currententity->model->edges;
|
||||
pedges = brush->edges;
|
||||
r_lastvertvalid = false;
|
||||
|
||||
for (i = 0; i < fa->numedges; i++) {
|
||||
lindex = currententity->model->surfedges[fa->firstedge + i];
|
||||
lindex = brush->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0) {
|
||||
r_pedge = &pedges[lindex];
|
||||
|
@ -623,6 +624,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
|
|||
polyvert_t pverts[100]; // FIXME: do real number, safely
|
||||
int vertpage, newverts, newpage, lastvert;
|
||||
qboolean visible;
|
||||
mod_brush_t *brush = ¤tentity->model->brush;
|
||||
|
||||
// FIXME: clean this up and make it faster
|
||||
// FIXME: guard against running out of vertices
|
||||
|
@ -641,12 +643,12 @@ R_RenderPoly (msurface_t *fa, int clipflags)
|
|||
|
||||
// reconstruct the polygon
|
||||
// FIXME: these should be precalculated and loaded off disk
|
||||
pedges = currententity->model->edges;
|
||||
pedges = brush->edges;
|
||||
lnumverts = fa->numedges;
|
||||
vertpage = 0;
|
||||
|
||||
for (i = 0; i < lnumverts; i++) {
|
||||
lindex = currententity->model->surfedges[fa->firstedge + i];
|
||||
lindex = brush->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0) {
|
||||
r_pedge = &pedges[lindex];
|
||||
|
@ -777,15 +779,16 @@ R_RenderPoly (msurface_t *fa, int clipflags)
|
|||
|
||||
|
||||
void
|
||||
R_ZDrawSubmodelPolys (model_t *pmodel)
|
||||
R_ZDrawSubmodelPolys (model_t *model)
|
||||
{
|
||||
int i, numsurfaces;
|
||||
msurface_t *psurf;
|
||||
float dot;
|
||||
plane_t *pplane;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
numsurfaces = brush->nummodelsurfaces;
|
||||
|
||||
for (i = 0; i < numsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
|
|
|
@ -164,6 +164,7 @@ void
|
|||
R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
||||
{
|
||||
int i;
|
||||
mod_brush_t *brush = &worldmodel->brush;
|
||||
|
||||
memset (&r_worldentity, 0, sizeof (r_worldentity));
|
||||
r_worldentity.model = worldmodel;
|
||||
|
@ -172,11 +173,11 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
// FIXME: is this one short?
|
||||
for (i = 0; i < r_worldentity.model->numleafs; i++)
|
||||
r_worldentity.model->leafs[i].efrags = NULL;
|
||||
for (i = 0; i < brush->numleafs; i++)
|
||||
brush->leafs[i].efrags = NULL;
|
||||
|
||||
if (worldmodel->skytexture)
|
||||
R_InitSky (worldmodel->skytexture);
|
||||
if (brush->skytexture)
|
||||
R_InitSky (brush->skytexture);
|
||||
|
||||
// Force a vis update
|
||||
r_viewleaf = NULL;
|
||||
|
@ -381,7 +382,8 @@ R_DrawEntitiesOnList (void)
|
|||
if (currententity->model->type == mod_iqm//FIXME
|
||||
|| R_AliasCheckBBox ()) {
|
||||
// 128 instead of 255 due to clamping below
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
j = max (R_LightPoint (&r_worldentity.model->brush,
|
||||
currententity->origin), minlight * 128);
|
||||
|
||||
lighting.ambientlight = j;
|
||||
lighting.shadelight = j;
|
||||
|
@ -448,7 +450,8 @@ R_DrawViewModel (void)
|
|||
|
||||
minlight = max (currententity->min_light, currententity->model->min_light);
|
||||
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
j = max (R_LightPoint (&r_worldentity.model->brush,
|
||||
currententity->origin), minlight * 128);
|
||||
|
||||
r_viewlighting.ambientlight = j;
|
||||
r_viewlighting.shadelight = j;
|
||||
|
@ -568,19 +571,20 @@ R_DrawBEntitiesOnList (void)
|
|||
clipflags = R_BmodelCheckBBox (clmodel, minmaxs);
|
||||
|
||||
if (clipflags != BMODEL_FULLY_CLIPPED) {
|
||||
mod_brush_t *brush = &clmodel->brush;
|
||||
VectorCopy (currententity->origin, r_entorigin);
|
||||
VectorSubtract (r_origin, r_entorigin, modelorg);
|
||||
|
||||
// FIXME: is this needed?
|
||||
VectorCopy (modelorg, r_worldmodelorg);
|
||||
r_pcurrentvertbase = clmodel->vertexes;
|
||||
r_pcurrentvertbase = brush->vertexes;
|
||||
|
||||
// FIXME: stop transforming twice
|
||||
R_RotateBmodel ();
|
||||
|
||||
// calculate dynamic lighting for bmodel if it's not an
|
||||
// instanced model
|
||||
if (clmodel->firstmodelsurface != 0) {
|
||||
if (brush->firstmodelsurface != 0) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
|
@ -590,9 +594,10 @@ R_DrawBEntitiesOnList (void)
|
|||
VectorSubtract (r_dlights[k].origin,
|
||||
currententity->origin,
|
||||
lightorigin);
|
||||
R_RecursiveMarkLights (lightorigin, &r_dlights[k],
|
||||
k, clmodel->nodes +
|
||||
clmodel->hulls[0].firstclipnode);
|
||||
R_RecursiveMarkLights (brush, lightorigin,
|
||||
&r_dlights[k], k,
|
||||
brush->nodes
|
||||
+ brush->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
// if the driver wants polygons, deliver those.
|
||||
|
|
|
@ -154,7 +154,7 @@ R_BuildLightMap (void)
|
|||
size = smax * tmax;
|
||||
lightmap = surf->samples;
|
||||
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!r_worldentity.model->brush.lightdata) {
|
||||
for (i = 0; i < size; i++)
|
||||
blocklights[i] = 0;
|
||||
return;
|
||||
|
|
|
@ -240,7 +240,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
|
|||
|
||||
|
||||
void
|
||||
sw32_R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
||||
sw32_R_DrawSolidClippedSubmodelPolygons (model_t *model)
|
||||
{
|
||||
int i, j, lindex;
|
||||
vec_t dot;
|
||||
|
@ -250,12 +250,13 @@ sw32_R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
|||
mvertex_t bverts[MAX_BMODEL_VERTS];
|
||||
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
|
||||
medge_t *pedge, *pedges;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
pedges = pmodel->edges;
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
numsurfaces = brush->nummodelsurfaces;
|
||||
pedges = brush->edges;
|
||||
|
||||
for (i = 0; i < numsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
|
@ -281,7 +282,7 @@ sw32_R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
|||
numbedges += psurf->numedges;
|
||||
|
||||
for (j = 0; j < psurf->numedges; j++) {
|
||||
lindex = pmodel->surfedges[psurf->firstedge + j];
|
||||
lindex = brush->surfedges[psurf->firstedge + j];
|
||||
|
||||
if (lindex > 0) {
|
||||
pedge = &pedges[lindex];
|
||||
|
@ -309,18 +310,19 @@ sw32_R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
|
|||
|
||||
|
||||
void
|
||||
sw32_R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
|
||||
sw32_R_DrawSubmodelPolygons (model_t *model, int clipflags)
|
||||
{
|
||||
int i;
|
||||
vec_t dot;
|
||||
msurface_t *psurf;
|
||||
int numsurfaces;
|
||||
plane_t *pplane;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
|
||||
// FIXME: use bounding-box-based frustum clipping info?
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
numsurfaces = brush->nummodelsurfaces;
|
||||
|
||||
for (i = 0; i < numsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
|
@ -361,7 +363,7 @@ get_side (mnode_t *node)
|
|||
}
|
||||
|
||||
static void
|
||||
visit_node (mnode_t *node, int side, int clipflags)
|
||||
visit_node (mod_brush_t *brush, mnode_t *node, int side, int clipflags)
|
||||
{
|
||||
int c;
|
||||
msurface_t *surf;
|
||||
|
@ -370,7 +372,7 @@ visit_node (mnode_t *node, int side, int clipflags)
|
|||
side = (~side + 1) & SURF_PLANEBACK;
|
||||
// draw stuff
|
||||
if ((c = node->numsurfaces)) {
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (; c; c--, surf++) {
|
||||
if (surf->visframe != r_visframecount)
|
||||
continue;
|
||||
|
@ -447,7 +449,7 @@ test_node (mnode_t *node, int *clipflags)
|
|||
}
|
||||
|
||||
static void
|
||||
R_VisitWorldNodes (model_t *model, int clipflags)
|
||||
R_VisitWorldNodes (mod_brush_t *brush, int clipflags)
|
||||
{
|
||||
typedef struct {
|
||||
mnode_t *node;
|
||||
|
@ -459,9 +461,9 @@ R_VisitWorldNodes (model_t *model, int clipflags)
|
|||
mnode_t *front;
|
||||
int side, cf;
|
||||
|
||||
node = model->nodes;
|
||||
node = brush->nodes;
|
||||
// +2 for paranoia
|
||||
node_stack = alloca ((model->depth + 2) * sizeof (rstack_t));
|
||||
node_stack = alloca ((brush->depth + 2) * sizeof (rstack_t));
|
||||
node_ptr = node_stack;
|
||||
|
||||
cf = clipflags;
|
||||
|
@ -481,7 +483,7 @@ R_VisitWorldNodes (model_t *model, int clipflags)
|
|||
}
|
||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||
visit_leaf ((mleaf_t *) front);
|
||||
visit_node (node, side, clipflags);
|
||||
visit_node (brush, node, side, clipflags);
|
||||
node = node->children[!side];
|
||||
}
|
||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||
|
@ -491,7 +493,7 @@ R_VisitWorldNodes (model_t *model, int clipflags)
|
|||
node = node_ptr->node;
|
||||
side = node_ptr->side;
|
||||
clipflags = node_ptr->clipflags;
|
||||
visit_node (node, side, clipflags);
|
||||
visit_node (brush, node, side, clipflags);
|
||||
node = node->children[!side];
|
||||
continue;
|
||||
}
|
||||
|
@ -505,17 +507,17 @@ void
|
|||
sw32_R_RenderWorld (void)
|
||||
{
|
||||
int i;
|
||||
model_t *clmodel;
|
||||
btofpoly_t btofpolys[MAX_BTOFPOLYS];
|
||||
mod_brush_t *brush;
|
||||
|
||||
pbtofpolys = btofpolys;
|
||||
|
||||
currententity = &r_worldentity;
|
||||
VectorCopy (r_origin, modelorg);
|
||||
clmodel = currententity->model;
|
||||
r_pcurrentvertbase = clmodel->vertexes;
|
||||
brush = ¤tentity->model->brush;
|
||||
r_pcurrentvertbase = brush->vertexes;
|
||||
|
||||
R_VisitWorldNodes (clmodel, 15);
|
||||
R_VisitWorldNodes (brush, 15);
|
||||
|
||||
// if the driver wants the polygons back to front, play the visible ones
|
||||
// back in that order
|
||||
|
|
|
@ -349,6 +349,7 @@ sw32_R_RenderFace (msurface_t *fa, int clipflags)
|
|||
vec3_t p_normal;
|
||||
medge_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
mod_brush_t *brush = ¤tentity->model->brush;
|
||||
|
||||
// skip out if no more surfs
|
||||
if ((sw32_surface_p) >= sw32_surf_max) {
|
||||
|
@ -378,11 +379,11 @@ sw32_R_RenderFace (msurface_t *fa, int clipflags)
|
|||
sw32_r_nearzi = 0;
|
||||
sw32_r_nearzionly = false;
|
||||
makeleftedge = makerightedge = false;
|
||||
pedges = currententity->model->edges;
|
||||
pedges = brush->edges;
|
||||
sw32_r_lastvertvalid = false;
|
||||
|
||||
for (i = 0; i < fa->numedges; i++) {
|
||||
lindex = currententity->model->surfedges[fa->firstedge + i];
|
||||
lindex = brush->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0) {
|
||||
sw32_r_pedge = &pedges[lindex];
|
||||
|
@ -621,6 +622,7 @@ sw32_R_RenderPoly (msurface_t *fa, int clipflags)
|
|||
polyvert_t pverts[100]; // FIXME: do real number, safely
|
||||
int vertpage, newverts, newpage, lastvert;
|
||||
qboolean visible;
|
||||
mod_brush_t *brush = ¤tentity->model->brush;
|
||||
|
||||
// FIXME: clean this up and make it faster
|
||||
// FIXME: guard against running out of vertices
|
||||
|
@ -639,12 +641,12 @@ sw32_R_RenderPoly (msurface_t *fa, int clipflags)
|
|||
|
||||
// reconstruct the polygon
|
||||
// FIXME: these should be precalculated and loaded off disk
|
||||
pedges = currententity->model->edges;
|
||||
pedges = brush->edges;
|
||||
lnumverts = fa->numedges;
|
||||
vertpage = 0;
|
||||
|
||||
for (i = 0; i < lnumverts; i++) {
|
||||
lindex = currententity->model->surfedges[fa->firstedge + i];
|
||||
lindex = brush->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0) {
|
||||
sw32_r_pedge = &pedges[lindex];
|
||||
|
@ -775,15 +777,16 @@ sw32_R_RenderPoly (msurface_t *fa, int clipflags)
|
|||
|
||||
|
||||
void
|
||||
sw32_R_ZDrawSubmodelPolys (model_t *pmodel)
|
||||
sw32_R_ZDrawSubmodelPolys (model_t *model)
|
||||
{
|
||||
int i, numsurfaces;
|
||||
msurface_t *psurf;
|
||||
float dot;
|
||||
plane_t *pplane;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
|
||||
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
|
||||
numsurfaces = pmodel->nummodelsurfaces;
|
||||
psurf = &brush->surfaces[brush->firstmodelsurface];
|
||||
numsurfaces = brush->nummodelsurfaces;
|
||||
|
||||
for (i = 0; i < numsurfaces; i++, psurf++) {
|
||||
// find which side of the node we are on
|
||||
|
|
|
@ -180,6 +180,7 @@ void
|
|||
sw32_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
||||
{
|
||||
int i;
|
||||
mod_brush_t *brush = &worldmodel->brush;
|
||||
|
||||
memset (&r_worldentity, 0, sizeof (r_worldentity));
|
||||
r_worldentity.model = worldmodel;
|
||||
|
@ -188,11 +189,11 @@ sw32_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
|
|||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
// FIXME: is this one short?
|
||||
for (i = 0; i < r_worldentity.model->numleafs; i++)
|
||||
r_worldentity.model->leafs[i].efrags = NULL;
|
||||
for (i = 0; i < brush->numleafs; i++)
|
||||
brush->leafs[i].efrags = NULL;
|
||||
|
||||
if (worldmodel->skytexture)
|
||||
sw32_R_InitSky (worldmodel->skytexture);
|
||||
if (brush->skytexture)
|
||||
sw32_R_InitSky (brush->skytexture);
|
||||
|
||||
// Force a vis update
|
||||
r_viewleaf = NULL;
|
||||
|
@ -388,7 +389,9 @@ R_DrawEntitiesOnList (void)
|
|||
if (currententity->model->type == mod_iqm//FIXME
|
||||
|| sw32_R_AliasCheckBBox ()) {
|
||||
// 128 instead of 255 due to clamping below
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
j = max (R_LightPoint (&r_worldentity.model->brush,
|
||||
currententity->origin),
|
||||
minlight * 128);
|
||||
|
||||
lighting.ambientlight = j;
|
||||
lighting.shadelight = j;
|
||||
|
@ -454,7 +457,8 @@ R_DrawViewModel (void)
|
|||
|
||||
minlight = max (currententity->min_light, currententity->model->min_light);
|
||||
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
j = max (R_LightPoint (&r_worldentity.model->brush,
|
||||
currententity->origin), minlight * 128);
|
||||
|
||||
r_viewlighting.ambientlight = j;
|
||||
r_viewlighting.shadelight = j;
|
||||
|
@ -574,19 +578,20 @@ R_DrawBEntitiesOnList (void)
|
|||
clipflags = R_BmodelCheckBBox (clmodel, minmaxs);
|
||||
|
||||
if (clipflags != BMODEL_FULLY_CLIPPED) {
|
||||
mod_brush_t *brush = &clmodel->brush;
|
||||
VectorCopy (currententity->origin, r_entorigin);
|
||||
VectorSubtract (r_origin, r_entorigin, modelorg);
|
||||
|
||||
// FIXME: is this needed?
|
||||
VectorCopy (modelorg, sw32_r_worldmodelorg);
|
||||
r_pcurrentvertbase = clmodel->vertexes;
|
||||
r_pcurrentvertbase = brush->vertexes;
|
||||
|
||||
// FIXME: stop transforming twice
|
||||
sw32_R_RotateBmodel ();
|
||||
|
||||
// calculate dynamic lighting for bmodel if it's not an
|
||||
// instanced model
|
||||
if (clmodel->firstmodelsurface != 0) {
|
||||
if (brush->firstmodelsurface != 0) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
|
@ -596,9 +601,10 @@ R_DrawBEntitiesOnList (void)
|
|||
VectorSubtract (r_dlights[k].origin,
|
||||
currententity->origin,
|
||||
lightorigin);
|
||||
R_RecursiveMarkLights (lightorigin, &r_dlights[k],
|
||||
k, clmodel->nodes +
|
||||
clmodel->hulls[0].firstclipnode);
|
||||
R_RecursiveMarkLights (brush, lightorigin,
|
||||
&r_dlights[k], k,
|
||||
brush->nodes
|
||||
+ brush->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
// if the driver wants polygons, deliver those.
|
||||
|
|
|
@ -172,7 +172,7 @@ R_BuildLightMap (void)
|
|||
size = smax * tmax;
|
||||
lightmap = surf->samples;
|
||||
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!r_worldentity.model->brush.lightdata) {
|
||||
for (i = 0; i < size; i++)
|
||||
blocklights[i] = 0;
|
||||
return;
|
||||
|
|
|
@ -144,7 +144,7 @@ calc_lighting (qfv_light_t *light, entity_t *ent)
|
|||
{
|
||||
vec3_t ambient_color;
|
||||
//FIXME should be ent->position
|
||||
float l = R_LightPoint (r_origin) / 128.0;
|
||||
float l = R_LightPoint (&r_worldentity.model->brush, r_origin) / 128.0;
|
||||
|
||||
//XXX l = max (light, max (ent->model->min_light, ent->min_light));
|
||||
light->type = 2;
|
||||
|
|
|
@ -153,7 +153,7 @@ add_texture (texture_t *tx, vulkan_ctx_t *ctx)
|
|||
}
|
||||
|
||||
static void
|
||||
init_surface_chains (model_t *model, vulkan_ctx_t *ctx)
|
||||
init_surface_chains (mod_brush_t *brush, vulkan_ctx_t *ctx)
|
||||
{
|
||||
bspctx_t *bctx = ctx->bsp_context;
|
||||
int i;
|
||||
|
@ -161,9 +161,9 @@ init_surface_chains (model_t *model, vulkan_ctx_t *ctx)
|
|||
release_static_instsurfs (bctx);
|
||||
release_instsurfs (bctx);
|
||||
|
||||
for (i = 0; i < model->nummodelsurfaces; i++) {
|
||||
model->surfaces[i].instsurf = get_static_instsurf (bctx);
|
||||
model->surfaces[i].instsurf->surface = &model->surfaces[i];
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++) {
|
||||
brush->surfaces[i].instsurf = get_static_instsurf (bctx);
|
||||
brush->surfaces[i].instsurf->surface = &brush->surfaces[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ Vulkan_ClearElements (vulkan_ctx_t *ctx)
|
|||
}
|
||||
|
||||
static void
|
||||
update_lightmap (msurface_t *surf, vulkan_ctx_t *ctx)
|
||||
update_lightmap (mod_brush_t *brush, msurface_t *surf, vulkan_ctx_t *ctx)
|
||||
{
|
||||
int maps;
|
||||
|
||||
|
@ -210,13 +210,13 @@ update_lightmap (msurface_t *surf, vulkan_ctx_t *ctx)
|
|||
if ((surf->dlightframe == r_framecount) || surf->cached_dlight) {
|
||||
dynamic:
|
||||
if (r_dynamic->int_val)
|
||||
Vulkan_BuildLightMap (surf, ctx);
|
||||
Vulkan_BuildLightMap (brush, surf, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
chain_surface (msurface_t *surf, vec_t *transform, float *color,
|
||||
vulkan_ctx_t *ctx)
|
||||
chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
||||
float *color, vulkan_ctx_t *ctx)
|
||||
{
|
||||
bspctx_t *bctx = ctx->bsp_context;
|
||||
instsurf_t *is;
|
||||
|
@ -236,7 +236,7 @@ chain_surface (msurface_t *surf, vec_t *transform, float *color,
|
|||
tex = tx->render;
|
||||
CHAIN_SURF_F2B (surf, tex->tex_chain);
|
||||
|
||||
update_lightmap (surf, ctx);
|
||||
update_lightmap (brush, surf, ctx);
|
||||
}
|
||||
if (!(is = surf->instsurf))
|
||||
is = surf->tinst;
|
||||
|
@ -245,13 +245,13 @@ chain_surface (msurface_t *surf, vec_t *transform, float *color,
|
|||
}
|
||||
|
||||
static void
|
||||
register_textures (model_t *model, vulkan_ctx_t *ctx)
|
||||
register_textures (mod_brush_t *brush, vulkan_ctx_t *ctx)
|
||||
{
|
||||
int i;
|
||||
texture_t *tex;
|
||||
|
||||
for (i = 0; i < model->numtextures; i++) {
|
||||
tex = model->textures[i];
|
||||
for (i = 0; i < brush->numtextures; i++) {
|
||||
tex = brush->textures[i];
|
||||
if (!tex)
|
||||
continue;
|
||||
add_texture (tex, ctx);
|
||||
|
@ -270,11 +270,12 @@ Vulkan_RegisterTextures (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
{
|
||||
int i;
|
||||
model_t *m;
|
||||
mod_brush_t *brush = &r_worldentity.model->brush;
|
||||
|
||||
clear_textures (ctx);
|
||||
init_surface_chains (r_worldentity.model, ctx);
|
||||
init_surface_chains (brush, ctx);
|
||||
add_texture (r_notexture_mip, ctx);
|
||||
register_textures (r_worldentity.model, ctx);
|
||||
register_textures (brush, ctx);
|
||||
for (i = 0; i < num_models; i++) {
|
||||
m = models[i];
|
||||
if (!m)
|
||||
|
@ -285,8 +286,9 @@ Vulkan_RegisterTextures (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
// world has already been done, not interested in non-brush models
|
||||
if (m == r_worldentity.model || m->type != mod_brush)
|
||||
continue;
|
||||
m->numsubmodels = 1; // no support for submodels in non-world model
|
||||
register_textures (m, ctx);
|
||||
brush = &m->brush;
|
||||
brush->numsubmodels = 1; // no support for submodels in non-world model
|
||||
register_textures (brush, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,18 +331,18 @@ build_surf_displist (model_t **models, msurface_t *fa, int base,
|
|||
bsppoly_t *poly;
|
||||
uint32_t *ind;
|
||||
float s, t;
|
||||
mod_brush_t *brush;
|
||||
|
||||
if (fa->ec_index < 0) {
|
||||
// instance model
|
||||
vertices = models[~fa->ec_index]->vertexes;
|
||||
edges = models[~fa->ec_index]->edges;
|
||||
surfedges = models[~fa->ec_index]->surfedges;
|
||||
brush = &models[~fa->ec_index]->brush;
|
||||
} else {
|
||||
// main or sub model
|
||||
vertices = r_worldentity.model->vertexes;
|
||||
edges = r_worldentity.model->edges;
|
||||
surfedges = r_worldentity.model->surfedges;
|
||||
brush = &r_worldentity.model->brush;
|
||||
}
|
||||
vertices = brush->vertexes;
|
||||
edges = brush->edges;
|
||||
surfedges = brush->surfedges;
|
||||
// create a triangle fan
|
||||
numverts = fa->numedges;
|
||||
numindices = numverts + 1;
|
||||
|
@ -405,6 +407,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
qfv_stagebuf_t *stage;
|
||||
bspvert_t *vertices;
|
||||
bsppoly_t *poly;
|
||||
mod_brush_t *brush;
|
||||
|
||||
QuatSet (0, 0, sqrt(0.5), sqrt(0.5), bctx->sky_fix); // proper skies
|
||||
QuatSet (0, 0, 0, 1, bctx->sky_rotation[0]);
|
||||
|
@ -421,24 +424,25 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
if (!m)
|
||||
continue;
|
||||
// sub-models are done as part of the main model
|
||||
if (*m->path == '*')
|
||||
if (*m->path == '*' || m->type != mod_brush)
|
||||
continue;
|
||||
brush = &m->brush;
|
||||
// non-bsp models don't have surfaces.
|
||||
dm = m->submodels;
|
||||
for (j = 0; j < m->numsurfaces; j++) {
|
||||
dm = brush->submodels;
|
||||
for (j = 0; j < brush->numsurfaces; j++) {
|
||||
vulktex_t *tex;
|
||||
if (j == dm->firstface + dm->numfaces) {
|
||||
dm++;
|
||||
if (dm - m->submodels == m->numsubmodels) {
|
||||
if (dm - brush->submodels == brush->numsubmodels) {
|
||||
// limit the surfaces
|
||||
// probably never hit
|
||||
Sys_Printf ("R_BuildDisplayLists: too many surfaces\n");
|
||||
m->numsurfaces = j;
|
||||
brush->numsurfaces = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
surf = m->surfaces + j;
|
||||
surf->ec_index = dm - m->submodels;
|
||||
surf = brush->surfaces + j;
|
||||
surf->ec_index = dm - brush->submodels;
|
||||
if (!surf->ec_index && m != r_worldentity.model)
|
||||
surf->ec_index = -1 - i; // instanced model
|
||||
tex = surf->texinfo->texture->render;
|
||||
|
@ -602,8 +606,10 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
|||
msurface_t *surf;
|
||||
qboolean rotated;
|
||||
vec3_t mins, maxs, org;
|
||||
mod_brush_t *brush;
|
||||
|
||||
model = e->model;
|
||||
brush = &model->brush;
|
||||
if (e->transform[0] != 1 || e->transform[5] != 1 || e->transform[10] != 1) {
|
||||
rotated = true;
|
||||
radius = model->radius;
|
||||
|
@ -628,7 +634,7 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
|||
}
|
||||
|
||||
// calculate dynamic lighting for bmodel if it's not an instanced model
|
||||
if (model->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
if (brush->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
|
@ -637,14 +643,14 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
|||
continue;
|
||||
|
||||
VectorSubtract (r_dlights[k].origin, e->origin, lightorigin);
|
||||
R_RecursiveMarkLights (lightorigin, &r_dlights[k], k,
|
||||
model->nodes + model->hulls[0].firstclipnode);
|
||||
R_RecursiveMarkLights (brush, lightorigin, &r_dlights[k], k,
|
||||
brush->nodes + brush->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
|
||||
surf = &model->surfaces[model->firstmodelsurface];
|
||||
surf = &brush->surfaces[brush->firstmodelsurface];
|
||||
|
||||
for (i = 0; i < model->nummodelsurfaces; i++, surf++) {
|
||||
for (i = 0; i < brush->nummodelsurfaces; i++, surf++) {
|
||||
// find the node side on which we are
|
||||
plane = surf->plane;
|
||||
|
||||
|
@ -653,7 +659,7 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
|||
// enqueue the polygon
|
||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON))
|
||||
|| (!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||
chain_surface (surf, e->transform, e->colormod, ctx);
|
||||
chain_surface (brush, surf, e->transform, e->colormod, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -678,7 +684,7 @@ get_side (mnode_t *node)
|
|||
}
|
||||
|
||||
static inline void
|
||||
visit_node (mnode_t *node, int side, vulkan_ctx_t *ctx)
|
||||
visit_node (mod_brush_t *brush, mnode_t *node, int side, vulkan_ctx_t *ctx)
|
||||
{
|
||||
int c;
|
||||
msurface_t *surf;
|
||||
|
@ -687,7 +693,7 @@ visit_node (mnode_t *node, int side, vulkan_ctx_t *ctx)
|
|||
side = (~side + 1) & SURF_PLANEBACK;
|
||||
// draw stuff
|
||||
if ((c = node->numsurfaces)) {
|
||||
surf = r_worldentity.model->surfaces + node->firstsurface;
|
||||
surf = brush->surfaces + node->firstsurface;
|
||||
for (; c; c--, surf++) {
|
||||
if (surf->visframe != r_visframecount)
|
||||
continue;
|
||||
|
@ -696,7 +702,7 @@ visit_node (mnode_t *node, int side, vulkan_ctx_t *ctx)
|
|||
if (side ^ (surf->flags & SURF_PLANEBACK))
|
||||
continue; // wrong side
|
||||
|
||||
chain_surface (surf, 0, 0, ctx);
|
||||
chain_surface (brush, surf, 0, 0, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -714,7 +720,7 @@ test_node (mnode_t *node)
|
|||
}
|
||||
|
||||
static void
|
||||
R_VisitWorldNodes (model_t *model, vulkan_ctx_t *ctx)
|
||||
R_VisitWorldNodes (mod_brush_t *brush, vulkan_ctx_t *ctx)
|
||||
{
|
||||
typedef struct {
|
||||
mnode_t *node;
|
||||
|
@ -726,9 +732,9 @@ R_VisitWorldNodes (model_t *model, vulkan_ctx_t *ctx)
|
|||
mnode_t *front;
|
||||
int side;
|
||||
|
||||
node = model->nodes;
|
||||
node = brush->nodes;
|
||||
// +2 for paranoia
|
||||
node_stack = alloca ((model->depth + 2) * sizeof (rstack_t));
|
||||
node_stack = alloca ((brush->depth + 2) * sizeof (rstack_t));
|
||||
node_ptr = node_stack;
|
||||
|
||||
while (1) {
|
||||
|
@ -744,7 +750,7 @@ R_VisitWorldNodes (model_t *model, vulkan_ctx_t *ctx)
|
|||
}
|
||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||
visit_leaf ((mleaf_t *) front);
|
||||
visit_node (node, side, ctx);
|
||||
visit_node (brush, node, side, ctx);
|
||||
node = node->children[!side];
|
||||
}
|
||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||
|
@ -753,7 +759,7 @@ R_VisitWorldNodes (model_t *model, vulkan_ctx_t *ctx)
|
|||
node_ptr--;
|
||||
node = node_ptr->node;
|
||||
side = node_ptr->side;
|
||||
visit_node (node, side, ctx);
|
||||
visit_node (brush, node, side, ctx);
|
||||
node = node->children[!side];
|
||||
continue;
|
||||
}
|
||||
|
@ -1099,19 +1105,21 @@ Vulkan_DrawWorld (vulkan_ctx_t *ctx)
|
|||
bspctx_t *bctx = ctx->bsp_context;
|
||||
bspframe_t *bframe = &bctx->frames.a[ctx->curFrame];
|
||||
entity_t worldent;
|
||||
mod_brush_t *brush;
|
||||
|
||||
clear_texture_chains (bctx); // do this first for water and skys
|
||||
bframe->index_count = 0;
|
||||
|
||||
memset (&worldent, 0, sizeof (worldent));
|
||||
worldent.model = r_worldentity.model;
|
||||
brush = &r_worldentity.model->brush;
|
||||
|
||||
//vulktex_t *tex = r_worldentity.model->skytexture->render;
|
||||
//bctx->skysheet_tex = tex->tex;
|
||||
|
||||
currententity = &worldent;
|
||||
|
||||
R_VisitWorldNodes (worldent.model, ctx);
|
||||
R_VisitWorldNodes (brush, ctx);
|
||||
if (r_drawentities->int_val) {
|
||||
entity_t *ent;
|
||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||
|
|
|
@ -125,7 +125,7 @@ add_dynamic_lights (msurface_t *surf, float *block)
|
|||
}
|
||||
|
||||
void
|
||||
Vulkan_BuildLightMap (msurface_t *surf, vulkan_ctx_t *ctx)
|
||||
Vulkan_BuildLightMap (mod_brush_t *brush, msurface_t *surf, vulkan_ctx_t *ctx)
|
||||
{
|
||||
bspctx_t *bctx = ctx->bsp_context;
|
||||
int smax, tmax, size;
|
||||
|
@ -142,7 +142,7 @@ Vulkan_BuildLightMap (msurface_t *surf, vulkan_ctx_t *ctx)
|
|||
block = QFV_SubpicBatch (surf->lightpic, bctx->light_stage);
|
||||
|
||||
// set to full bright if no light data
|
||||
if (!r_worldentity.model->lightdata) {
|
||||
if (!brush->lightdata) {
|
||||
out = block;
|
||||
while (size-- > 0) {
|
||||
*out++ = 1;
|
||||
|
@ -219,6 +219,7 @@ Vulkan_BuildLightmaps (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
bspctx_t *bctx = ctx->bsp_context;
|
||||
int i, j;
|
||||
model_t *m;
|
||||
mod_brush_t *brush;
|
||||
|
||||
QFV_ScrapClear (bctx->light_scrap);
|
||||
|
||||
|
@ -228,13 +229,14 @@ Vulkan_BuildLightmaps (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
m = models[j];
|
||||
if (!m)
|
||||
break;
|
||||
if (m->path[0] == '*') {
|
||||
if (m->path[0] == '*' || m->type != mod_brush) {
|
||||
// sub model surfaces are processed as part of the main model
|
||||
continue;
|
||||
}
|
||||
brush = &m->brush;
|
||||
// non-bsp models don't have surfaces.
|
||||
for (i = 0; i < m->numsurfaces; i++) {
|
||||
msurface_t *surf = m->surfaces + i;
|
||||
for (i = 0; i < brush->numsurfaces; i++) {
|
||||
msurface_t *surf = brush->surfaces + i;
|
||||
surf->lightpic = 0; // paranoia
|
||||
if (surf->flags & SURF_DRAWTURB) {
|
||||
continue;
|
||||
|
@ -251,15 +253,16 @@ Vulkan_BuildLightmaps (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
if (!m) {
|
||||
break;
|
||||
}
|
||||
if (m->path[0] == '*') {
|
||||
if (m->path[0] == '*' || m->type != mod_brush) {
|
||||
// sub model surfaces are processed as part of the main model
|
||||
continue;
|
||||
}
|
||||
brush = &m->brush;
|
||||
// non-bsp models don't have surfaces.
|
||||
for (i = 0; i < m->numsurfaces; i++) {
|
||||
msurface_t *surf = m->surfaces + i;
|
||||
for (i = 0; i < brush->numsurfaces; i++) {
|
||||
msurface_t *surf = brush->surfaces + i;
|
||||
if (surf->lightpic) {
|
||||
Vulkan_BuildLightMap (surf, ctx);
|
||||
Vulkan_BuildLightMap (brush, surf, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
|||
|
||||
memset (&trace, 0, sizeof (trace));
|
||||
trace.fraction = 1;
|
||||
MOD_TraceLine (cl.worldmodel->hulls, 0, start, end, &trace);
|
||||
MOD_TraceLine (cl.worldmodel->brush.hulls, 0, start, end, &trace);
|
||||
|
||||
VectorCopy (trace.endpos, impact);
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ CL_RelinkEntities (void)
|
|||
if (i != cl.viewentity || chase_active->int_val) {
|
||||
if (ent->efrag)
|
||||
r_funcs->R_RemoveEfrags (ent);
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
VectorCopy (ent->origin, ent->old_origin);
|
||||
} else {
|
||||
|
@ -416,10 +416,10 @@ CL_RelinkEntities (void)
|
|||
if (ent->efrag) {
|
||||
if (!VectorCompare (ent->origin, ent->old_origin)) {
|
||||
r_funcs->R_RemoveEfrags (ent);
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
} else {
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ map_ent (const char *mapname)
|
|||
edicts = ED_Parse (&edpr, buf);
|
||||
free (buf);
|
||||
} else {
|
||||
edicts = ED_Parse (&edpr, cl.model_precache[1]->entities);
|
||||
edicts = ED_Parse (&edpr, cl.model_precache[1]->brush.entities);
|
||||
}
|
||||
free (name);
|
||||
return edicts;
|
||||
|
@ -315,7 +315,7 @@ CL_NewMap (const char *mapname)
|
|||
Hunk_Check (); // make sure nothing is hurt
|
||||
Sbar_CenterPrint (0);
|
||||
|
||||
if (cl.model_precache[1] && cl.model_precache[1]->entities) {
|
||||
if (cl.model_precache[1] && cl.model_precache[1]->brush.entities) {
|
||||
cl.edicts = map_ent (mapname);
|
||||
if (cl.edicts) {
|
||||
cl.worldspawn = PL_ObjectAtIndex (cl.edicts, 0);
|
||||
|
@ -795,7 +795,7 @@ CL_ParseStatic (int version)
|
|||
VectorCopy (baseline.origin, ent->origin);
|
||||
CL_TransformEntity (ent, baseline.angles, true);
|
||||
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -294,7 +294,7 @@ beam_setup (beam_t *b, qboolean transform)
|
|||
CL_TransformEntity (&tent->ent, ang, true);
|
||||
}
|
||||
VectorCopy (ang, tent->ent.angles);
|
||||
r_funcs->R_AddEfrags (&tent->ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, &tent->ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ CL_UpdateExplosions (void)
|
|||
|
||||
ent->frame = f;
|
||||
if (!ent->efrag)
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -432,9 +432,9 @@ SV_AddToFatPVS (vec3_t org, mnode_t *node)
|
|||
static byte *
|
||||
SV_FatPVS (vec3_t org)
|
||||
{
|
||||
fatbytes = (sv.worldmodel->numleafs + 31) >> 3;
|
||||
fatbytes = (sv.worldmodel->brush.numleafs + 31) >> 3;
|
||||
memset (fatpvs, 0, fatbytes);
|
||||
SV_AddToFatPVS (org, sv.worldmodel->nodes);
|
||||
SV_AddToFatPVS (org, sv.worldmodel->brush.nodes);
|
||||
return fatpvs;
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ SV_SpawnServer (const char *server)
|
|||
|
||||
sv.model_precache[0] = sv_pr_state.pr_strings;
|
||||
sv.model_precache[1] = sv.modelname;
|
||||
for (i = 1; i < sv.worldmodel->numsubmodels; i++) {
|
||||
for (i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
|
||||
sv.model_precache[1 + i] = localmodels[i];
|
||||
sv.models[i + 1] = Mod_ForName (localmodels[i], false);
|
||||
}
|
||||
|
@ -1220,7 +1220,7 @@ SV_SpawnServer (const char *server)
|
|||
ED_LoadFromFile (&sv_pr_state, (char *) buf);
|
||||
free (buf);
|
||||
} else {
|
||||
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);
|
||||
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->brush.entities);
|
||||
}
|
||||
|
||||
sv.active = true;
|
||||
|
|
|
@ -585,7 +585,7 @@ PF_newcheckclient (progs_t *pr, int check)
|
|||
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
||||
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
||||
pvs = Mod_LeafPVS (leaf, sv.worldmodel);
|
||||
memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3);
|
||||
memcpy (checkpvs, pvs, (sv.worldmodel->brush.numleafs + 7) >> 3);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ PF_checkclient (progs_t *pr)
|
|||
self = PROG_TO_EDICT (pr, *sv_globals.self);
|
||||
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
||||
leaf = Mod_PointInLeaf (view, sv.worldmodel);
|
||||
l = (leaf - sv.worldmodel->leafs) - 1;
|
||||
l = (leaf - sv.worldmodel->brush.leafs) - 1;
|
||||
if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) {
|
||||
c_notvis++;
|
||||
RETURN_EDICT (pr, sv.edicts);
|
||||
|
|
|
@ -245,7 +245,7 @@ SV_HullForEntity (edict_t *ent, const vec3_t mins, const vec3_t maxs,
|
|||
PR_GetString (&sv_pr_state,
|
||||
SVstring (ent, classname)));
|
||||
|
||||
hull_list = model->hull_list;
|
||||
hull_list = model->brush.hull_list;
|
||||
}
|
||||
if (hull_list) {
|
||||
// decide which clipping hull to use, based on the size
|
||||
|
@ -425,7 +425,7 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node)
|
|||
leaf = (mleaf_t *) node;
|
||||
|
||||
edict_leaf = alloc_edict_leaf ();
|
||||
edict_leaf->leafnum = leaf - sv.worldmodel->leafs - 1;
|
||||
edict_leaf->leafnum = leaf - sv.worldmodel->brush.leafs - 1;
|
||||
edict_leaf->next = SVdata (ent)->leafs;
|
||||
SVdata (ent)->leafs = edict_leaf;
|
||||
return;
|
||||
|
@ -497,7 +497,7 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
|
|||
// link to PVS leafs
|
||||
free_edict_leafs (&SVdata (ent)->leafs);
|
||||
if (SVfloat (ent, modelindex))
|
||||
SV_FindTouchedLeafs (ent, sv.worldmodel->nodes);
|
||||
SV_FindTouchedLeafs (ent, sv.worldmodel->brush.nodes);
|
||||
|
||||
if (SVfloat (ent, solid) == SOLID_NOT)
|
||||
return;
|
||||
|
@ -560,7 +560,7 @@ SV_PointContents (const vec3_t p)
|
|||
{
|
||||
int cont;
|
||||
|
||||
cont = SV_HullPointContents (&sv.worldmodel->hulls[0], 0, p);
|
||||
cont = SV_HullPointContents (&sv.worldmodel->brush.hulls[0], 0, p);
|
||||
if (cont <= CONTENTS_CURRENT_0 && cont >= CONTENTS_CURRENT_DOWN)
|
||||
cont = CONTENTS_WATER;
|
||||
return cont;
|
||||
|
@ -569,7 +569,7 @@ SV_PointContents (const vec3_t p)
|
|||
int
|
||||
SV_TruePointContents (const vec3_t p)
|
||||
{
|
||||
return SV_HullPointContents (&sv.worldmodel->hulls[0], 0, p);
|
||||
return SV_HullPointContents (&sv.worldmodel->brush.hulls[0], 0, p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -903,7 +903,7 @@ SV_TestPlayerPosition (edict_t *ent, const vec3_t origin)
|
|||
vec3_t boxmins, boxmaxs, offset;
|
||||
|
||||
// check world first
|
||||
hull = &sv.worldmodel->hulls[1];
|
||||
hull = &sv.worldmodel->brush.hulls[1];
|
||||
if (SV_HullPointContents (hull, hull->firstclipnode, origin) !=
|
||||
CONTENTS_EMPTY) return sv.edicts;
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
|||
|
||||
memset (&trace, 0, sizeof (trace));
|
||||
trace.fraction = 1;
|
||||
MOD_TraceLine (cl.worldmodel->hulls, 0, start, end, &trace);
|
||||
MOD_TraceLine (cl.worldmodel->brush.hulls, 0, start, end, &trace);
|
||||
|
||||
VectorCopy (trace.endpos, impact);
|
||||
}
|
||||
|
|
|
@ -542,7 +542,7 @@ CL_SetSolidEntities (void)
|
|||
continue;
|
||||
if (!cl.model_precache[state->modelindex])
|
||||
continue;
|
||||
if (cl.model_precache[state->modelindex]->hulls[1].firstclipnode
|
||||
if (cl.model_precache[state->modelindex]->brush.hulls[1].firstclipnode
|
||||
|| cl.model_precache[state->modelindex]->clipbox) {
|
||||
if (pmove.numphysent == MAX_PHYSENTS) {
|
||||
Sys_Printf ("WARNING: entity physent overflow, email "
|
||||
|
|
|
@ -335,7 +335,7 @@ CL_LinkPacketEntities (void)
|
|||
if (i != cl.viewentity || chase_active->int_val) {
|
||||
if (ent->efrag)
|
||||
r_funcs->R_RemoveEfrags (ent);
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
VectorCopy (ent->origin, ent->old_origin);
|
||||
} else {
|
||||
|
@ -370,15 +370,15 @@ CL_LinkPacketEntities (void)
|
|||
if (ent->efrag) {
|
||||
if (!VectorCompare (ent->origin, ent->old_origin)) {
|
||||
r_funcs->R_RemoveEfrags (ent);
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
} else {
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ent->efrag)
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
|
||||
// rotate binary objects locally
|
||||
if (ent->model->flags & EF_ROTATE) {
|
||||
|
@ -567,7 +567,7 @@ CL_LinkPlayers (void)
|
|||
}
|
||||
|
||||
// stuff entity in map
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
|
||||
if (state->pls.effects & EF_FLAG1)
|
||||
CL_AddFlagModels (ent, 0, j);
|
||||
|
|
|
@ -288,7 +288,7 @@ map_ent (const char *mapname)
|
|||
edicts = ED_Parse (&edpr, buf);
|
||||
free (buf);
|
||||
} else {
|
||||
edicts = ED_Parse (&edpr, cl.model_precache[1]->entities);
|
||||
edicts = ED_Parse (&edpr, cl.model_precache[1]->brush.entities);
|
||||
}
|
||||
free (name);
|
||||
return edicts;
|
||||
|
@ -305,7 +305,7 @@ CL_NewMap (const char *mapname)
|
|||
Hunk_Check (); // make sure nothing is hurt
|
||||
Sbar_CenterPrint (0);
|
||||
|
||||
if (cl.model_precache[1] && cl.model_precache[1]->entities) {
|
||||
if (cl.model_precache[1] && cl.model_precache[1]->brush.entities) {
|
||||
cl.edicts = map_ent (mapname);
|
||||
if (cl.edicts) {
|
||||
cl.worldspawn = PL_ObjectAtIndex (cl.edicts, 0);
|
||||
|
@ -404,7 +404,7 @@ Model_NextDownload (void)
|
|||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message,
|
||||
va (0, prespawn_name, cl.servercount,
|
||||
cl.worldmodel->checksum2));
|
||||
cl.worldmodel->brush.checksum2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,7 +986,7 @@ CL_ParseStatic (void)
|
|||
VectorCopy (es.origin, ent->origin);
|
||||
CL_TransformEntity (ent, es.angles, true);
|
||||
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -298,7 +298,7 @@ beam_setup (beam_t *b, qboolean transform)
|
|||
CL_TransformEntity (&tent->ent, ang, true);
|
||||
}
|
||||
VectorCopy (ang, tent->ent.angles);
|
||||
r_funcs->R_AddEfrags (&tent->ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, &tent->ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,7 +595,7 @@ CL_UpdateExplosions (void)
|
|||
|
||||
ent->frame = f;
|
||||
if (!ent->efrag)
|
||||
r_funcs->R_AddEfrags (ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ CL_ParseProjectiles (qboolean nail2)
|
|||
pr->angles[2] = 0;
|
||||
CL_TransformEntity (&tent->ent, tent->ent.angles, true);
|
||||
|
||||
r_funcs->R_AddEfrags (&tent->ent);
|
||||
r_funcs->R_AddEfrags (&cl.worldmodel->brush, &tent->ent);
|
||||
}
|
||||
|
||||
*tail = cl_projectiles;
|
||||
|
|
|
@ -136,7 +136,7 @@ PM_PointContents (const vec3_t p)
|
|||
hull_t *hull;
|
||||
plane_t *plane;
|
||||
|
||||
hull = &pmove.physents[0].model->hulls[0];
|
||||
hull = &pmove.physents[0].model->brush.hulls[0];
|
||||
|
||||
num = hull->firstclipnode;
|
||||
|
||||
|
@ -174,7 +174,7 @@ PM_TestPlayerPosition (const vec3_t pos)
|
|||
pe = &pmove.physents[i];
|
||||
// get the clipping hull
|
||||
if (pe->model)
|
||||
hull = &pmove.physents[i].model->hulls[1];
|
||||
hull = &pmove.physents[i].model->brush.hulls[1];
|
||||
else {
|
||||
VectorSubtract (pe->mins, player_maxs, mins);
|
||||
VectorSubtract (pe->maxs, player_mins, maxs);
|
||||
|
@ -235,7 +235,7 @@ PM_PlayerMove (const vec3_t start, const vec3_t end)
|
|||
} else {
|
||||
check_box = 1;
|
||||
if (pe->model) {
|
||||
hull = &pe->model->hulls[1];
|
||||
hull = &pe->model->brush.hulls[1];
|
||||
VectorSubtract (pe->model->mins, player_maxs, mins);
|
||||
VectorSubtract (pe->model->maxs, player_mins, maxs);
|
||||
} else {
|
||||
|
|
|
@ -99,9 +99,9 @@ SV_AddToFatPVS (vec3_t org, mnode_t *node)
|
|||
static byte *
|
||||
SV_FatPVS (vec3_t org)
|
||||
{
|
||||
fatbytes = (sv.worldmodel->numleafs + 31) >> 3;
|
||||
fatbytes = (sv.worldmodel->brush.numleafs + 31) >> 3;
|
||||
memset (fatpvs, 0, fatbytes);
|
||||
SV_AddToFatPVS (org, sv.worldmodel->nodes);
|
||||
SV_AddToFatPVS (org, sv.worldmodel->brush.nodes);
|
||||
return fatpvs;
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ calc_pvs (delta_t *delta)
|
|||
if (pvs == NULL) {
|
||||
pvs = SV_FatPVS (org);
|
||||
} else {
|
||||
SV_AddToFatPVS (org, sv.worldmodel->nodes);
|
||||
SV_AddToFatPVS (org, sv.worldmodel->brush.nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ SV_CalcPHS (void)
|
|||
|
||||
SV_Printf ("Building PHS...\n");
|
||||
|
||||
num = sv.worldmodel->numleafs;
|
||||
num = sv.worldmodel->brush.numleafs;
|
||||
rowwords = (num + 31) >> 5;
|
||||
rowbytes = rowwords * 4;
|
||||
|
||||
|
@ -237,7 +237,8 @@ SV_CalcPHS (void)
|
|||
scan = sv.pvs;
|
||||
vcount = 0;
|
||||
for (i = 0; i < num; i++, scan += rowbytes) {
|
||||
memcpy (scan, Mod_LeafPVS (sv.worldmodel->leafs + i, sv.worldmodel),
|
||||
memcpy (scan, Mod_LeafPVS (sv.worldmodel->brush.leafs + i,
|
||||
sv.worldmodel),
|
||||
rowbytes);
|
||||
if (i == 0)
|
||||
continue;
|
||||
|
@ -402,7 +403,7 @@ SV_SpawnServer (const char *server)
|
|||
sv.model_precache[0] = sv_pr_state.pr_strings;
|
||||
sv.model_precache[1] = sv.modelname;
|
||||
sv.models[1] = sv.worldmodel;
|
||||
for (i = 1; i < sv.worldmodel->numsubmodels; i++) {
|
||||
for (i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
|
||||
sv.model_precache[1 + i] = localmodels[i];
|
||||
sv.models[i + 1] = Mod_ForName (localmodels[i], false);
|
||||
}
|
||||
|
@ -443,7 +444,7 @@ SV_SpawnServer (const char *server)
|
|||
ED_LoadFromFile (&sv_pr_state, (char *) buf);
|
||||
free (buf);
|
||||
} else {
|
||||
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);
|
||||
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->brush.entities);
|
||||
}
|
||||
|
||||
// look up some model indexes for specialized message compression
|
||||
|
|
|
@ -506,7 +506,7 @@ PF_newcheckclient (progs_t *pr, int check)
|
|||
VectorAdd (SVvector (ent, origin), SVvector (ent, view_ofs), org);
|
||||
leaf = Mod_PointInLeaf (org, sv.worldmodel);
|
||||
pvs = Mod_LeafPVS (leaf, sv.worldmodel);
|
||||
memcpy (checkpvs, pvs, (sv.worldmodel->numleafs + 7) >> 3);
|
||||
memcpy (checkpvs, pvs, (sv.worldmodel->brush.numleafs + 7) >> 3);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ PF_checkclient (progs_t *pr)
|
|||
self = PROG_TO_EDICT (pr, *sv_globals.self);
|
||||
VectorAdd (SVvector (self, origin), SVvector (self, view_ofs), view);
|
||||
leaf = Mod_PointInLeaf (view, sv.worldmodel);
|
||||
l = (leaf - sv.worldmodel->leafs) - 1;
|
||||
l = (leaf - sv.worldmodel->brush.leafs) - 1;
|
||||
if ((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) {
|
||||
c_notvis++;
|
||||
RETURN_EDICT (pr, sv.edicts);
|
||||
|
|
|
@ -297,12 +297,13 @@ SV_Multicast (const vec3_t origin, int to)
|
|||
int leafnum, j;
|
||||
mleaf_t *leaf;
|
||||
qboolean reliable;
|
||||
mod_brush_t *brush = &sv.worldmodel->brush;
|
||||
|
||||
leaf = Mod_PointInLeaf (origin, sv.worldmodel);
|
||||
if (!leaf)
|
||||
leafnum = 0;
|
||||
else
|
||||
leafnum = leaf - sv.worldmodel->leafs;
|
||||
leafnum = leaf - sv.worldmodel->brush.leafs;
|
||||
|
||||
reliable = false;
|
||||
|
||||
|
@ -316,13 +317,13 @@ SV_Multicast (const vec3_t origin, int to)
|
|||
case MULTICAST_PHS_R:
|
||||
reliable = true; // intentional fallthrough
|
||||
case MULTICAST_PHS:
|
||||
mask = sv.phs + leafnum * 4 * ((sv.worldmodel->numleafs + 31) >> 5);
|
||||
mask = sv.phs + leafnum * 4 * ((brush->numleafs + 31) >> 5);
|
||||
break;
|
||||
|
||||
case MULTICAST_PVS_R:
|
||||
reliable = true; // intentional fallthrough
|
||||
case MULTICAST_PVS:
|
||||
mask = sv.pvs + leafnum * 4 * ((sv.worldmodel->numleafs + 31) >> 5);
|
||||
mask = sv.pvs + leafnum * 4 * ((brush->numleafs + 31) >> 5);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -347,7 +348,7 @@ SV_Multicast (const vec3_t origin, int to)
|
|||
sv.worldmodel);
|
||||
if (leaf) {
|
||||
// -1 is because pvs rows are 1 based, not 0 based like leafs
|
||||
leafnum = leaf - sv.worldmodel->leafs - 1;
|
||||
leafnum = leaf - brush->leafs - 1;
|
||||
if (!(mask[leafnum >> 3] & (1 << (leafnum & 7)))) {
|
||||
// SV_Printf ("supressed multicast\n");
|
||||
continue;
|
||||
|
|
|
@ -335,14 +335,15 @@ SV_PreSpawn_f (void *unused)
|
|||
|
||||
// Sys_MaskPrintf (SYS_DEV, , "Client check = %d\n", check);
|
||||
|
||||
if (sv_mapcheck->int_val && check != sv.worldmodel->checksum &&
|
||||
check != sv.worldmodel->checksum2) {
|
||||
if (sv_mapcheck->int_val && check != sv.worldmodel->brush.checksum &&
|
||||
check != sv.worldmodel->brush.checksum2) {
|
||||
SV_ClientPrintf (1, host_client, PRINT_HIGH, "Map model file does "
|
||||
"not match (%s), %i != %i/%i.\n"
|
||||
"You may need a new version of the map, or the "
|
||||
"proper install files.\n",
|
||||
sv.modelname, check, sv.worldmodel->checksum,
|
||||
sv.worldmodel->checksum2);
|
||||
sv.modelname, check,
|
||||
sv.worldmodel->brush.checksum,
|
||||
sv.worldmodel->brush.checksum2);
|
||||
SV_DropClient (host_client);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ SV_HullForEntity (edict_t *ent, const vec3_t mins, const vec3_t maxs,
|
|||
PR_GetString (&sv_pr_state,
|
||||
SVstring (ent, classname)));
|
||||
|
||||
hull_list = model->hull_list;
|
||||
hull_list = model->brush.hull_list;
|
||||
}
|
||||
if (hull_list) {
|
||||
// decide which clipping hull to use, based on the size
|
||||
|
@ -425,7 +425,7 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node)
|
|||
leaf = (mleaf_t *) node;
|
||||
|
||||
edict_leaf = alloc_edict_leaf ();
|
||||
edict_leaf->leafnum = leaf - sv.worldmodel->leafs - 1;
|
||||
edict_leaf->leafnum = leaf - sv.worldmodel->brush.leafs - 1;
|
||||
edict_leaf->next = SVdata (ent)->leafs;
|
||||
SVdata (ent)->leafs = edict_leaf;
|
||||
return;
|
||||
|
@ -497,7 +497,7 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
|
|||
// link to PVS leafs
|
||||
free_edict_leafs (&SVdata (ent)->leafs);
|
||||
if (SVfloat (ent, modelindex))
|
||||
SV_FindTouchedLeafs (ent, sv.worldmodel->nodes);
|
||||
SV_FindTouchedLeafs (ent, sv.worldmodel->brush.nodes);
|
||||
|
||||
if (SVfloat (ent, solid) == SOLID_NOT)
|
||||
return;
|
||||
|
@ -560,7 +560,7 @@ SV_PointContents (const vec3_t p)
|
|||
{
|
||||
int cont;
|
||||
|
||||
cont = SV_HullPointContents (&sv.worldmodel->hulls[0], 0, p);
|
||||
cont = SV_HullPointContents (&sv.worldmodel->brush.hulls[0], 0, p);
|
||||
if (cont <= CONTENTS_CURRENT_0 && cont >= CONTENTS_CURRENT_DOWN)
|
||||
cont = CONTENTS_WATER;
|
||||
return cont;
|
||||
|
@ -569,7 +569,7 @@ SV_PointContents (const vec3_t p)
|
|||
int
|
||||
SV_TruePointContents (const vec3_t p)
|
||||
{
|
||||
return SV_HullPointContents (&sv.worldmodel->hulls[0], 0, p);
|
||||
return SV_HullPointContents (&sv.worldmodel->brush.hulls[0], 0, p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -991,7 +991,7 @@ SV_TestPlayerPosition (edict_t *ent, const vec3_t origin)
|
|||
vec3_t boxmins, boxmaxs, offset;
|
||||
|
||||
// check world first
|
||||
hull = &sv.worldmodel->hulls[1];
|
||||
hull = &sv.worldmodel->brush.hulls[1];
|
||||
if (SV_HullPointContents (hull, hull->firstclipnode, origin) !=
|
||||
CONTENTS_EMPTY) return sv.edicts;
|
||||
|
||||
|
|
Loading…
Reference in a new issue