void CL_ClearTempEntities (void)
{
- r_refdef.numtempentities = 0;
+ r_refdef.scene.numtempentities = 0;
}
entity_render_t *CL_NewTempEntity(void)
{
entity_render_t *render;
- if (r_refdef.numentities >= r_refdef.maxentities)
+ if (r_refdef.scene.numentities >= r_refdef.scene.maxentities)
return NULL;
- if (r_refdef.numtempentities >= r_refdef.maxtempentities)
+ if (r_refdef.scene.numtempentities >= r_refdef.scene.maxtempentities)
return NULL;
- render = &r_refdef.tempentities[r_refdef.numtempentities++];
+ render = &r_refdef.scene.tempentities[r_refdef.scene.numtempentities++];
memset (render, 0, sizeof(*render));
- r_refdef.entities[r_refdef.numentities++] = render;
+ r_refdef.scene.entities[r_refdef.scene.numentities++] = render;
render->alpha = 1;
VectorSet(render->colormod, 1, 1, 1);
if (r_dynamic.integer)
{
- for (i = 0, dl = cl.dlights;i < cl.num_dlights && r_refdef.numlights < MAX_DLIGHTS;i++, dl++)
+ for (i = 0, dl = cl.dlights;i < cl.num_dlights && r_refdef.scene.numlights < MAX_DLIGHTS;i++, dl++)
{
if (dl->radius)
{
tempmatrix = dl->matrix;
Matrix4x4_Scale(&tempmatrix, dl->radius, 1);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &tempmatrix, dl->color, dl->style, dl->cubemapname, dl->shadow, dl->corona, dl->coronasizescale, dl->ambientscale, dl->diffusescale, dl->specularscale, dl->flags);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &tempmatrix, dl->color, dl->style, dl->cubemapname, dl->shadow, dl->corona, dl->coronasizescale, dl->ambientscale, dl->diffusescale, dl->specularscale, dl->flags);
}
}
}
{
if (!cl.lightstyle || !cl.lightstyle[j].length)
{
- r_refdef.rtlightstylevalue[j] = 1;
- r_refdef.lightstylevalue[j] = 256;
+ r_refdef.scene.rtlightstylevalue[j] = 1;
+ r_refdef.scene.lightstylevalue[j] = 256;
continue;
}
k = i % cl.lightstyle[j].length;
// lightstylevalue is subject to a cvar for performance reasons;
// skipping lightmap updates on most rendered frames substantially
// improves framerates (but makes light fades look bad)
- r_refdef.rtlightstylevalue[j] = ((k*frac)+(l*(1-frac)))*(22/256.0f);
- r_refdef.lightstylevalue[j] = r_lerplightstyles.integer ? (unsigned short)(((k*frac)+(l*(1-frac)))*22) : k*22;
+ r_refdef.scene.rtlightstylevalue[j] = ((k*frac)+(l*(1-frac)))*(22/256.0f);
+ r_refdef.scene.lightstylevalue[j] = r_lerplightstyles.integer ? (unsigned short)(((k*frac)+(l*(1-frac)))*22) : k*22;
}
}
CL_ParticleTrail(EFFECT_EF_STARDUST, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
}
// muzzleflash fades over time, and is offset a bit
- if (e->persistent.muzzleflash > 0 && r_refdef.numlights < MAX_DLIGHTS)
+ if (e->persistent.muzzleflash > 0 && r_refdef.scene.numlights < MAX_DLIGHTS)
{
vec3_t v2;
vec3_t color;
Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]);
Matrix4x4_Scale(&tempmatrix, 150, 1);
VectorSet(color, e->persistent.muzzleflash * 4.0f, e->persistent.muzzleflash * 4.0f, e->persistent.muzzleflash * 4.0f);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &tempmatrix, color, -1, NULL, true, 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &tempmatrix, color, -1, NULL, true, 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
// LordHavoc: if the model has no flags, don't check each
if (e->render.model && e->render.effects && !(e->render.flags & RENDER_VIEWMODEL))
VectorMA(dlightcolor, (1.0f / 255.0f), palette_rgb[e->state_current.glowcolor], dlightcolor);
}
// make the glow dlight
- if (dlightradius > 0 && (dlightcolor[0] || dlightcolor[1] || dlightcolor[2]) && !(e->render.flags & RENDER_VIEWMODEL) && r_refdef.numlights < MAX_DLIGHTS)
+ if (dlightradius > 0 && (dlightcolor[0] || dlightcolor[1] || dlightcolor[2]) && !(e->render.flags & RENDER_VIEWMODEL) && r_refdef.scene.numlights < MAX_DLIGHTS)
{
matrix4x4_t dlightmatrix;
Matrix4x4_Normalize(&dlightmatrix, &e->render.matrix);
//if (e->state_current.number == cl.viewentity/* && !chase_active.integer*/)
// Matrix4x4_AdjustOrigin(&dlightmatrix, 0, 0, 30);
Matrix4x4_Scale(&dlightmatrix, dlightradius, 1);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &dlightmatrix, dlightcolor, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &dlightmatrix, dlightcolor, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
// custom rtlight
- if ((e->state_current.lightpflags & PFLAGS_FULLDYNAMIC) && r_refdef.numlights < MAX_DLIGHTS)
+ if ((e->state_current.lightpflags & PFLAGS_FULLDYNAMIC) && r_refdef.scene.numlights < MAX_DLIGHTS)
{
matrix4x4_t dlightmatrix;
float light[4];
// FIXME: add ambient/diffuse/specular scales as an extension ontop of TENEBRAE_GFX_DLIGHTS?
Matrix4x4_Normalize(&dlightmatrix, &e->render.matrix);
Matrix4x4_Scale(&dlightmatrix, light[3], 1);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &dlightmatrix, light, e->state_current.lightstyle, e->state_current.skin > 0 ? va("cubemaps/%i", e->state_current.skin) : NULL, !(e->state_current.lightpflags & PFLAGS_NOSHADOW), (e->state_current.lightpflags & PFLAGS_CORONA) != 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &dlightmatrix, light, e->state_current.lightstyle, e->state_current.skin > 0 ? va("cubemaps/%i", e->state_current.skin) : NULL, !(e->state_current.lightpflags & PFLAGS_NOSHADOW), (e->state_current.lightpflags & PFLAGS_CORONA) != 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
// do trail light
if (e->render.flags & RENDER_GLOWTRAIL)
return;
// don't show entities with no modelindex (note: this still shows
// entities which have a modelindex that resolved to a NULL model)
- if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.numentities < r_refdef.maxentities)
- r_refdef.entities[r_refdef.numentities++] = &e->render;
+ if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.scene.numentities < r_refdef.scene.maxentities)
+ r_refdef.scene.entities[r_refdef.scene.numentities++] = &e->render;
//if (cl.viewentity && e->state_current.number == cl.viewentity)
// Matrix4x4_Print(&e->render.matrix);
}
ent->render.flags |= RENDER_LIGHT;
VectorSet(ent->render.colormod, 1, 1, 1);
CL_UpdateRenderEntity(&ent->render);
- r_refdef.worldentity = &ent->render;
- r_refdef.worldmodel = cl.worldmodel;
+ r_refdef.scene.worldentity = &ent->render;
+ r_refdef.scene.worldmodel = cl.worldmodel;
}
static void CL_RelinkStaticEntities(void)
{
int i;
entity_t *e;
- for (i = 0, e = cl.static_entities;i < cl.num_static_entities && r_refdef.numentities < r_refdef.maxentities;i++, e++)
+ for (i = 0, e = cl.static_entities;i < cl.num_static_entities && r_refdef.scene.numentities < r_refdef.scene.maxentities;i++, e++)
{
e->render.flags = 0;
// if the model was not loaded when the static entity was created we
VectorSet(e->render.colormod, 1, 1, 1);
R_LerpAnimation(&e->render);
CL_UpdateRenderEntity(&e->render);
- r_refdef.entities[r_refdef.numentities++] = &e->render;
+ r_refdef.scene.entities[r_refdef.scene.numentities++] = &e->render;
}
}
if (b->lightning)
{
- if (cl_beams_lightatend.integer && r_refdef.numlights < MAX_DLIGHTS)
+ if (cl_beams_lightatend.integer && r_refdef.scene.numlights < MAX_DLIGHTS)
{
// FIXME: create a matrix from the beam start/end orientation
vec3_t dlightcolor;
VectorSet(dlightcolor, 0.3, 0.7, 1);
Matrix4x4_CreateFromQuakeEntity(&tempmatrix, end[0], end[1], end[2], 0, 0, 0, 200);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &tempmatrix, dlightcolor, -1, NULL, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &tempmatrix, dlightcolor, -1, NULL, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
if (cl_beams_polygons.integer)
continue;
*/
void CL_UpdateWorld(void)
{
- r_refdef.extraupdate = !r_speeds.integer;
- r_refdef.numentities = 0;
- r_refdef.numlights = 0;
+ r_refdef.scene.extraupdate = !r_speeds.integer;
+ r_refdef.scene.numentities = 0;
+ r_refdef.scene.numlights = 0;
r_refdef.view.matrix = identitymatrix;
cl.num_brushmodel_entities = 0;
R_MoveExplosions();
}
- r_refdef.time = cl.time;
+ r_refdef.scene.time = cl.time;
}
// LordHavoc: pausedemo command
int i;
float timestart, timedelta;
- r_refdef.extraupdate = false;
+ r_refdef.scene.extraupdate = false;
timestart = Sys_DoubleTime();
for (i = 0;i < 128;i++)
memset(&r_refdef, 0, sizeof(r_refdef));
// max entities sent to renderer per frame
- r_refdef.maxentities = MAX_EDICTS + 256 + 512;
- r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.maxentities);
+ r_refdef.scene.maxentities = MAX_EDICTS + 256 + 512;
+ r_refdef.scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.scene.maxentities);
- r_refdef.maxtempentities = 512;
- r_refdef.tempentities = (entity_render_t *)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t) * r_refdef.maxtempentities);
+ r_refdef.scene.maxtempentities = 512;
+ r_refdef.scene.tempentities = (entity_render_t *)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t) * r_refdef.scene.maxtempentities);
CL_InitInput ();
float len, dec, qd;
int smoke, blood, bubbles, r, color;
- if (spawndlight && r_refdef.numlights < MAX_DLIGHTS)
+ if (spawndlight && r_refdef.scene.numlights < MAX_DLIGHTS)
{
vec4_t light;
Vector4Set(light, 0, 0, 0, 0);
{
matrix4x4_t tempmatrix;
Matrix4x4_CreateFromQuakeEntity(&tempmatrix, originmaxs[0], originmaxs[1], originmaxs[2], 0, 0, 0, light[3]);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &tempmatrix, light, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &tempmatrix, light, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
}
// glowing entity
// called by CL_LinkNetworkEntity
Matrix4x4_Scale(&tempmatrix, info->lightradiusstart, 1);
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &tempmatrix, info->lightcolor, -1, info->lightcubemapnum > 0 ? va("cubemaps/%i", info->lightcubemapnum) : NULL, info->lightshadow, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &tempmatrix, info->lightcolor, -1, info->lightcubemapnum > 0 ? va("cubemaps/%i", info->lightcubemapnum) : NULL, info->lightshadow, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
}
// these properties are generated by R_View_Update()
// which entities are currently visible for this viewpoint
- // (the used range is 0...r_refdef.numentities)
+ // (the used range is 0...r_refdef.scene.numentities)
unsigned char entityvisible[MAX_EDICTS];
// flag arrays used for visibility checking on world model
// (all other entities have no per-surface/per-leaf visibility checks)
- // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
+ // TODO: dynamic resize according to r_refdef.scene.worldmodel->brush.num_clusters
unsigned char world_pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps
- // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
+ // TODO: dynamic resize according to r_refdef.scene.worldmodel->brush.num_leafs
unsigned char world_leafvisible[32768]; // FIXME: buffer overflow on huge maps
- // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
+ // TODO: dynamic resize according to r_refdef.scene.worldmodel->num_surfaces
unsigned char world_surfacevisible[262144]; // FIXME: buffer overflow on huge maps
// if true, the view is currently in a leaf without pvs data
qboolean world_novis;
}
r_refdef_viewcache_t;
-typedef struct r_refdef_s
-{
- // these fields define the basic rendering information for the world
- // but not the view, which could change multiple times in one rendered
- // frame (for example when rendering textures for certain effects)
-
- // these are set for water warping before
- // frustum_x/frustum_y are calculated
- float frustumscale_x, frustumscale_y;
-
- // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
- r_refdef_view_t view;
- r_refdef_viewcache_t viewcache;
-
- // minimum visible distance (pixels closer than this disappear)
- double nearclip;
- // maximum visible distance (pixels further than this disappear in 16bpp modes,
- // in 32bpp an infinite-farclip matrix is used instead)
- double farclip;
-
- // fullscreen color blend
- float viewblend[4];
-
+// TODO: really think about which fields should go into scene and which one should stay in refdef [1/7/2008 Black]
+// maybe also refactor some of the functions to support different setting sources (ie. fogenabled, etc.) for different scenes
+typedef struct r_refdef_scene_s {
// whether to call S_ExtraUpdate during render to reduce sound chop
qboolean extraupdate;
- // client gameworld time for rendering time based effects
+ // (client gameworld) time for rendering time based effects
double time;
// the world
// 8.8bit fixed point intensities for light styles
// controls intensity lightmap layers
unsigned short lightstylevalue[256]; // 8.8 fraction of base light value
+} r_refdef_scene_t;
+
+typedef struct r_refdef_s
+{
+ // these fields define the basic rendering information for the world
+ // but not the view, which could change multiple times in one rendered
+ // frame (for example when rendering textures for certain effects)
+
+ // these are set for water warping before
+ // frustum_x/frustum_y are calculated
+ float frustumscale_x, frustumscale_y;
+
+ // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
+ r_refdef_view_t view;
+ r_refdef_viewcache_t viewcache;
+
+ // minimum visible distance (pixels closer than this disappear)
+ double nearclip;
+ // maximum visible distance (pixels further than this disappear in 16bpp modes,
+ // in 32bpp an infinite-farclip matrix is used instead)
+ double farclip;
+
+ // fullscreen color blend
+ float viewblend[4];
+
+ r_refdef_scene_t scene;
vec3_t fogcolor;
vec_t fogrange;
{
VM_SAFEPARMCOUNT(0, VM_CL_R_ClearScene);
// clear renderable entity and light lists
- r_refdef.numentities = 0;
- r_refdef.numlights = 0;
+ r_refdef.scene.numentities = 0;
+ r_refdef.scene.numlights = 0;
// FIXME: restore these to the values from VM_CL_UpdateView
r_refdef.view.x = 0;
r_refdef.view.y = 0;
VM_SAFEPARMCOUNTRANGE(3, 3, VM_CL_R_AddDynamicLight);
// if we've run out of dlights, just return
- if (r_refdef.numlights >= MAX_DLIGHTS)
+ if (r_refdef.scene.numlights >= MAX_DLIGHTS)
return;
pos = PRVM_G_VECTOR(OFS_PARM0);
col = PRVM_G_VECTOR(OFS_PARM2);
Matrix4x4_CreateFromQuakeEntity(&matrix, pos[0], pos[1], pos[2], 0, 0, 0, PRVM_G_FLOAT(OFS_PARM1));
- R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &matrix, col, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &matrix, col, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
}
//============================================================================
CSQC_SetGlobals();
// clear renderable entity and light lists to prevent crashes if the
// CSQC_UpdateView function does not call R_ClearScene as it should
- r_refdef.numentities = 0;
- r_refdef.numlights = 0;
+ r_refdef.scene.numentities = 0;
+ r_refdef.scene.numlights = 0;
PRVM_ExecuteProgram(prog->funcoffsets.CSQC_UpdateView, "QC function CSQC_UpdateView is missing");
//VectorCopy(oldangles, cl.viewangles);
// Dresk : Reset Dmg Globals Here
else
{
// lightmapped wall
- if (r_glsl_deluxemapping.integer >= 1 && rsurface.uselightmaptexture && r_refdef.worldmodel && r_refdef.worldmodel->brushq3.deluxemapping)
+ if (r_glsl_deluxemapping.integer >= 1 && rsurface.uselightmaptexture && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brushq3.deluxemapping)
{
// deluxemapping (light direction texture)
- if (rsurface.uselightmaptexture && r_refdef.worldmodel && r_refdef.worldmodel->brushq3.deluxemapping && r_refdef.worldmodel->brushq3.deluxemapping_modelspace)
+ if (rsurface.uselightmaptexture && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brushq3.deluxemapping && r_refdef.scene.worldmodel->brushq3.deluxemapping_modelspace)
mode = SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE;
else
mode = SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE;
return;
renderimask = r_refdef.envmap ? (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL) : ((chase_active.integer || r_waterstate.renderingscene) ? RENDER_VIEWMODEL : RENDER_EXTERIORMODEL);
- if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs)
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.BoxTouchingVisibleLeafs)
{
// worldmodel can check visibility
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
- ent = r_refdef.entities[i];
- r_refdef.viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs)) && ((ent->effects & EF_NODEPTHTEST) || (ent->flags & RENDER_VIEWMODEL) || r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.worldmodel, r_refdef.viewcache.world_leafvisible, ent->mins, ent->maxs));
+ ent = r_refdef.scene.entities[i];
+ r_refdef.viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs)) && ((ent->effects & EF_NODEPTHTEST) || (ent->flags & RENDER_VIEWMODEL) || r_refdef.scene.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.scene.worldmodel, r_refdef.viewcache.world_leafvisible, ent->mins, ent->maxs));
}
- if(r_cullentities_trace.integer && r_refdef.worldmodel->brush.TraceLineOfSight)
+ if(r_cullentities_trace.integer && r_refdef.scene.worldmodel->brush.TraceLineOfSight)
{
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
if(r_refdef.viewcache.entityvisible[i] && !(ent->effects & EF_NODEPTHTEST) && !(ent->flags & RENDER_VIEWMODEL) && !(ent->model && (ent->model->name[0] == '*')))
{
- if(Mod_CanSeeBox_Trace(r_cullentities_trace_samples.integer, r_cullentities_trace_enlarge.value, r_refdef.worldmodel, r_refdef.view.origin, ent->mins, ent->maxs))
+ if(Mod_CanSeeBox_Trace(r_cullentities_trace_samples.integer, r_cullentities_trace_enlarge.value, r_refdef.scene.worldmodel, r_refdef.view.origin, ent->mins, ent->maxs))
ent->last_trace_visibility = realtime;
if(ent->last_trace_visibility < realtime - r_cullentities_trace_delay.value)
r_refdef.viewcache.entityvisible[i] = 0;
else
{
// no worldmodel or it can't check visibility
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
r_refdef.viewcache.entityvisible[i] = !(ent->flags & renderimask) && ((ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)) || !R_CullBox(ent->mins, ent->maxs));
}
}
return false;
sky = false;
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
if (!r_refdef.viewcache.entityvisible[i])
continue;
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
if (!ent->model || !ent->model->DrawSky)
continue;
ent->model->DrawSky(ent);
if (!r_drawentities.integer)
return;
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
if (!r_refdef.viewcache.entityvisible[i])
continue;
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
r_refdef.stats.entities++;
if (ent->model && ent->model->Draw != NULL)
ent->model->Draw(ent);
if (!r_drawentities.integer)
return;
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
if (!r_refdef.viewcache.entityvisible[i])
continue;
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
if (ent->model && ent->model->DrawDepth != NULL)
ent->model->DrawDepth(ent);
}
if (!r_drawentities.integer)
return;
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
if (!r_refdef.viewcache.entityvisible[i])
continue;
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
if (ent->model && ent->model->DrawDebug != NULL)
ent->model->DrawDebug(ent);
}
if (!r_drawentities.integer)
return;
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
if (!r_refdef.viewcache.entityvisible[i])
continue;
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
if (ent->model && ent->model->DrawAddWaterPlanes != NULL)
ent->model->DrawAddWaterPlanes(ent);
}
p->materialflags |= surface->texture->currentframe->currentmaterialflags;
// merge this surface's PVS into the waterplane
VectorMAM(0.5f, surface->mins, 0.5f, surface->maxs, center);
- if (p->materialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION) && r_refdef.worldmodel && r_refdef.worldmodel->brush.FatPVS
- && r_refdef.worldmodel->brush.PointInLeaf && r_refdef.worldmodel->brush.PointInLeaf(r_refdef.worldmodel, center)->clusterindex >= 0)
+ if (p->materialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION) && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.FatPVS
+ && r_refdef.scene.worldmodel->brush.PointInLeaf && r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, center)->clusterindex >= 0)
{
- r_refdef.worldmodel->brush.FatPVS(r_refdef.worldmodel, center, 2, p->pvsbits, sizeof(p->pvsbits), p->pvsvalid);
+ r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, center, 2, p->pvsbits, sizeof(p->pvsbits), p->pvsvalid);
p->pvsvalid = true;
}
}
// reverse the cullface settings for this render
r_refdef.view.cullface_front = GL_FRONT;
r_refdef.view.cullface_back = GL_BACK;
- if (r_refdef.worldmodel && r_refdef.worldmodel->brush.num_pvsclusterbytes)
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.num_pvsclusterbytes)
{
r_refdef.view.usecustompvs = true;
if (p->pvsvalid)
- memcpy(r_refdef.viewcache.world_pvsbits, p->pvsbits, r_refdef.worldmodel->brush.num_pvsclusterbytes);
+ memcpy(r_refdef.viewcache.world_pvsbits, p->pvsbits, r_refdef.scene.worldmodel->brush.num_pvsclusterbytes);
else
- memset(r_refdef.viewcache.world_pvsbits, 0xFF, r_refdef.worldmodel->brush.num_pvsclusterbytes);
+ memset(r_refdef.viewcache.world_pvsbits, 0xFF, r_refdef.scene.worldmodel->brush.num_pvsclusterbytes);
}
R_ResetViewRendering3D();
R_Textures_Frame();
r_refdef.farclip = 4096;
- if (r_refdef.worldmodel)
- r_refdef.farclip += VectorDistance(r_refdef.worldmodel->normalmins, r_refdef.worldmodel->normalmaxs);
+ if (r_refdef.scene.worldmodel)
+ r_refdef.farclip += VectorDistance(r_refdef.scene.worldmodel->normalmins, r_refdef.scene.worldmodel->normalmaxs);
r_refdef.nearclip = bound (0.001f, r_nearclip.value, r_refdef.farclip - 1.0f);
if (r_shadow_frontsidecasting.integer < 0 || r_shadow_frontsidecasting.integer > 1)
*/
void R_RenderView(void)
{
- if (!r_refdef.entities/* || !r_refdef.worldmodel*/)
+ if (!r_refdef.scene.entities/* || !r_refdef.scene.worldmodel*/)
return; //Host_Error ("R_RenderView: NULL worldmodel");
r_refdef.view.colorscale = r_hdr_scenebrightness.value;
if (r_timereport_active)
R_TimeReport("watervis");
- if (cl.csqc_vidvars.drawworld && r_refdef.worldmodel && r_refdef.worldmodel->DrawAddWaterPlanes)
+ if (cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawAddWaterPlanes)
{
- r_refdef.worldmodel->DrawAddWaterPlanes(r_refdef.worldentity);
+ r_refdef.scene.worldmodel->DrawAddWaterPlanes(r_refdef.scene.worldentity);
if (r_timereport_active)
R_TimeReport("waterworld");
}
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
R_DrawModelsAddWaterPlanes();
R_ResetViewRendering3D();
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
R_MeshQueue_BeginScene();
if (r_timereport_active)
R_TimeReport("visibility");
- Matrix4x4_CreateTranslate(&r_waterscrollmatrix, sin(r_refdef.time) * 0.025 * r_waterscroll.value, sin(r_refdef.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
+ Matrix4x4_CreateTranslate(&r_waterscrollmatrix, sin(r_refdef.scene.time) * 0.025 * r_waterscroll.value, sin(r_refdef.scene.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
if (cl.csqc_vidvars.drawworld)
{
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
- if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky)
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky)
{
- r_refdef.worldmodel->DrawSky(r_refdef.worldentity);
+ r_refdef.scene.worldmodel->DrawSky(r_refdef.scene.worldentity);
if (r_timereport_active)
R_TimeReport("worldsky");
}
R_TimeReport("bmodelsky");
}
- if (r_depthfirst.integer >= 1 && cl.csqc_vidvars.drawworld && r_refdef.worldmodel && r_refdef.worldmodel->DrawDepth)
+ if (r_depthfirst.integer >= 1 && cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawDepth)
{
- r_refdef.worldmodel->DrawDepth(r_refdef.worldentity);
+ r_refdef.scene.worldmodel->DrawDepth(r_refdef.scene.worldentity);
if (r_timereport_active)
R_TimeReport("worlddepth");
}
R_TimeReport("modeldepth");
}
- if (cl.csqc_vidvars.drawworld && r_refdef.worldmodel && r_refdef.worldmodel->Draw)
+ if (cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->Draw)
{
- r_refdef.worldmodel->Draw(r_refdef.worldentity);
+ r_refdef.scene.worldmodel->Draw(r_refdef.scene.worldentity);
if (r_timereport_active)
R_TimeReport("world");
}
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
R_DrawModels();
R_TimeReport("models");
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
if (r_shadows.integer > 0 && r_refdef.lightmapintensity > 0)
R_ResetViewRendering3D();
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
}
R_TimeReport("rtlights");
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
if (cl.csqc_vidvars.drawworld)
qglUseProgramObjectARB(0);CHECKGLERROR
}
- if (r_refdef.view.showdebug && r_refdef.worldmodel && r_refdef.worldmodel->DrawDebug && (r_showtris.value > 0 || r_shownormals.value > 0 || r_showcollisionbrushes.value > 0))
+ if (r_refdef.view.showdebug && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawDebug && (r_showtris.value > 0 || r_shownormals.value > 0 || r_showcollisionbrushes.value > 0))
{
- r_refdef.worldmodel->DrawDebug(r_refdef.worldentity);
+ r_refdef.scene.worldmodel->DrawDebug(r_refdef.scene.worldentity);
if (r_timereport_active)
R_TimeReport("worlddebug");
R_DrawModelsDebug();
}
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
R_ResetViewRendering2D();
static float R_EvaluateQ3WaveFunc(q3wavefunc_t func, const float *parms)
{
double index, f;
- index = parms[2] + r_refdef.time * parms[3];
+ index = parms[2] + r_refdef.scene.time * parms[3];
index -= floor(index);
switch (func)
{
if (model->skinscenes)
{
if (model->skinscenes[s].framecount > 1)
- s = model->skinscenes[s].firstframe + (unsigned int) (r_refdef.time * model->skinscenes[s].framerate) % model->skinscenes[s].framecount;
+ s = model->skinscenes[s].firstframe + (unsigned int) (r_refdef.scene.time * model->skinscenes[s].framerate) % model->skinscenes[s].framecount;
else
s = model->skinscenes[s].firstframe;
}
// use an alternate animation if the entity's frame is not 0,
// and only if the texture has an alternate animation
if (ent->frame2 != 0 && t->anim_total[1])
- t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[1]) : 0];
+ t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(r_refdef.scene.time * 5.0f) % t->anim_total[1]) : 0];
else
- t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(r_refdef.time * 5.0f) % t->anim_total[0]) : 0];
+ t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(r_refdef.scene.time * 5.0f) % t->anim_total[0]) : 0];
}
texture->currentframe = t;
}
break;
case Q3TCMOD_ROTATE:
Matrix4x4_CreateTranslate(&matrix, 0.5, 0.5, 0);
- Matrix4x4_ConcatRotate(&matrix, tcmod->parms[0] * r_refdef.time, 0, 0, 1);
+ Matrix4x4_ConcatRotate(&matrix, tcmod->parms[0] * r_refdef.scene.time, 0, 0, 1);
Matrix4x4_ConcatTranslate(&matrix, -0.5, -0.5, 0);
break;
case Q3TCMOD_SCALE:
Matrix4x4_CreateScale3(&matrix, tcmod->parms[0], tcmod->parms[1], 1);
break;
case Q3TCMOD_SCROLL:
- Matrix4x4_CreateTranslate(&matrix, tcmod->parms[0] * r_refdef.time, tcmod->parms[1] * r_refdef.time, 0);
+ Matrix4x4_CreateTranslate(&matrix, tcmod->parms[0] * r_refdef.scene.time, tcmod->parms[1] * r_refdef.scene.time, 0);
break;
case Q3TCMOD_STRETCH:
f = 1.0f / R_EvaluateQ3WaveFunc(tcmod->wavefunc, tcmod->waveparms);
// applied to the color
// FIXME: r_glsl 1 rendering doesn't support overbright lightstyles with this (the default light style is not overbright)
if (ent->model->type == mod_brushq3)
- colorscale *= r_refdef.rtlightstylevalue[0];
+ colorscale *= r_refdef.scene.rtlightstylevalue[0];
colorscale *= r_refdef.lightmapintensity;
VectorScale(t->lightmapcolor, r_ambient.value * (1.0f / 64.0f), ambientcolor);
VectorScale(t->lightmapcolor, colorscale, t->lightmapcolor);
void RSurf_ActiveWorldEntity(void)
{
- model_t *model = r_refdef.worldmodel;
+ model_t *model = r_refdef.scene.worldmodel;
RSurf_CleanUp();
if (rsurface.array_size < model->surfmesh.num_vertices)
R_Mesh_ResizeArrays(model->surfmesh.num_vertices);
float *normal = (rsurface.array_deformednormal3f + 3 * surface->num_firstvertex) + j*3;
VectorScale((rsurface.vertex3f + 3 * surface->num_firstvertex) + j*3, 0.98f, vertex);
VectorCopy((rsurface.normal3f + 3 * surface->num_firstvertex) + j*3, normal);
- normal[0] += deform->parms[0] * noise4f( vertex[0], vertex[1], vertex[2], r_refdef.time * deform->parms[1]);
- normal[1] += deform->parms[0] * noise4f( 98 + vertex[0], vertex[1], vertex[2], r_refdef.time * deform->parms[1]);
- normal[2] += deform->parms[0] * noise4f(196 + vertex[0], vertex[1], vertex[2], r_refdef.time * deform->parms[1]);
+ normal[0] += deform->parms[0] * noise4f( vertex[0], vertex[1], vertex[2], r_refdef.scene.time * deform->parms[1]);
+ normal[1] += deform->parms[0] * noise4f( 98 + vertex[0], vertex[1], vertex[2], r_refdef.scene.time * deform->parms[1]);
+ normal[2] += deform->parms[0] * noise4f(196 + vertex[0], vertex[1], vertex[2], r_refdef.scene.time * deform->parms[1]);
VectorNormalize(normal);
}
Mod_BuildTextureVectorsFromNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface.vertex3f, rsurface.modeltexcoordtexture2f, rsurface.array_deformednormal3f, rsurface.modelelement3i + surface->num_firsttriangle * 3, rsurface.array_deformedsvector3f, rsurface.array_deformedtvector3f, r_smoothnormals_areaweighting.integer);
const msurface_t *surface = texturesurfacelist[texturesurfaceindex];
for (j = 0;j < surface->num_vertices;j++)
{
- scale = sin((rsurface.modeltexcoordtexture2f[2 * (surface->num_firstvertex + j)] * deform->parms[0] + r_refdef.time * deform->parms[2])) * deform->parms[1];
+ scale = sin((rsurface.modeltexcoordtexture2f[2 * (surface->num_firstvertex + j)] * deform->parms[0] + r_refdef.scene.time * deform->parms[2])) * deform->parms[1];
VectorMA(rsurface.vertex3f + 3 * (surface->num_firstvertex + j), scale, rsurface.normal3f + 3 * (surface->num_firstvertex + j), rsurface.array_deformedvertex3f + 3 * (surface->num_firstvertex + j));
}
}
if (rsurface.texture->tcmods[0].tcmod == Q3TCMOD_TURBULENT)
{
amplitude = rsurface.texture->tcmods[0].parms[1];
- animpos = rsurface.texture->tcmods[0].parms[2] + r_refdef.time * rsurface.texture->tcmods[0].parms[3];
+ animpos = rsurface.texture->tcmods[0].parms[2] + r_refdef.scene.time * rsurface.texture->tcmods[0].parms[3];
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
const msurface_t *surface = texturesurfacelist[texturesurfaceindex];
if (surface->lightmapinfo->samples)
{
const unsigned char *lm = surface->lightmapinfo->samples + (rsurface.modellightmapoffsets + surface->num_firstvertex)[i];
- float scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
+ float scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
VectorScale(lm, scale, c);
if (surface->lightmapinfo->styles[1] != 255)
{
int size3 = ((surface->lightmapinfo->extents[0]>>4)+1)*((surface->lightmapinfo->extents[1]>>4)+1)*3;
lm += size3;
- scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[1]] * (1.0f / 32768.0f);
+ scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[1]] * (1.0f / 32768.0f);
VectorMA(c, scale, lm, c);
if (surface->lightmapinfo->styles[2] != 255)
{
lm += size3;
- scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[2]] * (1.0f / 32768.0f);
+ scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[2]] * (1.0f / 32768.0f);
VectorMA(c, scale, lm, c);
if (surface->lightmapinfo->styles[3] != 255)
{
lm += size3;
- scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[3]] * (1.0f / 32768.0f);
+ scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[3]] * (1.0f / 32768.0f);
VectorMA(c, scale, lm, c);
}
}
// in Quake3 maps as it causes problems with q3map2 sky tricks,
// and skymasking also looks very bad when noclipping outside the
// level, so don't use it then either.
- if (r_refdef.worldmodel && r_refdef.worldmodel->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_refdef.viewcache.world_novis)
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->type == mod_brushq1 && r_q1bsp_skymasking.integer && !r_refdef.viewcache.world_novis)
{
GL_Color(r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], 1);
R_Mesh_ColorPointer(NULL, 0, 0);
// if the model is static it doesn't matter what value we give for
// wantnormals and wanttangents, so this logic uses only rules applicable
// to a model, knowing that they are meaningless otherwise
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
RSurf_ActiveWorldEntity();
else if ((ent->effects & EF_FULLBRIGHT) || r_showsurfaces.integer || VectorLength2(ent->modellight_diffuse) < (1.0f / 256.0f))
RSurf_ActiveModelEntity(ent, false, false);
}
for (i = 0, j = model->firstmodelsurface, surface = model->data_surfaces + j;i < model->nummodelsurfaces;i++, j++, surface++)
{
- if (ent == r_refdef.worldentity && !r_refdef.viewcache.world_surfacevisible[j])
+ if (ent == r_refdef.scene.worldentity && !r_refdef.viewcache.world_surfacevisible[j])
continue;
rsurface.texture = surface->texture->currentframe;
if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
{
if (!rsurface.texture->currentlayers->depthmask)
GL_Color(r_refdef.view.colorscale, 0, 0, r_showtris.value);
- else if (ent == r_refdef.worldentity)
+ else if (ent == r_refdef.scene.worldentity)
GL_Color(r_refdef.view.colorscale, r_refdef.view.colorscale, r_refdef.view.colorscale, r_showtris.value);
else
GL_Color(0, r_refdef.view.colorscale, 0, r_showtris.value);
int i, j, endj, f, flagsmask;
msurface_t *surface;
texture_t *t;
- model_t *model = r_refdef.worldmodel;
+ model_t *model = r_refdef.scene.worldmodel;
const int maxsurfacelist = 1024;
int numsurfacelist = 0;
msurface_t *surfacelist[1024];
model_brush_lightstyleinfo_t *style;
for (i = 0, style = model->brushq1.data_lightstyleinfo;i < model->brushq1.num_lightstyles;i++, style++)
{
- if (style->value != r_refdef.lightstylevalue[style->style])
+ if (style->value != r_refdef.scene.lightstylevalue[style->style])
{
msurface_t *surfaces = model->data_surfaces;
int *list = style->surfacelist;
- style->value = r_refdef.lightstylevalue[style->style];
+ style->value = r_refdef.scene.lightstylevalue[style->style];
for (j = 0;j < style->numsurfaces;j++)
surfaces[list[j]].cached_dlight = true;
}
}
}
- R_UpdateAllTextureInfo(r_refdef.worldentity);
+ R_UpdateAllTextureInfo(r_refdef.scene.worldentity);
flagsmask = addwaterplanes ? (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION) : (skysurfaces ? MATERIALFLAG_SKY : (MATERIALFLAG_WATER | MATERIALFLAG_WALL));
if (debug)
{
- R_DrawDebugModel(r_refdef.worldentity);
+ R_DrawDebugModel(r_refdef.scene.worldentity);
return;
}
{
// if lightmap parameters changed, rebuild lightmap texture
if (surface->cached_dlight)
- R_BuildLightMap(r_refdef.worldentity, surface);
+ R_BuildLightMap(r_refdef.scene.worldentity, surface);
// add face to draw list
surfacelist[numsurfacelist++] = surface;
r_refdef.stats.world_triangles += surface->num_triangles;
if (numsurfacelist >= maxsurfacelist)
{
r_refdef.stats.world_surfaces += numsurfacelist;
- R_QueueSurfaceList(r_refdef.worldentity, numsurfacelist, surfacelist, flagsmask, writedepth, depthonly, addwaterplanes);
+ R_QueueSurfaceList(r_refdef.scene.worldentity, numsurfacelist, surfacelist, flagsmask, writedepth, depthonly, addwaterplanes);
numsurfacelist = 0;
}
}
}
r_refdef.stats.world_surfaces += numsurfacelist;
if (numsurfacelist)
- R_QueueSurfaceList(r_refdef.worldentity, numsurfacelist, surfacelist, flagsmask, writedepth, depthonly, addwaterplanes);
+ R_QueueSurfaceList(r_refdef.scene.worldentity, numsurfacelist, surfacelist, flagsmask, writedepth, depthonly, addwaterplanes);
RSurf_CleanUp();
}
// if the model is static it doesn't matter what value we give for
// wantnormals and wanttangents, so this logic uses only rules applicable
// to a model, knowing that they are meaningless otherwise
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
RSurf_ActiveWorldEntity();
else if ((ent->effects & EF_FULLBRIGHT) || r_showsurfaces.integer || VectorLength2(ent->modellight_diffuse) < (1.0f / 256.0f))
RSurf_ActiveModelEntity(ent, false, false);
model_brush_lightstyleinfo_t *style;
for (i = 0, style = model->brushq1.data_lightstyleinfo;i < model->brushq1.num_lightstyles;i++, style++)
{
- if (style->value != r_refdef.lightstylevalue[style->style])
+ if (style->value != r_refdef.scene.lightstylevalue[style->style])
{
msurface_t *surfaces = model->data_surfaces;
int *list = style->surfacelist;
- style->value = r_refdef.lightstylevalue[style->style];
+ style->value = r_refdef.scene.lightstylevalue[style->style];
for (j = 0;j < style->numsurfaces;j++)
surfaces[list[j]].cached_dlight = true;
}
// add all the lightmaps
if (lightmap)
for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3)
- for (scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size3;i++)
+ for (scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size3;i++)
bl[i] += lightmap[i] * scale;
}
{
for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3, normalmap += size3)
{
- for (scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size;i++)
+ for (scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size;i++)
{
// add the normalmap with weighting proportional to the style's lightmap intensity
l = (int)(VectorLength(lightmap + i*3) * scale);
entity_render_t *ent;
model_t *model;
vec3_t org;
- if (r_refdef.worldmodel == NULL || !r_refdef.worldmodel->brush.data_nodes || !r_refdef.worldmodel->brushq1.lightdata)
+ if (r_refdef.scene.worldmodel == NULL || !r_refdef.scene.worldmodel->brush.data_nodes || !r_refdef.scene.worldmodel->brushq1.lightdata)
return;
fcolor[0] = cr1;
fcolor[1] = cg1;
fcolor[6] = cb2 - cb1;
fcolor[7] = (ca2 - ca1) * (1.0f / 64.0f);
- R_StainNode(r_refdef.worldmodel->brush.data_nodes + r_refdef.worldmodel->brushq1.hulls[0].firstclipnode, r_refdef.worldmodel, origin, radius, fcolor);
+ R_StainNode(r_refdef.scene.worldmodel->brush.data_nodes + r_refdef.scene.worldmodel->brushq1.hulls[0].firstclipnode, r_refdef.scene.worldmodel, origin, radius, fcolor);
// look for embedded bmodels
for (n = 0;n < cl.num_brushmodel_entities;n++)
int i, leafnum;
mportal_t *portal;
float center[3], f;
- model_t *model = r_refdef.worldmodel;
+ model_t *model = r_refdef.scene.worldmodel;
if (model == NULL)
return;
- for (leafnum = 0;leafnum < r_refdef.worldmodel->brush.num_leafs;leafnum++)
+ for (leafnum = 0;leafnum < r_refdef.scene.worldmodel->brush.num_leafs;leafnum++)
{
if (r_refdef.viewcache.world_leafvisible[leafnum])
{
//for (portalnum = 0, portal = model->brush.data_portals;portalnum < model->brush.num_portals;portalnum++, portal++)
- for (portal = r_refdef.worldmodel->brush.data_leafs[leafnum].portals;portal;portal = portal->next)
+ for (portal = r_refdef.scene.worldmodel->brush.data_leafs[leafnum].portals;portal;portal = portal->next)
{
if (portal->numpoints <= POLYGONELEMENTS_MAXPOINTS)
if (!R_CullBox(portal->mins, portal->maxs))
int i, j, *mark;
mleaf_t *leaf;
mleaf_t *viewleaf;
- model_t *model = r_refdef.worldmodel;
+ model_t *model = r_refdef.scene.worldmodel;
if (!model)
return;
{
if (ent->model == NULL)
return;
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
R_DrawWorldSurfaces(true, true, false, false, false);
else
R_DrawModelSurfaces(ent, true, true, false, false, false);
model_t *model = ent->model;
if (model == NULL)
return;
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
R_DrawWorldSurfaces(false, false, false, true, false);
else
R_DrawModelSurfaces(ent, false, false, false, true, false);
model_t *model = ent->model;
if (model == NULL)
return;
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
R_DrawWorldSurfaces(false, true, false, false, false);
else
R_DrawModelSurfaces(ent, false, true, false, false, false);
model_t *model = ent->model;
if (model == NULL)
return;
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
R_DrawWorldSurfaces(false, false, true, false, false);
else
R_DrawModelSurfaces(ent, false, false, true, false, false);
{
if (ent->model == NULL)
return;
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
R_DrawWorldSurfaces(false, false, false, false, true);
else
R_DrawModelSurfaces(ent, false, false, false, false, true);
{
batchnumsurfaces = 0;
endsurface = min(i + RSURF_MAX_BATCHSURFACES, numsurfaces);
- if (ent == r_refdef.worldentity)
+ if (ent == r_refdef.scene.worldentity)
{
for (;i < endsurface;i++)
if (r_refdef.viewcache.world_surfacevisible[surfacelist[i]])
int i;
const char *r, *newt;
skinframe_t *skinframe;
- if (!r_refdef.worldmodel)
+ if (!r_refdef.scene.worldmodel)
{
Con_Printf("There is no worldmodel\n");
return;
}
- m = r_refdef.worldmodel;
+ m = r_refdef.scene.worldmodel;
if(Cmd_Argc() < 2)
{
model_t *m;
texture_t *t;
int i;
- if (!r_refdef.worldmodel)
+ if (!r_refdef.scene.worldmodel)
{
Con_Printf("There is no worldmodel\n");
return;
}
- m = r_refdef.worldmodel;
+ m = r_refdef.scene.worldmodel;
Con_Print("Worldmodel textures :\n");
for(i=0,t=m->data_textures;i<m->num_textures;i++,t++)
void MP_Draw (void)
{
- extern r_refdef_t menu_refdef;
+ // declarations that are needed right now
+ extern r_refdef_scene_t menu_scene;
- static r_refdef_t clientrefdef;
- clientrefdef = r_refdef;
- r_refdef = menu_refdef;
+ static r_refdef_scene_t clientscene;
+ clientscene = r_refdef.scene;
+ r_refdef.scene = menu_scene;
// reset the temp entities each frame
- r_refdef.numtempentities = 0;
-
- // TODO: fix these evil hacks! [1/6/2008 Black]
- R_UpdateVariables();
- R_ResetViewRendering2D();
+ r_refdef.scene.numtempentities = 0;
PRVM_Begin;
PRVM_SetProg(PRVM_MENUPROG);
PRVM_End;
- menu_refdef = r_refdef;
- r_refdef = clientrefdef;
+ menu_scene = r_refdef.scene;
+ r_refdef.scene = clientscene;
}
void MP_ToggleMenu_f (void)
// bilinear filter each lightmap style, and sum them
for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++)
{
- scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[maps]];
+ scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]];
w = w00 * scale;VectorMA(ambientcolor, w, lightmap , ambientcolor);
w = w01 * scale;VectorMA(ambientcolor, w, lightmap + 3 , ambientcolor);
w = w10 * scale;VectorMA(ambientcolor, w, lightmap + line3 , ambientcolor);
q3dlightgrid_t *a, *s;
// scale lighting by lightstyle[0] so that darkmode in dpmod works properly
- stylescale = r_refdef.rtlightstylevalue[0];
+ stylescale = r_refdef.scene.rtlightstylevalue[0];
if (!model->brushq3.num_lightgrid)
{
{
// texture mapping properties used by this surface
mtexinfo_t *texinfo; // q1bsp
- // index into r_refdef.lightstylevalue array, 255 means not used (black)
+ // index into r_refdef.scene.lightstylevalue array, 255 means not used (black)
unsigned char styles[MAXLIGHTMAPS]; // q1bsp
// RGB lighting data [numstyles][height][width][3]
unsigned char *samples; // q1bsp
const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
-r_refdef_t menu_refdef;
+r_refdef_scene_t menu_scene;
void VM_M_Cmd_Init(void)
{
VM_Cmd_Init();
VM_Polygons_Reset();
- memset (&menu_refdef, 0, sizeof (r_refdef_t));
-
- menu_refdef.maxtempentities = 128;
- menu_refdef.tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * menu_refdef.maxtempentities);
-
- menu_refdef.frustumscale_x = 1;
- menu_refdef.frustumscale_y = 1;
- menu_refdef.maxentities = MAX_EDICTS + 256 + 512;
- menu_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * menu_refdef.maxentities);
-
- menu_refdef.view.width = vid.width;
- menu_refdef.view.height = vid.height;
- menu_refdef.view.depth = 1;
- menu_refdef.view.x = 0;
- menu_refdef.view.y = 0;
- menu_refdef.view.z = 0;
- menu_refdef.view.colormask[0] = true;
- menu_refdef.view.colormask[1] = true;
- menu_refdef.view.colormask[2] = true;
- menu_refdef.view.colormask[3] = true;
-
- menu_refdef.view.useperspective = false;
- menu_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0);
- menu_refdef.view.frustum_x = menu_refdef.view.frustum_y * (float)menu_refdef.view.width / (float)menu_refdef.view.height / vid_pixelheight.value;
+ memset (&menu_scene, 0, sizeof (menu_scene));
+
+ menu_scene.maxtempentities = 128;
+ menu_scene.tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * menu_scene.maxtempentities);
+
+ menu_scene.maxentities = MAX_EDICTS + 256 + 512;
+ menu_scene.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * menu_scene.maxentities);
}
void VM_M_Cmd_Reset(void)
VectorNormalize(up);
// calculate T coordinate scrolling (start and end texcoord along the beam)
- t1 = r_refdef.time * -r_lightningbeam_scroll.value;// + beamrepeatscale * DotProduct(start, beamdir);
+ t1 = r_refdef.scene.time * -r_lightningbeam_scroll.value;// + beamrepeatscale * DotProduct(start, beamdir);
t1 = t1 - (int) t1;
t2 = t1 + beamrepeatscale * length;
void r_shadow_newmap(void)
{
- if (r_refdef.worldmodel && strncmp(r_refdef.worldmodel->name, r_shadow_mapname, sizeof(r_shadow_mapname)))
+ if (r_refdef.scene.worldmodel && strncmp(r_refdef.scene.worldmodel->name, r_shadow_mapname, sizeof(r_shadow_mapname)))
R_Shadow_EditLights_Reload_f();
}
int i;
int numsurfaces, numleafs, numleafpvsbytes, numshadowtrispvsbytes, numlighttrispvsbytes;
int lighttris, shadowtris, shadowmeshes, shadowmeshtris;
- entity_render_t *ent = r_refdef.worldentity;
- model_t *model = r_refdef.worldmodel;
+ entity_render_t *ent = r_refdef.scene.worldentity;
+ model_t *model = r_refdef.scene.worldmodel;
unsigned char *data;
// compile the light
}
CHECKGLERROR
}
- else if (numsurfaces && r_refdef.worldmodel->brush.shadowmesh && r_shadow_culltriangles.integer)
+ else if (numsurfaces && r_refdef.scene.worldmodel->brush.shadowmesh && r_shadow_culltriangles.integer)
{
int t, tend;
int surfacelistindex;
msurface_t *surface;
- R_Shadow_PrepareShadowMark(r_refdef.worldmodel->brush.shadowmesh->numtriangles);
+ R_Shadow_PrepareShadowMark(r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
- surface = r_refdef.worldmodel->data_surfaces + surfacelist[surfacelistindex];
+ surface = r_refdef.scene.worldmodel->data_surfaces + surfacelist[surfacelistindex];
for (t = surface->num_firstshadowmeshtriangle, tend = t + surface->num_triangles;t < tend;t++)
if (CHECKPVSBIT(trispvs, t))
shadowmarklist[numshadowmark++] = t;
}
- R_Shadow_VolumeFromList(r_refdef.worldmodel->brush.shadowmesh->numverts, r_refdef.worldmodel->brush.shadowmesh->numtriangles, r_refdef.worldmodel->brush.shadowmesh->vertex3f, r_refdef.worldmodel->brush.shadowmesh->element3i, r_refdef.worldmodel->brush.shadowmesh->neighbor3i, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius + r_refdef.worldmodel->radius*2 + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
+ R_Shadow_VolumeFromList(r_refdef.scene.worldmodel->brush.shadowmesh->numverts, r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles, r_refdef.scene.worldmodel->brush.shadowmesh->vertex3f, r_refdef.scene.worldmodel->brush.shadowmesh->element3i, r_refdef.scene.worldmodel->brush.shadowmesh->neighbor3i, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius + r_refdef.scene.worldmodel->radius*2 + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
}
else if (numsurfaces)
- r_refdef.worldmodel->DrawShadowVolume(r_refdef.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs);
+ r_refdef.scene.worldmodel->DrawShadowVolume(r_refdef.scene.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs);
}
void R_Shadow_DrawEntityShadow(entity_render_t *ent)
void R_Shadow_DrawWorldLight(int numsurfaces, int *surfacelist, const unsigned char *trispvs)
{
- if (!r_refdef.worldmodel->DrawLight)
+ if (!r_refdef.scene.worldmodel->DrawLight)
return;
// set up properties for rendering light onto this entity
if (r_shadow_lightingrendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
R_Mesh_TexMatrix(3, &rsurface.entitytolight);
- r_refdef.worldmodel->DrawLight(r_refdef.worldentity, numsurfaces, surfacelist, trispvs);
+ r_refdef.scene.worldmodel->DrawLight(r_refdef.scene.worldentity, numsurfaces, surfacelist, trispvs);
}
void R_Shadow_DrawEntityLight(entity_render_t *ent)
rtlight->currentcubemap = rtlight->cubemapname[0] ? R_Shadow_Cubemap(rtlight->cubemapname) : r_texture_whitecube;
// look up the light style value at this time
- f = (rtlight->style >= 0 ? r_refdef.rtlightstylevalue[rtlight->style] : 1) * r_shadow_lightintensityscale.value;
+ f = (rtlight->style >= 0 ? r_refdef.scene.rtlightstylevalue[rtlight->style] : 1) * r_shadow_lightintensityscale.value;
VectorScale(rtlight->color, f, rtlight->currentcolor);
/*
if (rtlight->selected)
shadowtrispvs = rtlight->static_shadowtrispvs;
lighttrispvs = rtlight->static_lighttrispvs;
}
- else if (r_refdef.worldmodel && r_refdef.worldmodel->GetLightInfo)
+ else if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->GetLightInfo)
{
// dynamic light, world available and can receive realtime lighting
// calculate lit surfaces and leafs
- R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.worldmodel->brush.num_leafs, r_refdef.worldmodel->num_surfaces, r_refdef.worldmodel->brush.shadowmesh ? r_refdef.worldmodel->brush.shadowmesh->numtriangles : r_refdef.worldmodel->surfmesh.num_triangles, r_refdef.worldmodel->surfmesh.num_triangles);
- r_refdef.worldmodel->GetLightInfo(r_refdef.worldentity, rtlight->shadoworigin, rtlight->radius, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs);
+ R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.scene.worldmodel->brush.num_leafs, r_refdef.scene.worldmodel->num_surfaces, r_refdef.scene.worldmodel->brush.shadowmesh ? r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles : r_refdef.scene.worldmodel->surfmesh.num_triangles, r_refdef.scene.worldmodel->surfmesh.num_triangles);
+ r_refdef.scene.worldmodel->GetLightInfo(r_refdef.scene.worldentity, rtlight->shadoworigin, rtlight->radius, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs);
leaflist = r_shadow_buffer_leaflist;
leafpvs = r_shadow_buffer_leafpvs;
surfacelist = r_shadow_buffer_surfacelist;
// add dynamic entities that are lit by the light
if (r_drawentities.integer)
{
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
model_t *model;
- entity_render_t *ent = r_refdef.entities[i];
+ entity_render_t *ent = r_refdef.scene.entities[i];
vec3_t org;
if (!BoxesOverlap(ent->mins, ent->maxs, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
continue;
// inside the light box
// TODO: check if the surfaces in the model can receive light
// so now check if it's in a leaf seen by the light
- if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingLeafPVS && !r_refdef.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.worldmodel, leafpvs, ent->mins, ent->maxs))
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.BoxTouchingLeafPVS && !r_refdef.scene.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.scene.worldmodel, leafpvs, ent->mins, ent->maxs))
continue;
if (ent->flags & RENDER_NOSELFSHADOW)
lightentities_noselfshadow[numlightentities_noselfshadow++] = ent;
// cast a shadow...
// TODO: check if the surfaces in the model can cast shadow
// now check if it is in a leaf seen by the light
- if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingLeafPVS && !r_refdef.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.worldmodel, leafpvs, ent->mins, ent->maxs))
+ if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.BoxTouchingLeafPVS && !r_refdef.scene.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.scene.worldmodel, leafpvs, ent->mins, ent->maxs))
continue;
// about the VectorDistance2 - light emitting entities should not cast their own shadow
Matrix4x4_OriginFromMatrix(&ent->matrix, org);
return;
// don't let sound skip if going slow
- if (r_refdef.extraupdate)
+ if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
// make this the active rtlight for rendering purposes
}
}
if (r_refdef.rtdlight)
- for (lnum = 0;lnum < r_refdef.numlights;lnum++)
- R_DrawRTLight(&r_refdef.lights[lnum], visible);
+ for (lnum = 0;lnum < r_refdef.scene.numlights;lnum++)
+ R_DrawRTLight(&r_refdef.scene.lights[lnum], visible);
R_Shadow_RenderMode_End();
}
R_Shadow_RenderMode_StencilShadowVolumes(true);
- for (i = 0;i < r_refdef.numentities;i++)
+ for (i = 0;i < r_refdef.scene.numentities;i++)
{
- ent = r_refdef.entities[i];
+ ent = r_refdef.scene.entities[i];
// cast shadows from anything that is not a submodel of the map
if (ent->model && ent->model->DrawShadowVolume != NULL && !ent->model->brush.submodel && (ent->flags & RENDER_SHADOW))
{
continue;
R_DrawSprite(GL_ONE, GL_ONE, r_shadow_lightcorona, NULL, true, false, rtlight->shadoworigin, r_refdef.view.right, r_refdef.view.up, scale, -scale, -scale, scale, rtlight->color[0] * cscale, rtlight->color[1] * cscale, rtlight->color[2] * cscale, 1);
}
- for (i = 0;i < r_refdef.numlights;i++)
+ for (i = 0;i < r_refdef.scene.numlights;i++)
{
- rtlight = &r_refdef.lights[i];
+ rtlight = &r_refdef.scene.lights[i];
if (!(rtlight->flags & flag))
continue;
if (rtlight->corona <= 0)
int n, a, style, shadow, flags;
char tempchar, *lightsstring, *s, *t, name[MAX_QPATH], cubemapname[MAX_QPATH];
float origin[3], radius, color[3], angles[3], corona, coronasizescale, ambientscale, diffusescale, specularscale;
- if (r_refdef.worldmodel == NULL)
+ if (r_refdef.scene.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
- FS_StripExtension (r_refdef.worldmodel->name, name, sizeof (name));
+ FS_StripExtension (r_refdef.scene.worldmodel->name, name, sizeof (name));
strlcat (name, ".rtlights", sizeof (name));
lightsstring = (char *)FS_LoadFile(name, tempmempool, false, NULL);
if (lightsstring)
char line[MAX_INPUTLINE];
if (!Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray))
return;
- if (r_refdef.worldmodel == NULL)
+ if (r_refdef.scene.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
- FS_StripExtension (r_refdef.worldmodel->name, name, sizeof (name));
+ FS_StripExtension (r_refdef.scene.worldmodel->name, name, sizeof (name));
strlcat (name, ".rtlights", sizeof (name));
bufchars = bufmaxchars = 0;
buf = NULL;
int n, a, style;
char tempchar, *lightsstring, *s, *t, name[MAX_QPATH];
float origin[3], radius, color[3], subtract, spotdir[3], spotcone, falloff, distbias;
- if (r_refdef.worldmodel == NULL)
+ if (r_refdef.scene.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
- FS_StripExtension (r_refdef.worldmodel->name, name, sizeof (name));
+ FS_StripExtension (r_refdef.scene.worldmodel->name, name, sizeof (name));
strlcat (name, ".lights", sizeof (name));
lightsstring = (char *)FS_LoadFile(name, tempmempool, false, NULL);
if (lightsstring)
float origin[3], angles[3], radius, color[3], light[4], fadescale, lightscale, originhack[3], overridecolor[3], vec[4];
char key[256], value[MAX_INPUTLINE];
- if (r_refdef.worldmodel == NULL)
+ if (r_refdef.scene.worldmodel == NULL)
{
Con_Print("No map loaded.\n");
return;
}
// try to load a .ent file first
- FS_StripExtension (r_refdef.worldmodel->name, key, sizeof (key));
+ FS_StripExtension (r_refdef.scene.worldmodel->name, key, sizeof (key));
strlcat (key, ".ent", sizeof (key));
data = entfiledata = (char *)FS_LoadFile(key, tempmempool, true, NULL);
// and if that is not found, fall back to the bsp file entity string
if (!data)
- data = r_refdef.worldmodel->brush.entities;
+ data = r_refdef.scene.worldmodel->brush.entities;
if (!data)
return;
for (entnum = 0;COM_ParseToken_Simple(&data, false, false) && com_token[0] == '{';entnum++)
pflags = (int)atof(value);
else if (!strcmp("effects", key))
effects = (int)atof(value);
- else if (r_refdef.worldmodel->type == mod_brushq3)
+ else if (r_refdef.scene.worldmodel->type == mod_brushq3)
{
if (!strcmp("scale", key))
lightscale = atof(value);
void R_Shadow_EditLights_Reload_f(void)
{
- if (!r_refdef.worldmodel)
+ if (!r_refdef.scene.worldmodel)
return;
- strlcpy(r_shadow_mapname, r_refdef.worldmodel->name, sizeof(r_shadow_mapname));
+ strlcpy(r_shadow_mapname, r_refdef.scene.worldmodel->name, sizeof(r_shadow_mapname));
R_Shadow_ClearWorldLights();
R_Shadow_LoadWorldLights();
if (!Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray))
void R_Shadow_EditLights_Save_f(void)
{
- if (!r_refdef.worldmodel)
+ if (!r_refdef.scene.worldmodel)
return;
R_Shadow_SaveWorldLights();
}
VectorClear(diffusecolor);
VectorClear(diffusenormal);
- if (!r_fullbright.integer && r_refdef.worldmodel && r_refdef.worldmodel->brush.LightPoint)
+ if (!r_fullbright.integer && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.LightPoint)
{
ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_ambient.value * (2.0f / 128.0f);
- r_refdef.worldmodel->brush.LightPoint(r_refdef.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
+ r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
}
else
VectorSet(ambientcolor, 1, 1, 1);
int i;
float f, v[3];
rtlight_t *light;
- for (i = 0;i < r_refdef.numlights;i++)
+ for (i = 0;i < r_refdef.scene.numlights;i++)
{
- light = &r_refdef.lights[i];
+ light = &r_refdef.scene.lights[i];
Matrix4x4_Transform(&light->matrix_worldtolight, p, v);
f = 1 - VectorLength2(v);
if (f > 0 && CL_Move(p, vec3_origin, vec3_origin, light->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1)
{
if (skyboxside[0] || skyboxside[1] || skyboxside[2] || skyboxside[3] || skyboxside[4] || skyboxside[5])
skyrenderbox = true;
- else if (r_refdef.worldmodel && r_refdef.worldmodel->brush.solidskytexture)
+ else if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.solidskytexture)
skyrendersphere = true;
// for depth-masked sky, render the sky on the first sky surface encountered
skyrendernow = true;
// wrap the scroll values just to be extra kind to float accuracy
// scroll speed for upper layer
- speedscale = r_refdef.time*r_skyscroll1.value*8.0/128.0;
+ speedscale = r_refdef.scene.time*r_skyscroll1.value*8.0/128.0;
speedscale -= (int)speedscale;
Matrix4x4_CreateTranslate(&scroll1matrix, speedscale, speedscale, 0);
// scroll speed for lower layer (transparent layer)
- speedscale = r_refdef.time*r_skyscroll2.value*8.0/128.0;
+ speedscale = r_refdef.scene.time*r_skyscroll2.value*8.0/128.0;
speedscale -= (int)speedscale;
Matrix4x4_CreateTranslate(&scroll2matrix, speedscale, speedscale, 0);
R_Mesh_VertexPointer(skysphere_vertex3f, 0, 0);
R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
- R_Mesh_TexBind(0, R_GetTexture(r_refdef.worldmodel->brush.solidskytexture));
+ R_Mesh_TexBind(0, R_GetTexture(r_refdef.scene.worldmodel->brush.solidskytexture));
R_Mesh_TexCoordPointer(0, 2, skysphere_texcoord2f, 0, 0);
R_Mesh_TexMatrix(0, &scroll1matrix);
if (r_textureunits.integer >= 2 && r_refdef.view.colorscale == 1)
{
// one pass using GL_DECAL or GL_INTERPOLATE_ARB for alpha layer
- R_Mesh_TexBind(1, R_GetTexture(r_refdef.worldmodel->brush.alphaskytexture));
+ R_Mesh_TexBind(1, R_GetTexture(r_refdef.scene.worldmodel->brush.alphaskytexture));
R_Mesh_TexCombine(1, gl_combine.integer ? GL_INTERPOLATE_ARB : GL_DECAL, GL_MODULATE, 1, 1);
R_Mesh_TexCoordPointer(1, 2, skysphere_texcoord2f, 0, 0);
R_Mesh_TexMatrix(1, &scroll2matrix);
R_Mesh_Draw(0, skysphere_numverts, skysphere_numtriangles, skysphere_element3i, 0, 0);
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- R_Mesh_TexBind(0, R_GetTexture(r_refdef.worldmodel->brush.alphaskytexture));
+ R_Mesh_TexBind(0, R_GetTexture(r_refdef.scene.worldmodel->brush.alphaskytexture));
R_Mesh_TexMatrix(0, &scroll2matrix);
GL_LockArrays(0, skysphere_numverts);
R_Mesh_Draw(0, skysphere_numverts, skysphere_numtriangles, skysphere_element3i, 0, 0);