- removed more r_ header dependencies from the rest of the code.

SVN r3260 (trunk)
This commit is contained in:
Christoph Oelckers 2011-07-06 15:31:05 +00:00
parent 163301dcd5
commit 463c276014
36 changed files with 271 additions and 266 deletions

View file

@ -15,7 +15,6 @@
#include "g_game.h" #include "g_game.h"
#include "m_random.h" #include "m_random.h"
#include "r_sky.h" #include "r_sky.h"
#include "r_main.h"
#include "st_stuff.h" #include "st_stuff.h"
#include "stats.h" #include "stats.h"
#include "i_system.h" #include "i_system.h"

View file

@ -12,7 +12,6 @@
#include "g_game.h" #include "g_game.h"
#include "d_ticcmd.h" #include "d_ticcmd.h"
#include "m_random.h" #include "m_random.h"
#include "r_main.h"
#include "i_system.h" #include "i_system.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "gi.h" #include "gi.h"

View file

@ -14,7 +14,6 @@
#include "b_bot.h" #include "b_bot.h"
#include "g_game.h" #include "g_game.h"
#include "m_random.h" #include "m_random.h"
#include "r_main.h"
#include "stats.h" #include "stats.h"
#include "a_pickups.h" #include "a_pickups.h"
#include "statnums.h" #include "statnums.h"

View file

@ -61,7 +61,6 @@
#include "gi.h" #include "gi.h"
#include "r_defs.h" #include "r_defs.h"
#include "d_player.h" #include "d_player.h"
#include "r_main.h"
#include "templates.h" #include "templates.h"
#include "p_local.h" #include "p_local.h"
#include "r_sky.h" #include "r_sky.h"
@ -663,32 +662,6 @@ CCMD (fov)
Net_WriteByte (clamp (atoi (argv[1]), 5, 179)); Net_WriteByte (clamp (atoi (argv[1]), 5, 179));
} }
//==========================================================================
//
// CCMD r_visibility
//
// Controls how quickly light ramps across a 1/z range. Set this, and it
// sets all the r_*Visibility variables (except r_SkyVisibilily, which is
// currently unused).
//
//==========================================================================
CCMD (r_visibility)
{
if (argv.argc() < 2)
{
Printf ("Visibility is %g\n", R_GetVisibility());
}
else if (!netgame)
{
R_SetVisibility ((float)atof (argv[1]));
}
else
{
Printf ("Visibility cannot be changed in net games.\n");
}
}
//========================================================================== //==========================================================================
// //
// CCMD warp // CCMD warp

View file

@ -53,7 +53,6 @@
#include "v_video.h" #include "v_video.h"
#include "v_text.h" #include "v_text.h"
#include "w_wad.h" #include "w_wad.h"
#include "r_main.h"
#include "sbar.h" #include "sbar.h"
#include "s_sound.h" #include "s_sound.h"
#include "s_sndseq.h" #include "s_sndseq.h"
@ -64,6 +63,7 @@
#include "d_net.h" #include "d_net.h"
#include "g_level.h" #include "g_level.h"
#include "d_event.h" #include "d_event.h"
#include "d_player.h"
#include "gi.h" #include "gi.h"

View file

@ -77,6 +77,7 @@
#include "d_event.h" #include "d_event.h"
#include "p_acs.h" #include "p_acs.h"
#include "m_joy.h" #include "m_joy.h"
#include "farchive.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include <zlib.h> #include <zlib.h>

View file

@ -35,7 +35,6 @@
#include "actor.h" #include "actor.h"
#include "info.h" #include "info.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "r_main.h"
#include "p_local.h" #include "p_local.h"
#include "farchive.h" #include "farchive.h"

View file

@ -34,13 +34,13 @@
*/ */
#include "r_defs.h" #include "r_defs.h"
#include "r_main.h"
#include "m_random.h" #include "m_random.h"
#include "d_player.h" #include "d_player.h"
#include "d_event.h" #include "d_event.h"
#include "sbar.h" #include "sbar.h"
#include "sbarinfo.h" #include "sbarinfo.h"
#include "templates.h" #include "templates.h"
#include "r_utility.h"
#define ST_RAMPAGEDELAY (2*TICRATE) #define ST_RAMPAGEDELAY (2*TICRATE)
#define ST_MUCHPAIN 20 #define ST_MUCHPAIN 20

View file

@ -51,7 +51,6 @@
#include "sbarinfo.h" #include "sbarinfo.h"
#include "gi.h" #include "gi.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "r_main.h"
#include "a_weaponpiece.h" #include "a_weaponpiece.h"
#include "a_strifeglobal.h" #include "a_strifeglobal.h"
#include "g_level.h" #include "g_level.h"

View file

@ -48,10 +48,11 @@
#include "v_video.h" #include "v_video.h"
#include "hu_stuff.h" #include "hu_stuff.h"
#include "gi.h" #include "gi.h"
#include "v_palette.h"
#include "i_input.h" #include "i_input.h"
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "gstrings.h" #include "gstrings.h"
#include "r_main.h" #include "r_utility.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "textures/textures.h" #include "textures/textures.h"

View file

@ -50,7 +50,7 @@
#include "tarray.h" #include "tarray.h"
#include "m_bbox.h" #include "m_bbox.h"
#include "c_console.h" #include "c_console.h"
#include "r_main.h" #include "r_state.h"
const int MaxSegs = 64; const int MaxSegs = 64;
const int SplitCost = 8; const int SplitCost = 8;

View file

@ -43,7 +43,6 @@
#include "nodebuild.h" #include "nodebuild.h"
#include "templates.h" #include "templates.h"
#include "r_main.h"
#if 0 #if 0
#define D(x) x #define D(x) x

View file

@ -39,7 +39,6 @@
#include "doomtype.h" #include "doomtype.h"
#include "nodebuild.h" #include "nodebuild.h"
#include "r_main.h"
static inline void STACK_ARGS Warn (const char *format, ...) static inline void STACK_ARGS Warn (const char *format, ...)
{ {

View file

@ -47,9 +47,9 @@
#include "nodebuild.h" #include "nodebuild.h"
#include "templates.h" #include "templates.h"
#include "m_bbox.h" #include "m_bbox.h"
#include "r_main.h"
#include "i_system.h" #include "i_system.h"
#include "po_man.h" #include "po_man.h"
#include "r_state.h"
static const int PO_LINE_START = 1; static const int PO_LINE_START = 1;
static const int PO_LINE_EXPLICIT = 5; static const int PO_LINE_EXPLICIT = 5;

View file

@ -12,7 +12,6 @@
#include "w_wad.h" #include "w_wad.h"
#include "templates.h" #include "templates.h"
#include "r_sky.h" #include "r_sky.h"
#include "r_main.h"
#include "r_defs.h" #include "r_defs.h"
#include "p_setup.h" #include "p_setup.h"
#include "g_level.h" #include "g_level.h"

View file

@ -35,7 +35,6 @@
#include <assert.h> #include <assert.h>
#include "actor.h" #include "actor.h"
#include "r_main.h"
#include "p_conversation.h" #include "p_conversation.h"
#include "w_wad.h" #include "w_wad.h"
#include "cmdlib.h" #include "cmdlib.h"
@ -60,6 +59,7 @@
#include "sbar.h" #include "sbar.h"
#include "farchive.h" #include "farchive.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "r_utility.h"
#include "menu/menu.h" #include "menu/menu.h"
// The conversations as they exist inside a SCRIPTxx lump. // The conversations as they exist inside a SCRIPTxx lump.

View file

@ -36,8 +36,10 @@
#include "doomtype.h" #include "doomtype.h"
#include "doomstat.h" #include "doomstat.h"
#include "i_system.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "actor.h" #include "actor.h"
#include "m_argv.h"
#include "p_effect.h" #include "p_effect.h"
#include "p_local.h" #include "p_local.h"
#include "g_level.h" #include "g_level.h"
@ -54,9 +56,17 @@ CVAR (Int, cl_rockettrails, 1, CVAR_ARCHIVE);
CVAR (Bool, r_rail_smartspiral, 0, CVAR_ARCHIVE); CVAR (Bool, r_rail_smartspiral, 0, CVAR_ARCHIVE);
CVAR (Int, r_rail_spiralsparsity, 1, CVAR_ARCHIVE); CVAR (Int, r_rail_spiralsparsity, 1, CVAR_ARCHIVE);
CVAR (Int, r_rail_trailsparsity, 1, CVAR_ARCHIVE); CVAR (Int, r_rail_trailsparsity, 1, CVAR_ARCHIVE);
CVAR (Bool, r_particles, true, 0);
#define FADEFROMTTL(a) (255/(a)) #define FADEFROMTTL(a) (255/(a))
// [RH] particle globals
WORD NumParticles;
WORD ActiveParticles;
WORD InactiveParticles;
particle_t *Particles;
TArray<WORD> ParticlesInSubsec;
static int grey1, grey2, grey3, grey4, red, green, blue, yellow, black, static int grey1, grey2, grey3, grey4, red, green, blue, yellow, black,
red1, green1, blue1, yellow1, purple, purple1, white, red1, green1, blue1, yellow1, purple, purple1, white,
rblue1, rblue2, rblue3, rblue4, orange, yorange, dred, grey5, rblue1, rblue2, rblue3, rblue4, orange, yorange, dred, grey5,
@ -95,10 +105,114 @@ static const struct ColorList {
{NULL, 0, 0, 0 } {NULL, 0, 0, 0 }
}; };
inline particle_t *NewParticle (void)
{
particle_t *result = NULL;
if (InactiveParticles != NO_PARTICLE)
{
result = Particles + InactiveParticles;
InactiveParticles = result->tnext;
result->tnext = ActiveParticles;
ActiveParticles = WORD(result - Particles);
}
return result;
}
//
// [RH] Particle functions
//
void P_InitParticles ();
void P_DeinitParticles ();
// [BC] Allow the maximum number of particles to be specified by a cvar (so people
// with lots of nice hardware can have lots of particles!).
CUSTOM_CVAR( Int, r_maxparticles, 4000, CVAR_ARCHIVE )
{
if ( self == 0 )
self = 4000;
else if ( self < 100 )
self = 100;
if ( gamestate != GS_STARTUP )
{
P_DeinitParticles( );
P_InitParticles( );
}
}
void P_InitParticles ()
{
const char *i;
if ((i = Args->CheckValue ("-numparticles")))
NumParticles = atoi (i);
// [BC] Use r_maxparticles now.
else
NumParticles = r_maxparticles;
// This should be good, but eh...
if ( NumParticles < 100 )
NumParticles = 100;
P_DeinitParticles();
Particles = new particle_t[NumParticles];
P_ClearParticles ();
atterm (P_DeinitParticles);
}
void P_DeinitParticles()
{
if (Particles != NULL)
{
delete[] Particles;
Particles = NULL;
}
}
void P_ClearParticles ()
{
int i;
memset (Particles, 0, NumParticles * sizeof(particle_t));
ActiveParticles = NO_PARTICLE;
InactiveParticles = 0;
for (i = 0; i < NumParticles-1; i++)
Particles[i].tnext = i + 1;
Particles[i].tnext = NO_PARTICLE;
}
// Group particles by subsectors. Because particles are always
// in motion, there is little benefit to caching this information
// from one frame to the next.
void P_FindParticleSubsectors ()
{
if (ParticlesInSubsec.Size() < (size_t)numsubsectors)
{
ParticlesInSubsec.Reserve (numsubsectors - ParticlesInSubsec.Size());
}
clearbufshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE);
if (!r_particles)
{
return;
}
for (WORD i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext)
{
subsector_t *ssec = R_PointInSubsector (Particles[i].x, Particles[i].y);
int ssnum = int(ssec-subsectors);
Particles[i].subsector = ssec;
Particles[i].snext = ParticlesInSubsec[ssnum];
ParticlesInSubsec[ssnum] = i;
}
}
void P_InitEffects () void P_InitEffects ()
{ {
const struct ColorList *color = Colors; const struct ColorList *color = Colors;
P_InitParticles();
while (color->color) while (color->color)
{ {
*(color->color) = ColorMatcher.Pick (color->r, color->g, color->b); *(color->color) = ColorMatcher.Pick (color->r, color->g, color->b);

View file

@ -49,7 +49,31 @@
#define FX_BLACKFOUNTAIN 0x00060000 #define FX_BLACKFOUNTAIN 0x00060000
#define FX_WHITEFOUNTAIN 0x00070000 #define FX_WHITEFOUNTAIN 0x00070000
struct particle_t; // [RH] Particle details
struct particle_t
{
fixed_t x,y,z;
fixed_t velx,vely,velz;
fixed_t accx,accy,accz;
BYTE ttl;
BYTE trans;
BYTE size;
BYTE fade;
int color;
WORD tnext;
WORD snext;
subsector_t * subsector;
};
extern particle_t *Particles;
extern TArray<WORD> ParticlesInSubsec;
const WORD NO_PARTICLE = 0xffff;
void P_ClearParticles ();
void P_FindParticleSubsectors ();
class AActor; class AActor;
particle_t *JitterParticle (int ttl); particle_t *JitterParticle (int ttl);

View file

@ -23,8 +23,14 @@
#ifndef __P_LOCAL__ #ifndef __P_LOCAL__
#define __P_LOCAL__ #define __P_LOCAL__
#include "doomtype.h"
#include "doomdef.h"
#include "tables.h"
#include "r_state.h"
#include "r_utility.h"
#include "d_player.h"
#ifndef __R_LOCAL__ #ifndef __R_LOCAL__
#include "r_local.h" //#include "r_local.h"
#endif #endif
#include "a_morph.h" #include "a_morph.h"

View file

@ -25,10 +25,10 @@
#include "c_cvars.h" #include "c_cvars.h"
#include "doomstat.h" #include "doomstat.h"
#include "g_level.h" #include "g_level.h"
#include "r_main.h"
#include "nodebuild.h" #include "nodebuild.h"
#include "po_man.h" #include "po_man.h"
#include "farchive.h" #include "farchive.h"
#include "r_utility.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"

View file

@ -3930,7 +3930,7 @@ void P_SetupLevel (char *lumpname, int position)
R_OldBlend = 0xffffffff; R_OldBlend = 0xffffffff;
// [RH] Remove all particles // [RH] Remove all particles
R_ClearParticles (); P_ClearParticles ();
times[17].Clock(); times[17].Clock();
// preload graphics and sounds // preload graphics and sounds

View file

@ -22,7 +22,6 @@
#include "tables.h" #include "tables.h"
#include "s_sndseq.h" #include "s_sndseq.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "r_main.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "r_data/r_interpolate.h" #include "r_data/r_interpolate.h"
#include "g_level.h" #include "g_level.h"

View file

@ -45,6 +45,7 @@
#include "r_3dfloors.h" #include "r_3dfloors.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "g_level.h" #include "g_level.h"
#include "p_effect.h"
// State. // State.
#include "doomstat.h" #include "doomstat.h"

View file

@ -35,7 +35,6 @@
#include <stddef.h> #include <stddef.h>
#include "templates.h" #include "templates.h"
#include "r_main.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "v_video.h" #include "v_video.h"
#include "g_game.h" #include "g_game.h"
@ -48,6 +47,7 @@
#include "w_wad.h" #include "w_wad.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "farchive.h" #include "farchive.h"
#include "d_player.h"
#include "gi.h" #include "gi.h"
#include "stats.h" #include "stats.h"

View file

@ -64,6 +64,7 @@ extern FPlayerSkin * skins; // [RH]
extern BYTE OtherGameSkinRemap[256]; extern BYTE OtherGameSkinRemap[256];
extern PalEntry OtherGameSkinPalette[256]; extern PalEntry OtherGameSkinPalette[256];
void R_InitSprites ();
void R_DeinitSprites ();
#endif #endif

View file

@ -39,6 +39,7 @@
#include "r_sky.h" #include "r_sky.h"
#include "st_stuff.h" #include "st_stuff.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "c_dispatch.h"
#include "v_video.h" #include "v_video.h"
#include "stats.h" #include "stats.h"
#include "i_video.h" #include "i_video.h"
@ -52,6 +53,7 @@
#include "r_3dfloors.h" #include "r_3dfloors.h"
#include "v_palette.h" #include "v_palette.h"
#include "po_man.h" #include "po_man.h"
#include "p_effect.h"
#include "st_start.h" #include "st_start.h"
#include "v_font.h" #include "v_font.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
@ -96,7 +98,6 @@ extern bool DrawFSHUD; // [RH] Defined in d_main.cpp
extern short *openings; extern short *openings;
extern bool r_fakingunderwater; extern bool r_fakingunderwater;
extern "C" int fuzzviewheight; extern "C" int fuzzviewheight;
EXTERN_CVAR (Bool, r_particles)
EXTERN_CVAR (Bool, cl_capfps) EXTERN_CVAR (Bool, cl_capfps)
// PRIVATE DATA DECLARATIONS ----------------------------------------------- // PRIVATE DATA DECLARATIONS -----------------------------------------------
@ -625,6 +626,32 @@ float R_GetVisibility ()
return CurrentVisibility; return CurrentVisibility;
} }
//==========================================================================
//
// CCMD r_visibility
//
// Controls how quickly light ramps across a 1/z range. Set this, and it
// sets all the r_*Visibility variables (except r_SkyVisibilily, which is
// currently unused).
//
//==========================================================================
CCMD (r_visibility)
{
if (argv.argc() < 2)
{
Printf ("Visibility is %g\n", R_GetVisibility());
}
else if (!netgame)
{
R_SetVisibility ((float)atof (argv[1]));
}
else
{
Printf ("Visibility cannot be changed in net games.\n");
}
}
//========================================================================== //==========================================================================
// //
// R_SetViewSize // R_SetViewSize
@ -829,7 +856,6 @@ void R_Init ()
R_InitPlanes (); R_InitPlanes ();
R_InitTranslationTables (); R_InitTranslationTables ();
R_InitShadeMaps(); R_InitShadeMaps();
R_InitParticles (); // [RH] Setup particle engine
R_InitColumnDrawers (); R_InitColumnDrawers ();
colfunc = basecolfunc = R_DrawColumn; colfunc = basecolfunc = R_DrawColumn;
@ -853,7 +879,6 @@ void R_Init ()
static void R_Shutdown () static void R_Shutdown ()
{ {
R_DeinitParticles();
R_DeinitTranslationTables(); R_DeinitTranslationTables();
R_DeinitPlanes(); R_DeinitPlanes();
R_DeinitColormaps (); R_DeinitColormaps ();
@ -1592,7 +1617,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
r_fakingunderwater = false; r_fakingunderwater = false;
// [RH] Setup particles for this frame // [RH] Setup particles for this frame
R_FindParticleSubsectors (); P_FindParticleSubsectors ();
WallCycles.Clock(); WallCycles.Clock();
DWORD savedflags = camera->renderflags; DWORD savedflags = camera->renderflags;

View file

@ -23,12 +23,8 @@
#ifndef __R_MAIN_H__ #ifndef __R_MAIN_H__
#define __R_MAIN_H__ #define __R_MAIN_H__
// Number of diminishing brightness levels. #include "r_utility.h"
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#define NUMCOLORMAPS 32
#include "d_player.h" #include "d_player.h"
#include "r_state.h"
#include "v_palette.h" #include "v_palette.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
@ -49,11 +45,6 @@ extern fixed_t viewingrangerecip;
extern fixed_t FocalLengthX, FocalLengthY; extern fixed_t FocalLengthX, FocalLengthY;
extern float FocalLengthXfloat; extern float FocalLengthXfloat;
extern fixed_t InvZtoScale; extern fixed_t InvZtoScale;
extern int WidescreenRatio;
extern angle_t LocalViewAngle; // [RH] Added to consoleplayer's angle
extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's pitch
extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate
extern float WallTMapScale; extern float WallTMapScale;
extern float WallTMapScale2; extern float WallTMapScale2;
@ -75,8 +66,6 @@ extern float iyaspectmulfloat;
extern FDynamicColormap*basecolormap; // [RH] Colormap for sector currently being drawn extern FDynamicColormap*basecolormap; // [RH] Colormap for sector currently being drawn
extern int validcount;
extern int linecount; extern int linecount;
extern int loopcount; extern int loopcount;
@ -120,10 +109,6 @@ extern float r_TiltVisibility;
extern fixed_t r_SpriteVisibility; extern fixed_t r_SpriteVisibility;
extern fixed_t r_SkyVisibility; extern fixed_t r_SkyVisibility;
extern fixed_t r_TicFrac;
extern DWORD r_FrameTime;
extern bool r_NoInterpolate;
extern int extralight, r_actualextralight; extern int extralight, r_actualextralight;
extern bool foggy; extern bool foggy;
extern int fixedlightlev; extern int fixedlightlev;
@ -149,33 +134,6 @@ extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh);
extern void (STACK_ARGS *hcolfunc_post4) (int sx, int yl, int yh); extern void (STACK_ARGS *hcolfunc_post4) (int sx, int yl, int yh);
//
// Utility functions.
//==========================================================================
//
// R_PointOnSide
//
// Traverse BSP (sub) tree, check point against partition plane.
// Returns side 0 (front/on) or 1 (back).
//
// [RH] inlined, stripped down, and made more precise
//
//==========================================================================
inline int R_PointOnSide (fixed_t x, fixed_t y, const node_t *node)
{
return DMulScale32 (y-node->y, node->dx, node->x-x, node->dy) > 0;
}
extern fixed_t viewx;
extern fixed_t viewy;
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); }
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy);
void R_SetFOV (float fov); void R_SetFOV (float fov);
float R_GetFOV (); float R_GetFOV ();
void R_InitTextureMapping (); void R_InitTextureMapping ();
@ -192,7 +150,6 @@ void R_SetupBuffer ();
void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false); void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false);
void R_ResetViewInterpolation ();
// Called by startup code. // Called by startup code.
void R_Init (void); void R_Init (void);
@ -205,9 +162,6 @@ void R_SetViewSize (int blocks);
void R_MultiresInit (void); void R_MultiresInit (void);
extern void R_FreePastViewers ();
extern void R_ClearPastViewer (AActor *actor);
extern int stacked_extralight; extern int stacked_extralight;
extern float stacked_visibility; extern float stacked_visibility;
extern fixed_t stacked_viewx, stacked_viewy, stacked_viewz; extern fixed_t stacked_viewx, stacked_viewy, stacked_viewz;
@ -215,24 +169,5 @@ extern angle_t stacked_angle;
extern void R_CopyStackedViewParameters(); extern void R_CopyStackedViewParameters();
// This list keeps track of the cameras that draw into canvas textures.
struct FCanvasTextureInfo
{
FCanvasTextureInfo *Next;
TObjPtr<AActor> Viewpoint;
FCanvasTexture *Texture;
FTextureID PicNum;
int FOV;
static void Add (AActor *viewpoint, FTextureID picnum, int fov);
static void UpdateAll ();
static void EmptyList ();
static void Serialize (FArchive &arc);
static void Mark();
private:
static FCanvasTextureInfo *List;
};
#endif // __R_MAIN_H__ #endif // __R_MAIN_H__

View file

@ -68,8 +68,6 @@
static void R_DrawSkyStriped (visplane_t *pl); static void R_DrawSkyStriped (visplane_t *pl);
EXTERN_CVAR (Bool, r_particles);
planefunction_t floorfunc; planefunction_t floorfunc;
planefunction_t ceilingfunc; planefunction_t ceilingfunc;

View file

@ -34,7 +34,6 @@
#include "templates.h" #include "templates.h"
#include "doomdef.h" #include "doomdef.h"
#include "m_swap.h" #include "m_swap.h"
#include "m_argv.h"
#include "i_system.h" #include "i_system.h"
#include "w_wad.h" #include "w_wad.h"
#include "r_local.h" #include "r_local.h"
@ -53,6 +52,7 @@
#include "d_net.h" #include "d_net.h"
#include "colormatcher.h" #include "colormatcher.h"
#include "d_netinf.h" #include "d_netinf.h"
#include "p_effect.h"
#include "r_bsp.h" #include "r_bsp.h"
#include "r_plane.h" #include "r_plane.h"
#include "r_segs.h" #include "r_segs.h"
@ -115,8 +115,6 @@ FDynamicColormap *VisPSpritesBaseColormap[NUMPSPRITES];
static int spriteshade; static int spriteshade;
TArray<WORD> ParticlesInSubsec;
// constant arrays // constant arrays
// used for psprite clipping and initializing clipping // used for psprite clipping and initializing clipping
short zeroarray[MAXWIDTH]; short zeroarray[MAXWIDTH];
@ -134,14 +132,6 @@ int OffscreenBufferWidth, OffscreenBufferHeight;
BYTE *OffscreenColorBuffer; BYTE *OffscreenColorBuffer;
FCoverageBuffer *OffscreenCoverageBuffer; FCoverageBuffer *OffscreenCoverageBuffer;
// [RH] particle globals
WORD NumParticles;
WORD ActiveParticles;
WORD InactiveParticles;
particle_t *Particles;
CVAR (Bool, r_particles, true, 0);
// //
// GAME FUNCTIONS // GAME FUNCTIONS
// //
@ -2000,94 +1990,6 @@ void R_DrawMasked (void)
} }
//
// [RH] Particle functions
//
// [BC] Allow the maximum number of particles to be specified by a cvar (so people
// with lots of nice hardware can have lots of particles!).
CUSTOM_CVAR( Int, r_maxparticles, 4000, CVAR_ARCHIVE )
{
if ( self == 0 )
self = 4000;
else if ( self < 100 )
self = 100;
if ( gamestate != GS_STARTUP )
{
R_DeinitParticles( );
R_InitParticles( );
}
}
void R_InitParticles ()
{
const char *i;
if ((i = Args->CheckValue ("-numparticles")))
NumParticles = atoi (i);
// [BC] Use r_maxparticles now.
else
NumParticles = r_maxparticles;
// This should be good, but eh...
if ( NumParticles < 100 )
NumParticles = 100;
R_DeinitParticles();
Particles = new particle_t[NumParticles];
R_ClearParticles ();
atterm (R_DeinitParticles);
}
void R_DeinitParticles()
{
if (Particles != NULL)
{
delete[] Particles;
Particles = NULL;
}
}
void R_ClearParticles ()
{
int i;
memset (Particles, 0, NumParticles * sizeof(particle_t));
ActiveParticles = NO_PARTICLE;
InactiveParticles = 0;
for (i = 0; i < NumParticles-1; i++)
Particles[i].tnext = i + 1;
Particles[i].tnext = NO_PARTICLE;
}
// Group particles by subsectors. Because particles are always
// in motion, there is little benefit to caching this information
// from one frame to the next.
void R_FindParticleSubsectors ()
{
if (ParticlesInSubsec.Size() < (size_t)numsubsectors)
{
ParticlesInSubsec.Reserve (numsubsectors - ParticlesInSubsec.Size());
}
clearbufshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE);
if (!r_particles)
{
return;
}
for (WORD i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext)
{
subsector_t *ssec = R_PointInSubsector (Particles[i].x, Particles[i].y);
int ssnum = int(ssec-subsectors);
Particles[i].subsector = ssec;
Particles[i].snext = ParticlesInSubsec[ssnum];
ParticlesInSubsec[ssnum] = i;
}
}
void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, int fakeside) void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade, int fakeside)
{ {
fixed_t tr_x; fixed_t tr_x;

View file

@ -60,50 +60,10 @@ struct vissprite_t
visstyle_t Style; visstyle_t Style;
}; };
// [RH] Particle details struct particle_t;
struct particle_t
{
fixed_t x,y,z;
fixed_t velx,vely,velz;
fixed_t accx,accy,accz;
BYTE ttl;
BYTE trans;
BYTE size;
BYTE fade;
int color;
WORD tnext;
WORD snext;
subsector_t * subsector;
};
extern WORD NumParticles;
extern WORD ActiveParticles;
extern WORD InactiveParticles;
extern particle_t *Particles;
const WORD NO_PARTICLE = 0xffff;
inline particle_t *NewParticle (void)
{
particle_t *result = NULL;
if (InactiveParticles != NO_PARTICLE)
{
result = Particles + InactiveParticles;
InactiveParticles = result->tnext;
result->tnext = ActiveParticles;
ActiveParticles = WORD(result - Particles);
}
return result;
}
void R_InitParticles ();
void R_DeinitParticles ();
void R_ClearParticles ();
void R_DrawParticle (vissprite_t *); void R_DrawParticle (vissprite_t *);
void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside); void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside);
void R_FindParticleSubsectors ();
extern TArray<WORD> ParticlesInSubsec;
extern int MaxVisSprites; extern int MaxVisSprites;
@ -135,8 +95,6 @@ void R_SortVisSprites (int (STACK_ARGS *compare)(const void *, const void *), si
void R_AddSprites (sector_t *sec, int lightlevel, int fakeside); void R_AddSprites (sector_t *sec, int lightlevel, int fakeside);
void R_AddPSprites (); void R_AddPSprites ();
void R_DrawSprites (); void R_DrawSprites ();
void R_InitSprites ();
void R_DeinitSprites ();
void R_ClearSprites (); void R_ClearSprites ();
void R_DrawMasked (); void R_DrawMasked ();
void R_DrawRemainingPlayerSprites (); void R_DrawRemainingPlayerSprites ();

72
src/r_utility.h Normal file
View file

@ -0,0 +1,72 @@
#ifndef __R_UTIL_H
#define __R_UTIL_H
#include "r_state.h"
//
// Stuff from r_main.h that's needed outside the rendering code.
// Number of diminishing brightness levels.
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#define NUMCOLORMAPS 32
extern fixed_t viewx;
extern fixed_t viewy;
extern bool r_NoInterpolate;
extern int validcount;
extern angle_t LocalViewAngle; // [RH] Added to consoleplayer's angle
extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's pitch
extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate
extern int WidescreenRatio;
extern fixed_t r_TicFrac;
extern DWORD r_FrameTime;
//==========================================================================
//
// R_PointOnSide
//
// Traverse BSP (sub) tree, check point against partition plane.
// Returns side 0 (front/on) or 1 (back).
//
// [RH] inlined, stripped down, and made more precise
//
//==========================================================================
inline int R_PointOnSide (fixed_t x, fixed_t y, const node_t *node)
{
return DMulScale32 (y-node->y, node->dx, node->x-x, node->dy) > 0;
}
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); }
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy);
void R_ResetViewInterpolation ();
void R_SetViewSize (int blocks);
extern void R_FreePastViewers ();
extern void R_ClearPastViewer (AActor *actor);
// This list keeps track of the cameras that draw into canvas textures.
struct FCanvasTextureInfo
{
FCanvasTextureInfo *Next;
TObjPtr<AActor> Viewpoint;
FCanvasTexture *Texture;
FTextureID PicNum;
int FOV;
static void Add (AActor *viewpoint, FTextureID picnum, int fov);
static void UpdateAll ();
static void EmptyList ();
static void Serialize (FArchive &arc);
static void Mark();
private:
static FCanvasTextureInfo *List;
};
#endif

View file

@ -61,7 +61,7 @@
#include "g_level.h" #include "g_level.h"
#include "r_state.h" #include "r_state.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "r_main.h" #include "r_utility.h"
#include "doomstat.h" #include "doomstat.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------

View file

@ -35,8 +35,8 @@
#include "doomtype.h" #include "doomtype.h"
#include "files.h" #include "files.h"
#include "r_main.h"
#include "templates.h" #include "templates.h"
#include "r_utility.h"
#include "textures/textures.h" #include "textures/textures.h"

View file

@ -47,7 +47,6 @@
#include "templates.h" #include "templates.h"
#include "v_video.h" #include "v_video.h"
#include "i_system.h" #include "i_system.h"
#include "r_main.h" // For lighting constants
#include "w_wad.h" #include "w_wad.h"
#include "i_video.h" #include "i_video.h"
#include "c_dispatch.h" #include "c_dispatch.h"

View file

@ -79,7 +79,7 @@
#include "cmdlib.h" #include "cmdlib.h"
#include "g_level.h" #include "g_level.h"
#include "doomstat.h" #include "doomstat.h"
#include "r_main.h" #include "r_utility.h"
#include "stats.h" #include "stats.h"
#include "st_start.h" #include "st_start.h"

View file

@ -2407,6 +2407,10 @@
RelativePath=".\src\r_things.h" RelativePath=".\src\r_things.h"
> >
</File> </File>
<File
RelativePath=".\src\r_utility.h"
>
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter