[renderer] move r_worldentity and r_viewleaf into refdef

More cleanup of globals that seem to be quake specific.
This commit is contained in:
Bill Currie 2022-03-14 15:27:43 +09:00
parent 2641fe3241
commit 7402fcfd0c
22 changed files with 78 additions and 73 deletions

View file

@ -219,6 +219,9 @@ typedef struct {
int drawflat; int drawflat;
float fov_x, fov_y; float fov_x, fov_y;
struct model_s *worldmodel;
struct mleaf_s *viewleaf;
} refdef_t; } refdef_t;
// color shifts ============================================================= // color shifts =============================================================
@ -240,8 +243,6 @@ typedef struct {
extern struct texture_s *r_notexture_mip; extern struct texture_s *r_notexture_mip;
extern entity_t r_worldentity;
void R_Init (void); void R_Init (void);
struct vid_internal_s; struct vid_internal_s;
void R_LoadModule (struct vid_internal_s *vid_internal); void R_LoadModule (struct vid_internal_s *vid_internal);

View file

@ -286,8 +286,6 @@ extern int r_frustum_indexes[4*6];
extern int r_maxsurfsseen, r_maxedgesseen; extern int r_maxsurfsseen, r_maxedgesseen;
extern qboolean r_dowarpold, r_viewchanged; extern qboolean r_dowarpold, r_viewchanged;
extern mleaf_t *r_viewleaf;
extern int r_clipflags; extern int r_clipflags;
extern int r_dlightframecount; extern int r_dlightframecount;

View file

@ -598,7 +598,7 @@ gl_overbright_f (cvar_t *var)
} }
} }
brush = &r_worldentity.renderer.model->brush; brush = &r_refdef.worldmodel->brush;
for (unsigned i = 0; i < brush->numsurfaces; i++) { for (unsigned i = 0; i < brush->numsurfaces; i++) {
msurface_t *surf = brush->surfaces + i; msurface_t *surf = brush->surfaces + i;

View file

@ -449,7 +449,7 @@ gl_R_DrawAliasModel (entity_t *e)
float lightadj; float lightadj;
// get lighting information // get lighting information
R_LightPoint (&r_worldentity.renderer.model->brush, &origin[0]);//FIXME R_LightPoint (&r_refdef.worldmodel->brush, &origin[0]);//FIXME
lightadj = (ambientcolor[0] + ambientcolor[1] + ambientcolor[2]) / 765.0; lightadj = (ambientcolor[0] + ambientcolor[1] + ambientcolor[2]) / 765.0;

View file

@ -332,7 +332,7 @@ gl_R_SetupFrame (void)
R_SetFrustum (); R_SetFrustum ();
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model); r_refdef.viewleaf = Mod_PointInLeaf (&position[0], r_refdef.worldmodel);
} }
static void static void
@ -456,7 +456,7 @@ R_RenderView_ (void)
if (r_norefresh->int_val) { if (r_norefresh->int_val) {
return; return;
} }
if (!r_worldentity.renderer.model) { if (!r_refdef.worldmodel) {
return; return;
} }
@ -784,7 +784,7 @@ R_RenderViewFishEye (void)
void void
gl_R_ClearState (void) gl_R_ClearState (void)
{ {
r_worldentity.renderer.model = 0; r_refdef.worldmodel = 0;
R_ClearEfrags (); R_ClearEfrags ();
R_ClearDlights (); R_ClearDlights ();
R_ClearParticles (); R_ClearParticles ();

View file

@ -219,8 +219,7 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
d_lightstylevalue[i] = 264; // normal light value d_lightstylevalue[i] = 264; // normal light value
memset (&r_worldentity, 0, sizeof (r_worldentity)); r_refdef.worldmodel = worldmodel;
r_worldentity.renderer.model = worldmodel;
brush = &worldmodel->brush; brush = &worldmodel->brush;
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
@ -228,7 +227,7 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
brush->leafs[i].efrags = NULL; brush->leafs[i].efrags = NULL;
// Force a vis update // Force a vis update
r_viewleaf = NULL; r_refdef.viewleaf = NULL;
R_MarkLeaves (); R_MarkLeaves ();
R_ClearParticles (); R_ClearParticles ();
@ -257,7 +256,7 @@ gl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
continue; continue;
if (*models[i]->path == '*') if (*models[i]->path == '*')
continue; continue;
if (models[i] != r_worldentity.renderer.model if (models[i] != r_refdef.worldmodel
&& models[i]->type == mod_brush) && models[i]->type == mod_brush)
register_textures (&models[i]->brush); register_textures (&models[i]->brush);
} }

View file

@ -723,7 +723,7 @@ gl_R_DrawWorld (void)
glbspctx_t bctx = { }; glbspctx_t bctx = { };
memset (&worldent, 0, sizeof (worldent)); memset (&worldent, 0, sizeof (worldent));
worldent.renderer.model = r_worldentity.renderer.model; worldent.renderer.model = r_refdef.worldmodel;
sky_chain = 0; sky_chain = 0;
sky_chain_tail = &sky_chain; sky_chain_tail = &sky_chain;
@ -732,7 +732,7 @@ gl_R_DrawWorld (void)
} }
bctx.brush = &worldent.renderer.model->brush; bctx.brush = &worldent.renderer.model->brush;
bctx.entity = &r_worldentity; bctx.entity = &worldent;
R_VisitWorldNodes (&bctx); R_VisitWorldNodes (&bctx);

View file

@ -161,7 +161,7 @@ calc_lighting (entity_t *ent, float *ambient, float *shadelight,
entorigin = Transform_GetWorldPosition (ent->transform); entorigin = Transform_GetWorldPosition (ent->transform);
VectorSet ( -1, 0, 0, lightvec); //FIXME VectorSet ( -1, 0, 0, lightvec); //FIXME
light = R_LightPoint (&r_worldentity.renderer.model->brush, &entorigin[0]); light = R_LightPoint (&r_refdef.worldmodel->brush, &entorigin[0]);
*ambient = max (light, max (ent->renderer.model->min_light, *ambient = max (light, max (ent->renderer.model->min_light,
ent->renderer.min_light) * 128); ent->renderer.min_light) * 128);
*shadelight = *ambient; *shadelight = *ambient;

View file

@ -433,9 +433,9 @@ glsl_R_RegisterTextures (model_t **models, int num_models)
mod_brush_t *brush; mod_brush_t *brush;
glsl_R_ClearTextures (); glsl_R_ClearTextures ();
glsl_R_InitSurfaceChains (&r_worldentity.renderer.model->brush); glsl_R_InitSurfaceChains (&r_refdef.worldmodel->brush);
glsl_R_AddTexture (r_notexture_mip); glsl_R_AddTexture (r_notexture_mip);
register_textures (&r_worldentity.renderer.model->brush); register_textures (&r_refdef.worldmodel->brush);
for (i = 0; i < num_models; i++) { for (i = 0; i < num_models; i++) {
m = models[i]; m = models[i];
if (!m) if (!m)
@ -444,7 +444,7 @@ glsl_R_RegisterTextures (model_t **models, int num_models)
if (*m->path == '*') if (*m->path == '*')
continue; continue;
// world has already been done, not interested in non-brush models // world has already been done, not interested in non-brush models
if (m == r_worldentity.renderer.model || m->type != mod_brush) if (m == r_refdef.worldmodel || m->type != mod_brush)
continue; continue;
brush = &m->brush; brush = &m->brush;
brush->numsubmodels = 1; // no support for submodels in non-world model brush->numsubmodels = 1; // no support for submodels in non-world model
@ -489,7 +489,7 @@ build_surf_displist (model_t **models, msurface_t *surf, int base,
if (surf->model_index < 0) { if (surf->model_index < 0) {
brush = &models[-surf->model_index - 1]->brush; brush = &models[-surf->model_index - 1]->brush;
} else { } else {
brush = &r_worldentity.renderer.model->brush; brush = &r_refdef.worldmodel->brush;
} }
vertices = brush->vertexes; vertices = brush->vertexes;
edges = brush->edges; edges = brush->edges;
@ -588,7 +588,7 @@ glsl_R_BuildDisplayLists (model_t **models, int num_models)
} }
surf = brush->surfaces + j; surf = brush->surfaces + j;
surf->model_index = dm - brush->submodels; surf->model_index = dm - brush->submodels;
if (!surf->model_index && m != r_worldentity.renderer.model) if (!surf->model_index && m != r_refdef.worldmodel)
surf->model_index = -1 - i; // instanced model surf->model_index = -1 - i; // instanced model
tex = surf->texinfo->texture->render; tex = surf->texinfo->texture->render;
CHAIN_SURF_F2B (surf, tex->tex_chain); CHAIN_SURF_F2B (surf, tex->tex_chain);
@ -1140,10 +1140,10 @@ glsl_R_DrawWorld (void)
clear_texture_chains (); // do this first for water and skys clear_texture_chains (); // do this first for water and skys
memset (&worldent, 0, sizeof (worldent)); memset (&worldent, 0, sizeof (worldent));
worldent.renderer.model = r_worldentity.renderer.model; worldent.renderer.model = r_refdef.worldmodel;
bctx.brush = &worldent.renderer.model->brush; bctx.brush = &worldent.renderer.model->brush;
bctx.entity = &r_worldentity; bctx.entity = &worldent;
R_VisitWorldNodes (&bctx); R_VisitWorldNodes (&bctx);
if (r_drawentities->int_val) { if (r_drawentities->int_val) {

View file

@ -225,7 +225,7 @@ glsl_R_DrawIQM (entity_t *ent)
entorigin = mat[3]; entorigin = mat[3];
mmulf (mvp_mat, iqm_vp, mat); mmulf (mvp_mat, iqm_vp, mat);
R_LightPoint (&r_worldentity.renderer.model->brush, &entorigin[0]);//FIXME min_light? R_LightPoint (&r_refdef.worldmodel->brush, &entorigin[0]);//FIXME min_light?
VectorScale (ambientcolor, 1/255.0, ambientcolor); VectorScale (ambientcolor, 1/255.0, ambientcolor);
R_FindNearLights (&entorigin[0], MAX_IQM_LIGHTS, lights);//FIXME R_FindNearLights (&entorigin[0], MAX_IQM_LIGHTS, lights);//FIXME

View file

@ -104,7 +104,7 @@ glsl_R_SetupFrame (void)
R_SetFrustum (); R_SetFrustum ();
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model); r_refdef.viewleaf = Mod_PointInLeaf (&position[0], r_refdef.worldmodel);
} }
static void static void
@ -182,7 +182,7 @@ glsl_R_RenderView (void)
double t[10] = {}; double t[10] = {};
int speeds = r_speeds->int_val; int speeds = r_speeds->int_val;
if (!r_worldentity.renderer.model) { if (!r_refdef.worldmodel) {
return; return;
} }
@ -275,11 +275,10 @@ glsl_R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
d_lightstylevalue[i] = 264; // normal light value d_lightstylevalue[i] = 264; // normal light value
memset (&r_worldentity, 0, sizeof (r_worldentity)); r_refdef.worldmodel = worldmodel;
r_worldentity.renderer.model = worldmodel;
// Force a vis update // Force a vis update
r_viewleaf = NULL; r_refdef.viewleaf = NULL;
R_MarkLeaves (); R_MarkLeaves ();
R_ClearParticles (); R_ClearParticles ();
@ -296,7 +295,7 @@ glsl_R_LineGraph (int x, int y, int *h_vals, int count, int height)
void void
glsl_R_ClearState (void) glsl_R_ClearState (void)
{ {
r_worldentity.renderer.model = 0; r_refdef.worldmodel = 0;
R_ClearEfrags (); R_ClearEfrags ();
R_ClearDlights (); R_ClearDlights ();
R_ClearParticles (); R_ClearParticles ();

View file

@ -42,7 +42,6 @@
#include "r_internal.h" #include "r_internal.h"
mvertex_t *r_pcurrentvertbase; mvertex_t *r_pcurrentvertbase;
mleaf_t *r_viewleaf;
static mleaf_t *r_oldviewleaf; static mleaf_t *r_oldviewleaf;
static set_t *solid; static set_t *solid;
@ -54,14 +53,14 @@ R_MarkLeaves (void)
mleaf_t *leaf; mleaf_t *leaf;
mnode_t *node; mnode_t *node;
msurface_t **mark; msurface_t **mark;
mod_brush_t *brush = &r_worldentity.renderer.model->brush; mod_brush_t *brush = &r_refdef.worldmodel->brush;
if (r_oldviewleaf == r_viewleaf && !r_novis->int_val) if (r_oldviewleaf == r_refdef.viewleaf && !r_novis->int_val)
return; return;
r_visframecount++; r_visframecount++;
r_oldviewleaf = r_viewleaf; r_oldviewleaf = r_refdef.viewleaf;
if (!r_viewleaf) if (!r_refdef.viewleaf)
return; return;
if (r_novis->int_val) { if (r_novis->int_val) {
@ -73,7 +72,7 @@ R_MarkLeaves (void)
} }
vis = solid; vis = solid;
} else } else
vis = Mod_LeafPVS (r_viewleaf, r_worldentity.renderer.model); vis = Mod_LeafPVS (r_refdef.viewleaf, r_refdef.worldmodel);
for (unsigned i = 0; i < brush->visleafs; i++) { for (unsigned i = 0; i < brush->visleafs; i++) {
if (set_is_member (vis, i)) { if (set_is_member (vis, i)) {

View file

@ -326,7 +326,7 @@ R_PushDlights (const vec3_t entorigin)
if (l->die < r_data->realtime || !l->radius) if (l->die < r_data->realtime || !l->radius)
continue; continue;
VectorSubtract (l->origin, entorigin, lightorigin); VectorSubtract (l->origin, entorigin, lightorigin);
R_MarkLights (lightorigin, l, i, r_worldentity.renderer.model); R_MarkLights (lightorigin, l, i, r_refdef.worldmodel);
} }
} }

View file

@ -65,8 +65,6 @@ vec3_t modelorg; // modelorg is the viewpoint relative to
vec3_t base_modelorg; vec3_t base_modelorg;
vec3_t r_entorigin; // the currently rendering entity in world vec3_t r_entorigin; // the currently rendering entity in world
// coordinates // coordinates
entity_t r_worldentity;
// screen size info // screen size info
refdef_t r_refdef; refdef_t r_refdef;

View file

@ -40,6 +40,11 @@
#include "r_internal.h" #include "r_internal.h"
typedef struct glbspctx_s {
mod_brush_t *brush;
entity_t *entity;
} swbspctx_t;
// current entity info // current entity info
qboolean insubmodel; qboolean insubmodel;
vec3_t r_worldmodelorg; vec3_t r_worldmodelorg;
@ -368,11 +373,12 @@ get_side (mnode_t *node)
} }
static void static void
visit_node (mod_brush_t *brush, mnode_t *node, int side, int clipflags) visit_node (swbspctx_t *bctx, mnode_t *node, int side, int clipflags)
{ {
int c; int c;
msurface_t *surf; msurface_t *surf;
entity_t *ent = &r_worldentity; entity_t *ent = bctx->entity;
mod_brush_t *brush = &ent->renderer.model->brush;
// sneaky hack for side = side ? SURF_PLANEBACK : 0; // sneaky hack for side = side ? SURF_PLANEBACK : 0;
side = (~side + 1) & SURF_PLANEBACK; side = (~side + 1) & SURF_PLANEBACK;
@ -455,7 +461,7 @@ test_node (mnode_t *node, int *clipflags)
} }
static void static void
R_VisitWorldNodes (mod_brush_t *brush, int clipflags) R_VisitWorldNodes (swbspctx_t *bctx, int clipflags)
{ {
typedef struct { typedef struct {
mnode_t *node; mnode_t *node;
@ -466,6 +472,7 @@ R_VisitWorldNodes (mod_brush_t *brush, int clipflags)
mnode_t *node; mnode_t *node;
mnode_t *front; mnode_t *front;
int side, cf; int side, cf;
mod_brush_t *brush = &bctx->entity->renderer.model->brush;
node = brush->nodes; node = brush->nodes;
// +2 for paranoia // +2 for paranoia
@ -489,7 +496,7 @@ R_VisitWorldNodes (mod_brush_t *brush, int clipflags)
} }
if (front->contents < 0 && front->contents != CONTENTS_SOLID) if (front->contents < 0 && front->contents != CONTENTS_SOLID)
visit_leaf ((mleaf_t *) front); visit_leaf ((mleaf_t *) front);
visit_node (brush, node, side, clipflags); visit_node (bctx, node, side, clipflags);
node = node->children[!side]; node = node->children[!side];
} }
if (node->contents < 0 && node->contents != CONTENTS_SOLID) if (node->contents < 0 && node->contents != CONTENTS_SOLID)
@ -499,7 +506,7 @@ R_VisitWorldNodes (mod_brush_t *brush, int clipflags)
node = node_ptr->node; node = node_ptr->node;
side = node_ptr->side; side = node_ptr->side;
clipflags = node_ptr->clipflags; clipflags = node_ptr->clipflags;
visit_node (brush, node, side, clipflags); visit_node (bctx, node, side, clipflags);
node = node->children[!side]; node = node->children[!side];
continue; continue;
} }
@ -514,15 +521,21 @@ R_RenderWorld (void)
{ {
int i; int i;
btofpoly_t btofpolys[MAX_BTOFPOLYS]; btofpoly_t btofpolys[MAX_BTOFPOLYS];
mod_brush_t *brush; entity_t worldent = {};
entity_t *ent = &r_worldentity; entity_t *ent = &worldent;
mod_brush_t *brush = &r_refdef.worldmodel->brush;
swbspctx_t bspctx = {
brush,
ent,
};
worldent.renderer.model = r_refdef.worldmodel;
pbtofpolys = btofpolys; pbtofpolys = btofpolys;
brush = &r_worldentity.renderer.model->brush; brush = &r_refdef.worldmodel->brush;
r_pcurrentvertbase = brush->vertexes; r_pcurrentvertbase = brush->vertexes;
R_VisitWorldNodes (brush, 15); R_VisitWorldNodes (&bspctx, 15);
// if the driver wants the polygons back to front, play the visible ones // if the driver wants the polygons back to front, play the visible ones
// back in that order // back in that order

View file

@ -171,8 +171,7 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
{ {
mod_brush_t *brush = &worldmodel->brush; mod_brush_t *brush = &worldmodel->brush;
memset (&r_worldentity, 0, sizeof (r_worldentity)); r_refdef.worldmodel = worldmodel;
r_worldentity.renderer.model = worldmodel;
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
for (unsigned i = 0; i < brush->modleafs; i++) for (unsigned i = 0; i < brush->modleafs; i++)
@ -182,7 +181,7 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
R_InitSky (brush->skytexture); R_InitSky (brush->skytexture);
// Force a vis update // Force a vis update
r_viewleaf = NULL; r_refdef.viewleaf = NULL;
R_MarkLeaves (); R_MarkLeaves ();
R_ClearParticles (); R_ClearParticles ();
@ -364,7 +363,7 @@ setup_lighting (entity_t *ent, alight_t *lighting)
minlight = max (ent->renderer.model->min_light, ent->renderer.min_light); minlight = max (ent->renderer.model->min_light, ent->renderer.min_light);
// 128 instead of 255 due to clamping below // 128 instead of 255 due to clamping below
j = max (R_LightPoint (&r_worldentity.renderer.model->brush, r_entorigin), j = max (R_LightPoint (&r_refdef.worldmodel->brush, r_entorigin),
minlight * 128); minlight * 128);
lighting->ambientlight = j; lighting->ambientlight = j;
@ -466,7 +465,7 @@ R_DrawViewModel (void)
minlight = max (viewent->renderer.min_light, minlight = max (viewent->renderer.min_light,
viewent->renderer.model->min_light); viewent->renderer.model->min_light);
j = max (R_LightPoint (&r_worldentity.renderer.model->brush, j = max (R_LightPoint (&r_refdef.worldmodel->brush,
r_entorigin), minlight * 128); r_entorigin), minlight * 128);
r_viewlighting.ambientlight = j; r_viewlighting.ambientlight = j;
@ -741,7 +740,7 @@ R_RenderView_ (void)
if (r_norefresh->int_val) if (r_norefresh->int_val)
return; return;
if (!r_worldentity.renderer.model) { if (!r_refdef.worldmodel) {
return; return;
} }
@ -1153,7 +1152,7 @@ R_RenderViewFishEye (void)
void void
R_ClearState (void) R_ClearState (void)
{ {
r_worldentity.renderer.model = 0; r_refdef.worldmodel = 0;
R_ClearEfrags (); R_ClearEfrags ();
R_ClearDlights (); R_ClearDlights ();
R_ClearParticles (); R_ClearParticles ();

View file

@ -192,10 +192,10 @@ R_SetupFrame (void)
R_SetFrustum (); R_SetFrustum ();
// current viewleaf // current viewleaf
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model); r_refdef.viewleaf = Mod_PointInLeaf (&position[0], r_refdef.worldmodel);
r_dowarpold = r_dowarp; r_dowarpold = r_dowarp;
r_dowarp = r_waterwarp->int_val && (r_viewleaf->contents <= r_dowarp = r_waterwarp->int_val && (r_refdef.viewleaf->contents <=
CONTENTS_WATER); CONTENTS_WATER);
if ((r_dowarp != r_dowarpold) || r_viewchanged) { if ((r_dowarp != r_dowarpold) || r_viewchanged) {

View file

@ -161,7 +161,7 @@ R_BuildLightMap (transform_t *transform)
size = smax * tmax; size = smax * tmax;
lightmap = surf->samples; lightmap = surf->samples;
if (!r_worldentity.renderer.model->brush.lightdata) { if (!r_refdef.worldmodel->brush.lightdata) {
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
blocklights[i] = 0; blocklights[i] = 0;
return; return;

View file

@ -104,7 +104,7 @@ vulkan_R_Init (void)
static void static void
vulkan_R_ClearState (void) vulkan_R_ClearState (void)
{ {
r_worldentity.renderer.model = 0; r_refdef.worldmodel = 0;
R_ClearEfrags (); R_ClearEfrags ();
R_ClearDlights (); R_ClearDlights ();
R_ClearParticles (); R_ClearParticles ();

View file

@ -275,7 +275,7 @@ Vulkan_RegisterTextures (model_t **models, int num_models, vulkan_ctx_t *ctx)
{ {
int i; int i;
model_t *m; model_t *m;
mod_brush_t *brush = &r_worldentity.renderer.model->brush; mod_brush_t *brush = &r_refdef.worldmodel->brush;
clear_textures (ctx); clear_textures (ctx);
init_surface_chains (brush, ctx); init_surface_chains (brush, ctx);
@ -289,7 +289,7 @@ Vulkan_RegisterTextures (model_t **models, int num_models, vulkan_ctx_t *ctx)
if (*m->path == '*') if (*m->path == '*')
continue; continue;
// world has already been done, not interested in non-brush models // world has already been done, not interested in non-brush models
if (m == r_worldentity.renderer.model || m->type != mod_brush) if (m == r_refdef.worldmodel || m->type != mod_brush)
continue; continue;
brush = &m->brush; brush = &m->brush;
brush->numsubmodels = 1; // no support for submodels in non-world model brush->numsubmodels = 1; // no support for submodels in non-world model
@ -342,7 +342,7 @@ build_surf_displist (model_t **models, msurface_t *surf, int base,
brush = &models[~surf->model_index]->brush; brush = &models[~surf->model_index]->brush;
} else { } else {
// main or sub model // main or sub model
brush = &r_worldentity.renderer.model->brush; brush = &r_refdef.worldmodel->brush;
} }
vertices = brush->vertexes; vertices = brush->vertexes;
edges = brush->edges; edges = brush->edges;
@ -441,7 +441,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
} }
surf = brush->surfaces + j; surf = brush->surfaces + j;
surf->model_index = dm - brush->submodels; surf->model_index = dm - brush->submodels;
if (!surf->model_index && m != r_worldentity.renderer.model) { if (!surf->model_index && m != r_refdef.worldmodel) {
surf->model_index = -1 - i; // instanced model surf->model_index = -1 - i; // instanced model
} }
tex = surf->texinfo->texture->render; tex = surf->texinfo->texture->render;
@ -1031,10 +1031,10 @@ Vulkan_DrawWorld (qfv_renderframe_t *rFrame)
bframe->index_count = 0; bframe->index_count = 0;
memset (&worldent, 0, sizeof (worldent)); memset (&worldent, 0, sizeof (worldent));
worldent.renderer.model = r_worldentity.renderer.model; worldent.renderer.model = r_refdef.worldmodel;
brush = &r_worldentity.renderer.model->brush; brush = &r_refdef.worldmodel->brush;
bctx->entity = &r_worldentity; bctx->entity = &worldent;
bctx->transform = 0; bctx->transform = 0;
bctx->color = 0; bctx->color = 0;

View file

@ -90,8 +90,8 @@ find_visible_lights (vulkan_ctx_t *ctx)
lightingctx_t *lctx = ctx->lighting_context; lightingctx_t *lctx = ctx->lighting_context;
lightingframe_t *lframe = &lctx->frames.a[ctx->curFrame]; lightingframe_t *lframe = &lctx->frames.a[ctx->curFrame];
mleaf_t *leaf = r_viewleaf; mleaf_t *leaf = r_refdef.viewleaf;
model_t *model = r_worldentity.renderer.model; model_t *model = r_refdef.worldmodel;
if (!leaf || !model) { if (!leaf || !model) {
return; return;

View file

@ -73,7 +73,7 @@ setup_frame (vulkan_ctx_t *ctx)
R_SetFrustum (); R_SetFrustum ();
vec4f_t position = r_refdef.frame.position; vec4f_t position = r_refdef.frame.position;
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model); r_refdef.viewleaf = Mod_PointInLeaf (&position[0], r_refdef.worldmodel);
} }
static void static void
@ -131,7 +131,7 @@ Vulkan_RenderView (qfv_renderframe_t *rFrame)
double t[10] = {}; double t[10] = {};
int speeds = r_speeds->int_val; int speeds = r_speeds->int_val;
if (!r_worldentity.renderer.model) { if (!r_refdef.worldmodel) {
return; return;
} }
@ -187,11 +187,10 @@ Vulkan_NewMap (model_t *worldmodel, struct model_s **models, int num_models,
d_lightstylevalue[i] = 264; // normal light value d_lightstylevalue[i] = 264; // normal light value
} }
memset (&r_worldentity, 0, sizeof (r_worldentity)); r_refdef.worldmodel = worldmodel;
r_worldentity.renderer.model = worldmodel;
// Force a vis update // Force a vis update
r_viewleaf = NULL; r_refdef.viewleaf = NULL;
R_MarkLeaves (); R_MarkLeaves ();
R_ClearParticles (); R_ClearParticles ();