mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-26 06:01:14 +00:00
Create files for clip, draw and portal segments
This commit is contained in:
parent
b2a0f02f68
commit
1b284ecf3b
15 changed files with 224 additions and 127 deletions
|
@ -820,6 +820,9 @@ set( FASTMATH_PCH_SOURCES
|
|||
swrenderer/scene/r_things.cpp
|
||||
swrenderer/scene/r_voxel.cpp
|
||||
swrenderer/scene/r_walldraw.cpp
|
||||
swrenderer/scene/r_clip_segment.cpp
|
||||
swrenderer/scene/r_draw_segment.cpp
|
||||
swrenderer/scene/r_portal_segment.cpp
|
||||
polyrenderer/poly_renderer.cpp
|
||||
polyrenderer/scene/poly_scene.cpp
|
||||
polyrenderer/scene/poly_portal.cpp
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#include "drawers/r_draw.h"
|
||||
#include "scene/r_plane.h"
|
||||
#include "scene/r_bsp.h"
|
||||
#include "scene/r_draw_segment.h"
|
||||
#include "scene/r_portal_segment.h"
|
||||
#include "scene/r_clip_segment.h"
|
||||
#include "scene/r_segs.h"
|
||||
#include "scene/r_3dfloors.h"
|
||||
#include "r_sky.h"
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "r_things.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "r_clip_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "p_effect.h"
|
||||
|
@ -83,15 +85,6 @@ double rw_backfz1, rw_backfz2;
|
|||
double rw_frontcz1, rw_frontcz2;
|
||||
double rw_frontfz1, rw_frontfz2;
|
||||
|
||||
|
||||
size_t MaxDrawSegs;
|
||||
drawseg_t *drawsegs;
|
||||
drawseg_t* firstdrawseg;
|
||||
drawseg_t* ds_p;
|
||||
|
||||
size_t FirstInterestingDrawseg;
|
||||
TArray<size_t> InterestingDrawsegs;
|
||||
|
||||
FWallCoords WallC;
|
||||
FWallTmapVals WallT;
|
||||
|
||||
|
@ -99,7 +92,6 @@ static BYTE FakeSide;
|
|||
|
||||
int WindowLeft, WindowRight;
|
||||
WORD MirrorFlags;
|
||||
TArray<PortalDrawseg> WallPortals(1000); // note: this array needs to go away as reallocation can cause crashes.
|
||||
|
||||
|
||||
subsector_t *InSubsector;
|
||||
|
@ -108,45 +100,6 @@ subsector_t *InSubsector;
|
|||
|
||||
void R_StoreWallRange (int start, int stop);
|
||||
|
||||
//
|
||||
// R_ClearDrawSegs
|
||||
//
|
||||
void R_ClearDrawSegs (void)
|
||||
{
|
||||
if (drawsegs == NULL)
|
||||
{
|
||||
MaxDrawSegs = 256; // [RH] Default. Increased as needed.
|
||||
firstdrawseg = drawsegs = (drawseg_t *)M_Malloc (MaxDrawSegs * sizeof(drawseg_t));
|
||||
}
|
||||
FirstInterestingDrawseg = 0;
|
||||
InterestingDrawsegs.Clear ();
|
||||
ds_p = drawsegs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ClipWallSegment
|
||||
// Clips the given range of columns
|
||||
// and includes it in the new clip list.
|
||||
//
|
||||
//
|
||||
// 1/11/98 killough: Since a type "short" is sufficient, we
|
||||
// should use it, since smaller arrays fit better in cache.
|
||||
//
|
||||
|
||||
struct cliprange_t
|
||||
{
|
||||
short first, last; // killough
|
||||
};
|
||||
|
||||
|
||||
// newend is one past the last valid seg
|
||||
static cliprange_t *newend;
|
||||
static cliprange_t solidsegs[MAXWIDTH/2+2];
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_ClipWallSegment
|
||||
|
@ -285,21 +238,6 @@ bool R_CheckClipWallSegment (int first, int last)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// R_ClearClipSegs
|
||||
//
|
||||
void R_ClearClipSegs (short left, short right)
|
||||
{
|
||||
solidsegs[0].first = -0x7fff; // new short limit -- killough
|
||||
solidsegs[0].last = left;
|
||||
solidsegs[1].first = right;
|
||||
solidsegs[1].last = 0x7fff; // new short limit -- killough
|
||||
newend = solidsegs+2;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// killough 3/7/98: Hack floor/ceiling heights for deep water etc.
|
||||
//
|
||||
|
|
|
@ -67,56 +67,17 @@ enum
|
|||
FAKED_AboveCeiling
|
||||
};
|
||||
|
||||
struct drawseg_t
|
||||
{
|
||||
seg_t* curline;
|
||||
float light, lightstep;
|
||||
float iscale, iscalestep;
|
||||
short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg
|
||||
short sx1, sx2; // left, right of parent seg on screen
|
||||
float sz1, sz2; // z for left, right of parent seg on screen
|
||||
float siz1, siz2; // 1/z for left, right of parent seg on screen
|
||||
float cx, cy, cdx, cdy;
|
||||
float yscale;
|
||||
BYTE silhouette; // 0=none, 1=bottom, 2=top, 3=both
|
||||
BYTE bFogBoundary;
|
||||
BYTE bFakeBoundary; // for fake walls
|
||||
int shade;
|
||||
// Pointers to lists for sprite clipping,
|
||||
// all three adjusted so [x1] is first value.
|
||||
ptrdiff_t sprtopclip; // type short
|
||||
ptrdiff_t sprbottomclip; // type short
|
||||
ptrdiff_t maskedtexturecol; // type short
|
||||
ptrdiff_t swall; // type float
|
||||
int fake; // ident fake drawseg, don't draw and clip sprites
|
||||
// backups
|
||||
ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures
|
||||
FWallTmapVals tmapvals;
|
||||
int CurrentPortalUniq; // [ZZ] to identify the portal that this drawseg is in. used for sprite clipping.
|
||||
};
|
||||
|
||||
|
||||
extern seg_t* curline;
|
||||
extern side_t* sidedef;
|
||||
extern line_t* linedef;
|
||||
extern sector_t* frontsector;
|
||||
extern sector_t* backsector;
|
||||
|
||||
extern drawseg_t *drawsegs;
|
||||
extern drawseg_t *firstdrawseg;
|
||||
extern drawseg_t* ds_p;
|
||||
|
||||
extern TArray<size_t> InterestingDrawsegs; // drawsegs that have something drawn on them
|
||||
extern size_t FirstInterestingDrawseg;
|
||||
|
||||
extern int WindowLeft, WindowRight;
|
||||
extern WORD MirrorFlags;
|
||||
|
||||
typedef void (*drawfunc_t) (int start, int stop);
|
||||
|
||||
// BSP?
|
||||
void R_ClearClipSegs (short left, short right);
|
||||
void R_ClearDrawSegs ();
|
||||
void R_RenderBSPNode (void *node);
|
||||
|
||||
// killough 4/13/98: fake floors/ceilings for deep water / fake ceilings:
|
||||
|
|
40
src/swrenderer/scene/r_clip_segment.cpp
Normal file
40
src/swrenderer/scene/r_clip_segment.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "templates.h"
|
||||
#include "doomdef.h"
|
||||
#include "m_bbox.h"
|
||||
#include "i_system.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "p_setup.h"
|
||||
#include "swrenderer/r_main.h"
|
||||
#include "r_plane.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "r_things.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "p_effect.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_segs.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
#include "po_man.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_clip_segment.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
cliprange_t *newend;
|
||||
cliprange_t solidsegs[MAXWIDTH/2+2];
|
||||
|
||||
void R_ClearClipSegs(short left, short right)
|
||||
{
|
||||
solidsegs[0].first = -0x7fff;
|
||||
solidsegs[0].last = left;
|
||||
solidsegs[1].first = right;
|
||||
solidsegs[1].last = 0x7fff;
|
||||
newend = solidsegs+2;
|
||||
}
|
||||
}
|
16
src/swrenderer/scene/r_clip_segment.h
Normal file
16
src/swrenderer/scene/r_clip_segment.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
struct cliprange_t
|
||||
{
|
||||
short first, last;
|
||||
};
|
||||
|
||||
// newend is one past the last valid seg
|
||||
extern cliprange_t *newend;
|
||||
extern cliprange_t solidsegs[MAXWIDTH/2+2];
|
||||
|
||||
void R_ClearClipSegs(short left, short right);
|
||||
}
|
49
src/swrenderer/scene/r_draw_segment.cpp
Normal file
49
src/swrenderer/scene/r_draw_segment.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "templates.h"
|
||||
#include "doomdef.h"
|
||||
#include "m_bbox.h"
|
||||
#include "i_system.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "p_setup.h"
|
||||
#include "swrenderer/r_main.h"
|
||||
#include "r_plane.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "r_things.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "p_effect.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_segs.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
#include "po_man.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_draw_segment.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
size_t MaxDrawSegs;
|
||||
drawseg_t *drawsegs;
|
||||
drawseg_t *firstdrawseg;
|
||||
drawseg_t *ds_p;
|
||||
|
||||
size_t FirstInterestingDrawseg;
|
||||
TArray<size_t> InterestingDrawsegs;
|
||||
|
||||
void R_ClearDrawSegs()
|
||||
{
|
||||
if (drawsegs == NULL)
|
||||
{
|
||||
MaxDrawSegs = 256; // [RH] Default. Increased as needed.
|
||||
firstdrawseg = drawsegs = (drawseg_t *)M_Malloc (MaxDrawSegs * sizeof(drawseg_t));
|
||||
}
|
||||
FirstInterestingDrawseg = 0;
|
||||
InterestingDrawsegs.Clear ();
|
||||
ds_p = drawsegs;
|
||||
}
|
||||
|
||||
}
|
43
src/swrenderer/scene/r_draw_segment.h
Normal file
43
src/swrenderer/scene/r_draw_segment.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
struct drawseg_t
|
||||
{
|
||||
seg_t *curline;
|
||||
float light, lightstep;
|
||||
float iscale, iscalestep;
|
||||
short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg
|
||||
short sx1, sx2; // left, right of parent seg on screen
|
||||
float sz1, sz2; // z for left, right of parent seg on screen
|
||||
float siz1, siz2; // 1/z for left, right of parent seg on screen
|
||||
float cx, cy, cdx, cdy;
|
||||
float yscale;
|
||||
uint8_t silhouette; // 0=none, 1=bottom, 2=top, 3=both
|
||||
uint8_t bFogBoundary;
|
||||
uint8_t bFakeBoundary; // for fake walls
|
||||
int shade;
|
||||
|
||||
// Pointers to lists for sprite clipping, all three adjusted so [x1] is first value.
|
||||
ptrdiff_t sprtopclip; // type short
|
||||
ptrdiff_t sprbottomclip; // type short
|
||||
ptrdiff_t maskedtexturecol; // type short
|
||||
ptrdiff_t swall; // type float
|
||||
ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures
|
||||
|
||||
FWallTmapVals tmapvals;
|
||||
|
||||
int fake; // ident fake drawseg, don't draw and clip sprites backups
|
||||
int CurrentPortalUniq; // [ZZ] to identify the portal that this drawseg is in. used for sprite clipping.
|
||||
};
|
||||
|
||||
extern drawseg_t *drawsegs;
|
||||
extern drawseg_t *firstdrawseg;
|
||||
extern drawseg_t *ds_p;
|
||||
|
||||
extern TArray<size_t> InterestingDrawsegs; // drawsegs that have something drawn on them
|
||||
extern size_t FirstInterestingDrawseg;
|
||||
|
||||
void R_ClearDrawSegs();
|
||||
}
|
|
@ -62,6 +62,9 @@
|
|||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
#include "gl/dynlights/gl_dynlight.h"
|
||||
#include "r_walldraw.h"
|
||||
#include "r_clip_segment.h"
|
||||
#include "r_draw_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244)
|
||||
|
|
34
src/swrenderer/scene/r_portal_segment.cpp
Normal file
34
src/swrenderer/scene/r_portal_segment.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "templates.h"
|
||||
#include "doomdef.h"
|
||||
#include "m_bbox.h"
|
||||
#include "i_system.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "p_setup.h"
|
||||
#include "swrenderer/r_main.h"
|
||||
#include "r_plane.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "r_things.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "p_effect.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_segs.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
#include "po_man.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_portal_segment.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
PortalDrawseg *CurrentPortal = nullptr;
|
||||
int CurrentPortalUniq = 0;
|
||||
bool CurrentPortalInSkybox = false;
|
||||
|
||||
TArray<PortalDrawseg> WallPortals(1000); // note: this array needs to go away as reallocation can cause crashes.
|
||||
}
|
26
src/swrenderer/scene/r_portal_segment.h
Normal file
26
src/swrenderer/scene/r_portal_segment.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
/* portal structure, this is used in r_ code in order to store drawsegs with portals (and mirrors) */
|
||||
struct PortalDrawseg
|
||||
{
|
||||
line_t* src; // source line (the one drawn) this doesn't change over render loops
|
||||
line_t* dst; // destination line (the one that the portal is linked with, equals 'src' for mirrors)
|
||||
|
||||
int x1; // drawseg x1
|
||||
int x2; // drawseg x2
|
||||
|
||||
int len;
|
||||
TArray<short> ceilingclip;
|
||||
TArray<short> floorclip;
|
||||
|
||||
bool mirror; // true if this is a mirror (src should equal dst)
|
||||
};
|
||||
|
||||
extern PortalDrawseg* CurrentPortal;
|
||||
extern int CurrentPortalUniq;
|
||||
extern bool CurrentPortalInSkybox;
|
||||
extern TArray<PortalDrawseg> WallPortals;
|
||||
}
|
|
@ -49,6 +49,8 @@
|
|||
#include "v_palette.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_walldraw.h"
|
||||
#include "r_draw_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
|
||||
#define WALLYREPEAT 8
|
||||
|
||||
|
@ -69,9 +71,6 @@ namespace swrenderer
|
|||
|
||||
extern double globaluclip, globaldclip;
|
||||
|
||||
PortalDrawseg* CurrentPortal = NULL;
|
||||
int CurrentPortalUniq = 0;
|
||||
bool CurrentPortalInSkybox = false;
|
||||
|
||||
// OPTIMIZE: closed two sided lines as single sided
|
||||
|
||||
|
|
|
@ -57,27 +57,6 @@ extern float rw_lightstep;
|
|||
extern float rw_lightleft;
|
||||
extern fixed_t rw_offset;
|
||||
|
||||
/* portal structure, this is used in r_ code in order to store drawsegs with portals (and mirrors) */
|
||||
struct PortalDrawseg
|
||||
{
|
||||
line_t* src; // source line (the one drawn) this doesn't change over render loops
|
||||
line_t* dst; // destination line (the one that the portal is linked with, equals 'src' for mirrors)
|
||||
|
||||
int x1; // drawseg x1
|
||||
int x2; // drawseg x2
|
||||
|
||||
int len;
|
||||
TArray<short> ceilingclip;
|
||||
TArray<short> floorclip;
|
||||
|
||||
bool mirror; // true if this is a mirror (src should equal dst)
|
||||
};
|
||||
|
||||
extern PortalDrawseg* CurrentPortal;
|
||||
extern int CurrentPortalUniq;
|
||||
extern bool CurrentPortalInSkybox;
|
||||
extern TArray<PortalDrawseg> WallPortals;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
#include "p_local.h"
|
||||
#include "p_maputl.h"
|
||||
#include "r_voxel.h"
|
||||
#include "r_draw_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
|
||||
EXTERN_CVAR(Bool, st_scale)
|
||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "gl/dynlights/gl_dynlight.h"
|
||||
#include "swrenderer/drawers/r_drawers.h"
|
||||
#include "r_walldraw.h"
|
||||
#include "r_draw_segment.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue