diff --git a/libs/video/renderer/gl/gl_dyn_fires.c b/libs/video/renderer/gl/gl_dyn_fires.c index b259c2c29..1dbcdcc86 100644 --- a/libs/video/renderer/gl/gl_dyn_fires.c +++ b/libs/video/renderer/gl/gl_dyn_fires.c @@ -52,9 +52,10 @@ static const char rcsid[] = #include "r_shared.h" #include "view.h" +fire_t r_fires[MAX_FIRES]; -void +static void AddLightBlend (float r, float g, float b, float a2) { float a; @@ -68,12 +69,81 @@ AddLightBlend (float r, float g, float b, float a2) v_blend[2] = v_blend[2] * (1 - a2) + b * a2; } +/* + R_AddFire + + Buggy GL fire trail effect. A meshing of polyblend dlights and + particle engine. +*/ +void +R_AddFire (vec3_t start, vec3_t end, entity_t *ent) +{ + float len; + int key; + fire_t *f; + vec3_t vec; + + if (!gl_fires->int_val) + return; + + VectorSubtract (end, start, vec); + len = VectorNormalize (vec); + key = ent->keynum; + + if (len) { + f = R_AllocFire (key); + VectorCopy (end, f->origin); + VectorCopy (start, f->owner); + f->size = 10; + f->die = r_realtime + 0.5; + f->decay = 1; + VectorCopy (r_firecolor->vec, f->color); + } +} + +/* + R_AllocFire + + Clears out and returns a new fireball +*/ +fire_t * +R_AllocFire (int key) +{ + int i; + fire_t *f; + + if (key) // first, try to find/reuse a keyed spot + { + f = r_fires; + for (i = 0; i < MAX_FIRES; i++, f++) + if (f->key == key) { + memset (f, 0, sizeof (*f)); + f->key = key; + return f; + } + } + + f = r_fires; // no match, look for a free spot + for (i = 0; i < MAX_FIRES; i++, f++) { + if (f->die < r_realtime) { + memset (f, 0, sizeof (*f)); + f->key = key; + return f; + } + } + + f = &r_fires[0]; + memset (f, 0, sizeof (*f)); + f->key = key; + return f; +} + /* R_DrawFire draws one fireball - probably never need to call this directly */ -void +static void R_DrawFire (fire_t *f) { float radius; @@ -149,3 +219,10 @@ R_UpdateFires (void) qfglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qfglDepthMask (GL_TRUE); } + +void +R_ClearFires (void) +{ + memset (r_fires, 0, sizeof (r_fires)); +} + diff --git a/libs/video/renderer/gl/gl_dyn_part.c b/libs/video/renderer/gl/gl_dyn_part.c index 7dc57cc82..c7dd96e21 100644 --- a/libs/video/renderer/gl/gl_dyn_part.c +++ b/libs/video/renderer/gl/gl_dyn_part.c @@ -111,6 +111,12 @@ inline void R_ClearParticles (void) { numparticles = 0; + + /* + FIXME: this is better than doing it in the client, and having gl-only + code in the renderer common area, but this is still the wrong place. + */ + R_ClearFires (); } void @@ -408,7 +414,7 @@ void R_RocketTrail (entity_t *ent) { float dist, maxlen, origlen, percent, pscale, pscalenext; - float len = 0; + float len = 0.0; vec3_t subtract, vec; if (numparticles >= r_maxparticles) @@ -446,7 +452,7 @@ void R_GrenadeTrail (entity_t *ent) { float dist, maxlen, origlen, percent, pscale, pscalenext; - float len = 0; + float len = 0.0; vec3_t subtract, vec; if (numparticles >= r_maxparticles) @@ -467,8 +473,8 @@ R_GrenadeTrail (entity_t *ent) particle_new (pt_smoke, part_tex_smoke, ent->old_origin, pscale + percent * 4.0, vec3_origin, - r_realtime + 2.0 - percent * 2.0, - (rand () & 3), + r_realtime + 2.0 - percent * 2.0, + 1 + (rand () & 3), 160 + (rand () & 31) - percent * 100.0); if (numparticles >= r_maxparticles) break; @@ -481,7 +487,7 @@ void R_BloodTrail (entity_t *ent) { float dist, maxlen, origlen, percent, pscale, pscalenext; - float len = 0; + float len = 0.0; int j; vec3_t subtract, vec, porg, pvel; @@ -566,8 +572,8 @@ R_SlightBloodTrail (entity_t *ent) void R_GreenTrail (entity_t *ent) { - float dist, maxlen, origlen, percent; - float len = 0; + float maxlen, origlen, percent; + float dist = 3.0, len = 0.0; static int tracercount; vec3_t subtract, vec, pvel; @@ -577,17 +583,16 @@ R_GreenTrail (entity_t *ent) VectorSubtract (ent->origin, ent->old_origin, vec); maxlen = VectorNormalize (vec); origlen = r_frametime / maxlen; - dist = 3.0; while (len < maxlen) { VectorCopy (vec3_origin, pvel); tracercount++; if (tracercount & 1) { - pvel[0] = 30 * vec[1]; - pvel[1] = 30 * -vec[0]; + pvel[0] = 30.0 * vec[1]; + pvel[1] = 30.0 * -vec[0]; } else { - pvel[0] = 30 * -vec[1]; - pvel[1] = 30 * vec[0]; + pvel[0] = 30.0 * -vec[1]; + pvel[1] = 30.0 * vec[0]; } VectorScale (vec, min(dist, len), subtract); @@ -607,8 +612,8 @@ R_GreenTrail (entity_t *ent) void R_FlameTrail (entity_t *ent) { - float dist, maxlen, origlen, percent; - float len = 0; + float maxlen, origlen, percent; + float dist = 3.0, len = 0.0; static int tracercount; vec3_t subtract, vec, pvel; @@ -618,17 +623,16 @@ R_FlameTrail (entity_t *ent) VectorSubtract (ent->origin, ent->old_origin, vec); maxlen = VectorNormalize (vec); origlen = r_frametime / maxlen; - dist = 3.0; while (len < maxlen) { VectorCopy (vec3_origin, pvel); tracercount++; if (tracercount & 1) { - pvel[0] = 30 * vec[1]; - pvel[1] = 30 * -vec[0]; + pvel[0] = 30.0 * vec[1]; + pvel[1] = 30.0 * -vec[0]; } else { - pvel[0] = 30 * -vec[1]; - pvel[1] = 30 * vec[0]; + pvel[0] = 30.0 * -vec[1]; + pvel[1] = 30.0 * vec[0]; } VectorScale (vec, min(dist, len), subtract); @@ -648,8 +652,8 @@ R_FlameTrail (entity_t *ent) void R_VoorTrail (entity_t *ent) { - float dist, maxlen, origlen, percent; - float len = 0; + float maxlen, origlen, percent; + float dist = 3.0, len = 0.0; int j; vec3_t subtract, vec, porg; @@ -659,7 +663,6 @@ R_VoorTrail (entity_t *ent) VectorSubtract (ent->origin, ent->old_origin, vec); maxlen = VectorNormalize (vec); origlen = r_frametime / maxlen; - dist = 3.0; while (len < maxlen) { for (j = 0; j < 3; j++) @@ -681,7 +684,6 @@ R_VoorTrail (entity_t *ent) void R_DrawParticles (void) { -// byte i; unsigned char *at; float dvel, grav, fast_grav, minparticledist, scale, bloodcloud_alpha, bloodcloud_scale, fallfadespark_alpha, diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 2a137de1d..9a6f46a90 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -439,6 +439,7 @@ R_Mirror (void) qfglDepthRange (gldepthmin, gldepthmax); R_RenderScene (); + R_DrawWaterSurfaces (); gldepthmin = 0; gldepthmax = 1; @@ -484,6 +485,7 @@ R_RenderView (void) // render normal view R_RenderScene (); R_DrawViewModel (); + R_DrawWaterSurfaces (); R_UpdateFires (); R_DrawParticles (); diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index ac941f8f1..7a42cf54e 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -782,10 +782,10 @@ R_RecursiveWorldNode (mnode_t *node) continue; // wrong side if (surf->flags & SURF_DRAWTURB) { - if (r_wateralpha->value < 1.0) +// if (r_wateralpha->value < 1.0) // FIXME: DESPAIR CHAIN_SURF_B2F (surf, waterchain); - else - CHAIN_SURF (surf, waterchain); +// else +// CHAIN_SURF (surf, waterchain); } else if (surf->flags & SURF_DRAWSKY) { CHAIN_SURF (surf, sky_chain); } else if (gl_mtex_active) { @@ -824,9 +824,6 @@ R_DrawWorld (void) R_DrawSkyChain (sky_chain); - if (r_wateralpha->value >= 1.0) - R_DrawWaterSurfaces (); - DrawTextureChains (); if (!gl_mtex_active) @@ -834,9 +831,6 @@ R_DrawWorld (void) if (gl_fb_bmodels->int_val) R_RenderFullbrights (); - - if (r_wateralpha->value < 1.0) - R_DrawWaterSurfaces (); } void diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index bf2a683f7..302681650 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -150,8 +150,6 @@ int scr_erase_lines; int scr_erase_center; - - /* SCR_CenterPrint @@ -235,7 +233,7 @@ SCR_CheckDrawCenterString (int swap) SCR_DrawCenterString (); } -float +static float CalcFov (float fov_x, float width, float height) { float a, x; diff --git a/libs/video/renderer/r_main.c b/libs/video/renderer/r_main.c index 55a2c121e..2d6e90598 100644 --- a/libs/video/renderer/r_main.c +++ b/libs/video/renderer/r_main.c @@ -45,8 +45,6 @@ static const char rcsid[] = #include "QF/render.h" #include "r_cvar.h" -#include "r_dynamic.h" -#include "r_local.h" qboolean r_inhibit_viewmodel; qboolean r_force_fullscreen; @@ -55,88 +53,9 @@ double r_realtime; double r_frametime; entity_t *r_view_model; entity_t *r_player_entity; +float r_time1; int r_lineadj; qboolean r_active; -float r_time1; byte color_white[4] = { 255, 255, 255, 0 }; // alpha will be explicitly set byte color_black[4] = { 0, 0, 0, 0 }; // alpha will be explicitly set - -fire_t r_fires[MAX_FIRES]; - - -void -R_ClearFires (void) -{ - memset (r_fires, 0, sizeof (r_fires)); -} - -/* - R_AddFire - - Nifty ball of fire GL effect. Kinda a meshing of the dlight and - particle engine code. -*/ -void -R_AddFire (vec3_t start, vec3_t end, entity_t *ent) -{ - float len; - fire_t *f; - vec3_t vec; - int key; - - if (!gl_fires->int_val) - return; - - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); - key = ent->keynum; - - if (len) { - f = R_AllocFire (key); - VectorCopy (end, f->origin); - VectorCopy (start, f->owner); - f->size = 10; - f->die = r_realtime + 0.5; - f->decay = 1; - VectorCopy (r_firecolor->vec, f->color); - } -} - -/* - R_AllocFire - - Clears out and returns a new fireball -*/ -fire_t * -R_AllocFire (int key) -{ - int i; - fire_t *f; - - if (key) // first try to find/reuse a keyed - // spot - { - f = r_fires; - for (i = 0; i < MAX_FIRES; i++, f++) - if (f->key == key) { - memset (f, 0, sizeof (*f)); - f->key = key; - return f; - } - } - - f = r_fires; // no match, look for a free spot - for (i = 0; i < MAX_FIRES; i++, f++) { - if (f->die < r_realtime) { - memset (f, 0, sizeof (*f)); - f->key = key; - return f; - } - } - - f = &r_fires[0]; - memset (f, 0, sizeof (*f)); - f->key = key; - return f; -} diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index e96b5e160..5cc42354d 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -176,7 +176,7 @@ CL_ClearState (void) R_ClearEfrags (); R_ClearDlights (); - R_ClearFires (); + R_ClearParticles (); // FIXME: for R_ClearFires for (i = 0; i < MAX_EDICTS; i++) { cl_entities[i].baseline = &cl_baselines[i]; diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 0cdf03e34..84a1dfd56 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -419,7 +419,7 @@ CL_ClearState (void) R_ClearEfrags (); R_ClearDlights (); - R_ClearFires (); + R_ClearParticles (); // FIXME: for R_ClearFires in GL // wipe the entire cl structure Info_Destroy (cl.serverinfo); @@ -1528,7 +1528,7 @@ Host_Frame (float time) pass1 + pass2 + pass3, pass1, pass2, pass3); } - CL_TimeFrames_AddTimestamp (); +// CL_TimeFrames_AddTimestamp (); host_framecount++; fps_count++;