mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Try #2.
Change r_maxparticles from short to unsigned int. Make MAX_DLIGHTS into a cvar, r_dlight_max that sets the unsigned int r_maxdlights.
This commit is contained in:
parent
70d4510b28
commit
9cc671e6d2
13 changed files with 57 additions and 34 deletions
|
@ -36,8 +36,6 @@
|
|||
|
||||
// dynamic lights ===========================================================
|
||||
|
||||
#define MAX_DLIGHTS 32
|
||||
|
||||
typedef struct dlight_s
|
||||
{
|
||||
int key; // so entities can reuse same entry
|
||||
|
@ -49,9 +47,10 @@ typedef struct dlight_s
|
|||
float color[3]; // Don't use alpha --KB
|
||||
} dlight_t;
|
||||
|
||||
extern dlight_t r_dlights[MAX_DLIGHTS];
|
||||
extern dlight_t *r_dlights;
|
||||
extern unsigned int r_maxdlights;
|
||||
|
||||
// FIXME client_state_t should hold all pieces of the client state
|
||||
// FIXME: client_state_t should hold all pieces of the client state
|
||||
typedef struct
|
||||
{
|
||||
int length;
|
||||
|
@ -60,7 +59,7 @@ typedef struct
|
|||
|
||||
extern lightstyle_t r_lightstyle[MAX_LIGHTSTYLES];
|
||||
|
||||
// FIXME lightstyle_t and r_lightstyle were in client.h, is this the best place for them?
|
||||
// FIXME: lightstyle_t and r_lightstyle were in client.h, is this the best place for them?
|
||||
|
||||
//===============
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ R_RenderDlights (void)
|
|||
qfglShadeModel (GL_SMOOTH);
|
||||
|
||||
l = r_dlights;
|
||||
for (i = 0; i < MAX_DLIGHTS; i++, l++) {
|
||||
for (i = 0; i < r_maxdlights; i++, l++) {
|
||||
if (l->die < r_realtime || !l->radius)
|
||||
continue;
|
||||
R_RenderDlight (l);
|
||||
|
|
|
@ -48,6 +48,7 @@ static const char rcsid[] =
|
|||
#include "QF/vfs.h"
|
||||
#include "QF/GL/defines.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
#include "QF/GL/qf_explosions.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "r_cvar.h"
|
||||
|
@ -58,7 +59,7 @@ static const char rcsid[] =
|
|||
int ramp[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
|
||||
extern int part_tex_dot, part_tex_smoke, part_tex_spark;
|
||||
extern short r_maxparticles, numparticles;
|
||||
extern unsigned int r_maxparticles, numparticles;
|
||||
extern particle_t *particles, **freeparticles;
|
||||
|
||||
|
||||
|
@ -169,7 +170,9 @@ R_ParticleExplosion (vec3_t org)
|
|||
{
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
/*
|
||||
R_NewExplosion (org);
|
||||
*/
|
||||
particle_new_random (pt_smokecloud, part_tex_smoke, org, 4,
|
||||
30, 8, r_realtime + 5, (rand () & 7) + 8,
|
||||
128 + (rand () & 63));
|
||||
|
|
|
@ -194,7 +194,7 @@ R_DrawSpriteModel (entity_t *e)
|
|||
AngleVectors (currententity->angles, v_forward, v_right, v_up);
|
||||
up = v_up;
|
||||
right = v_right;
|
||||
} else { // normal sprite
|
||||
} else { // normal sprite
|
||||
up = vup;
|
||||
right = vright;
|
||||
}
|
||||
|
@ -298,7 +298,6 @@ GL_DrawAliasFrame (vert_order_t *vo, qboolean fb)
|
|||
|
||||
if (modelalpha != 1.0)
|
||||
qfglDepthMask (GL_TRUE);
|
||||
|
||||
}
|
||||
|
||||
extern vec3_t lightspot;
|
||||
|
@ -575,7 +574,7 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
if (e == r_view_model)
|
||||
shadelight = max (shadelight, 24);
|
||||
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
if (r_dlights[lnum].die >= r_realtime) {
|
||||
VectorSubtract (currententity->origin, r_dlights[lnum].origin,
|
||||
dist);
|
||||
|
@ -828,17 +827,14 @@ static void
|
|||
R_SetFrustum (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (r_refdef.fov_x == 90) {
|
||||
// front side is visible
|
||||
|
||||
VectorAdd (vpn, vright, frustum[0].normal);
|
||||
VectorSubtract (vpn, vright, frustum[1].normal);
|
||||
|
||||
VectorAdd (vpn, vup, frustum[2].normal);
|
||||
VectorSubtract (vpn, vup, frustum[3].normal);
|
||||
} else {
|
||||
|
||||
// rotate VPN right by FOV_X/2 degrees
|
||||
RotatePointAroundVector (frustum[0].normal, vup, vpn,
|
||||
-(90 - r_refdef.fov_x / 2));
|
||||
|
|
|
@ -147,7 +147,7 @@ R_AddDynamicLights (msurface_t *surf)
|
|||
smax = (surf->extents[0] >> 4) + 1;
|
||||
tmax = (surf->extents[1] >> 4) + 1;
|
||||
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
if (!(surf->dlightbits & (1 << lnum)))
|
||||
continue; // not lit by this light
|
||||
|
||||
|
@ -236,7 +236,7 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
|
|||
|
||||
// add all the lightmaps
|
||||
if (lightmap) {
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||
for (maps = 0; maps < r_maxdlights && surf->styles[maps] != 255;
|
||||
maps++) {
|
||||
scale = d_lightstylevalue[surf->styles[maps]];
|
||||
surf->cached_light[maps] = scale; // 8.8 fraction
|
||||
|
@ -676,7 +676,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
if (clmodel->firstmodelsurface != 0 && r_dlight_lightmap->int_val) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < MAX_DLIGHTS; k++) {
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
if ((r_dlights[k].die < r_realtime) || (!r_dlights[k].radius))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ cvar_t *r_aliastransbase;
|
|||
cvar_t *r_ambient;
|
||||
cvar_t *r_clearcolor;
|
||||
cvar_t *r_dlight_lightmap;
|
||||
cvar_t *r_dlight_max;
|
||||
cvar_t *r_drawentities;
|
||||
cvar_t *r_drawexplosions; // DESPAIR
|
||||
cvar_t *r_drawflat;
|
||||
|
@ -128,10 +129,11 @@ cvar_t *scr_showram;
|
|||
cvar_t *scr_showturtle;
|
||||
cvar_t *scr_viewsize;
|
||||
|
||||
extern short r_maxparticles;
|
||||
extern cvar_t *gl_sky_divide; // FIXME
|
||||
extern unsigned int r_maxparticles;
|
||||
extern cvar_t *gl_sky_divide; // FIXME
|
||||
|
||||
extern void R_MaxParticlesCheck (cvar_t *var);
|
||||
extern void R_MaxDlightsCheck (cvar_t *var);
|
||||
|
||||
|
||||
static void
|
||||
|
@ -257,6 +259,8 @@ R_Init_Cvars (void)
|
|||
r_dlight_lightmap = Cvar_Get ("r_dlight_lightmap", "1", CVAR_ARCHIVE,
|
||||
NULL, "Set to 1 for high quality dynamic "
|
||||
"lighting.");
|
||||
r_dlight_max = Cvar_Get ("r_dlight_max", "32", CVAR_ARCHIVE,
|
||||
R_MaxDlightsCheck, "Number of dynamic lights.");
|
||||
r_drawentities = Cvar_Get ("r_drawentities", "1", CVAR_NONE, NULL,
|
||||
"Toggles drawing of entities (almost "
|
||||
"everything but the world)");
|
||||
|
|
|
@ -43,13 +43,34 @@ static const char rcsid[] =
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/render.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "r_cvar.h"
|
||||
#include "r_local.h"
|
||||
#include "r_shared.h"
|
||||
|
||||
dlight_t r_dlights[MAX_DLIGHTS];
|
||||
dlight_t *r_dlights;
|
||||
lightstyle_t r_lightstyle[MAX_LIGHTSTYLES];
|
||||
|
||||
unsigned int r_maxdlights;
|
||||
|
||||
|
||||
void
|
||||
R_MaxDlightsCheck (cvar_t *var)
|
||||
{
|
||||
// FIXME: 1 minimum should be 0, if it doesn't require excess testing in
|
||||
// *_rsurf.c
|
||||
if (r_dynamic)
|
||||
r_maxdlights = max(var->int_val * r_dynamic->int_val, 1);
|
||||
else
|
||||
r_maxdlights = max(var->int_val, 1);
|
||||
|
||||
free (r_dlights);
|
||||
|
||||
r_dlights = (dlight_t *) calloc (r_maxdlights, sizeof (dlight_t));
|
||||
|
||||
R_ClearDlights();
|
||||
}
|
||||
|
||||
void
|
||||
R_AnimateLight (void)
|
||||
{
|
||||
|
@ -283,7 +304,7 @@ R_PushDlights (vec3_t entorigin)
|
|||
|
||||
l = r_dlights;
|
||||
|
||||
for (i = 0; i < MAX_DLIGHTS; i++, l++) {
|
||||
for (i = 0; i < r_maxdlights; i++, l++) {
|
||||
if (l->die < r_realtime || !l->radius)
|
||||
continue;
|
||||
VectorSubtract (l->origin, entorigin, lightorigin);
|
||||
|
@ -416,7 +437,7 @@ R_AllocDlight (int key)
|
|||
// first look for an exact key match
|
||||
if (key) {
|
||||
dl = r_dlights;
|
||||
for (i = 0; i < MAX_DLIGHTS; i++, dl++) {
|
||||
for (i = 0; i < r_maxdlights; i++, dl++) {
|
||||
if (dl->key == key) {
|
||||
memset (dl, 0, sizeof (*dl));
|
||||
dl->key = key;
|
||||
|
@ -427,7 +448,7 @@ R_AllocDlight (int key)
|
|||
}
|
||||
// then look for anything else
|
||||
dl = r_dlights;
|
||||
for (i = 0; i < MAX_DLIGHTS; i++, dl++) {
|
||||
for (i = 0; i < r_maxdlights; i++, dl++) {
|
||||
if (dl->die < r_realtime) {
|
||||
memset (dl, 0, sizeof (*dl));
|
||||
dl->key = key;
|
||||
|
@ -449,7 +470,7 @@ R_DecayLights (double frametime)
|
|||
dlight_t *dl;
|
||||
|
||||
dl = r_dlights;
|
||||
for (i = 0; i < MAX_DLIGHTS; i++, dl++) {
|
||||
for (i = 0; i < r_maxdlights; i++, dl++) {
|
||||
if (dl->die < r_realtime || !dl->radius)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ R_DrawEntitiesOnList (void)
|
|||
|
||||
lighting.plightvec = lightvec;
|
||||
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
if (r_dlights[lnum].die >= r_realtime) {
|
||||
VectorSubtract (currententity->origin,
|
||||
r_dlights[lnum].origin, dist);
|
||||
|
@ -581,7 +581,7 @@ R_DrawViewModel (void)
|
|||
r_viewlighting.shadelight = j;
|
||||
|
||||
// add dynamic lights
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
dl = &r_dlights[lnum];
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
@ -708,7 +708,7 @@ R_DrawBEntitiesOnList (void)
|
|||
if (clmodel->firstmodelsurface != 0) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < MAX_DLIGHTS; k++) {
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
if ((r_dlights[k].die < r_realtime) ||
|
||||
(!r_dlights[k].radius)) continue;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
|
|||
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
|
||||
extern short r_maxparticles;
|
||||
extern unsigned int r_maxparticles;
|
||||
extern particle_t *active_particles, *free_particles, *particles;
|
||||
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ R_AddDynamicLights (void)
|
|||
tmax = (surf->extents[1] >> 4) + 1;
|
||||
tex = surf->texinfo;
|
||||
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
if (!(surf->dlightbits & (1 << lnum)))
|
||||
continue; // not lit by this light
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ R_DrawEntitiesOnList (void)
|
|||
|
||||
lighting.plightvec = lightvec;
|
||||
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
if (r_dlights[lnum].die >= r_realtime) {
|
||||
VectorSubtract (currententity->origin,
|
||||
r_dlights[lnum].origin, dist);
|
||||
|
@ -609,7 +609,7 @@ R_DrawViewModel (void)
|
|||
r_viewlighting.shadelight = j;
|
||||
|
||||
// add dynamic lights
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
dl = &r_dlights[lnum];
|
||||
if (!dl->radius)
|
||||
continue;
|
||||
|
@ -736,7 +736,7 @@ R_DrawBEntitiesOnList (void)
|
|||
if (clmodel->firstmodelsurface != 0) {
|
||||
vec3_t lightorigin;
|
||||
|
||||
for (k = 0; k < MAX_DLIGHTS; k++) {
|
||||
for (k = 0; k < r_maxdlights; k++) {
|
||||
if ((r_dlights[k].die < r_realtime) ||
|
||||
(!r_dlights[k].radius)) continue;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
|
|||
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
|
||||
extern short r_maxparticles;
|
||||
extern unsigned int r_maxparticles;
|
||||
extern particle_t *active_particles, *free_particles, *particles;
|
||||
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ R_AddDynamicLights (void)
|
|||
tmax = (surf->extents[1] >> 4) + 1;
|
||||
tex = surf->texinfo;
|
||||
|
||||
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||
if (!(surf->dlightbits & (1 << lnum)))
|
||||
continue; // not lit by this light
|
||||
|
||||
|
|
Loading…
Reference in a new issue