2017-04-17 10:27:19 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2017-01-03 06:17:54 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// Copyright 1993-1996 id Software
|
|
|
|
// Copyright 1999-2016 Randy Heit
|
|
|
|
// Copyright 2016 Magnus Norddahl
|
2017-01-03 06:17:54 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2017-01-03 06:17:54 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
2017-01-03 06:17:54 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-04-17 10:27:19 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2017-01-03 06:17:54 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-12-28 06:04:13 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-01-01 09:28:35 +00:00
|
|
|
#include "swrenderer/line/r_line.h"
|
2016-12-30 05:08:47 +00:00
|
|
|
|
2016-12-28 06:04:13 +00:00
|
|
|
namespace swrenderer
|
|
|
|
{
|
2017-01-26 06:03:27 +00:00
|
|
|
struct DrawSegment
|
2016-12-28 06:04:13 +00:00
|
|
|
{
|
|
|
|
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;
|
2017-07-02 13:35:29 +00:00
|
|
|
uint8_t silhouette = 0; // 0=none, 1=bottom, 2=top, 3=both
|
|
|
|
bool bFogBoundary = false;
|
|
|
|
int shade = 0;
|
|
|
|
bool foggy = false;
|
2016-12-28 06:04:13 +00:00
|
|
|
|
|
|
|
// Pointers to lists for sprite clipping, all three adjusted so [x1] is first value.
|
2017-07-02 13:35:29 +00:00
|
|
|
short *sprtopclip = nullptr;
|
|
|
|
short *sprbottomclip = nullptr;
|
|
|
|
fixed_t *maskedtexturecol = nullptr;
|
|
|
|
float *swall = nullptr;
|
|
|
|
short *bkup = nullptr; // sprtopclip backup, for mid and fake textures
|
2018-03-08 00:28:23 +00:00
|
|
|
bool sprclipped = false; // True if draw segment was used for clipping sprites
|
2016-12-28 06:04:13 +00:00
|
|
|
|
|
|
|
FWallTmapVals tmapvals;
|
|
|
|
|
2017-07-02 13:35:29 +00:00
|
|
|
int CurrentPortalUniq = 0; // [ZZ] to identify the portal that this drawseg is in. used for sprite clipping.
|
|
|
|
|
|
|
|
bool Has3DFloorWalls() const { return b3DFloorBoundary != 0; }
|
|
|
|
bool Has3DFloorFrontSectorWalls() const { return (b3DFloorBoundary & 2) == 2; }
|
|
|
|
bool Has3DFloorBackSectorWalls() const { return (b3DFloorBoundary & 1) == 1; }
|
|
|
|
bool Has3DFloorMidTexture() const { return (b3DFloorBoundary & 4) == 4; }
|
|
|
|
|
|
|
|
void SetHas3DFloorFrontSectorWalls() { b3DFloorBoundary |= 2; }
|
|
|
|
void SetHas3DFloorBackSectorWalls() { b3DFloorBoundary |= 1; }
|
|
|
|
void SetHas3DFloorMidTexture() { b3DFloorBoundary |= 4; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t b3DFloorBoundary = 0; // 1=backsector, 2=frontsector, 4=midtexture
|
2016-12-28 06:04:13 +00:00
|
|
|
};
|
|
|
|
|
2017-02-04 23:42:42 +00:00
|
|
|
struct DrawSegmentGroup
|
|
|
|
{
|
|
|
|
short x1, x2;
|
|
|
|
float neardepth, fardepth;
|
|
|
|
short *sprtopclip;
|
|
|
|
short *sprbottomclip;
|
|
|
|
unsigned int BeginIndex;
|
|
|
|
unsigned int EndIndex;
|
|
|
|
};
|
|
|
|
|
2017-01-26 07:01:44 +00:00
|
|
|
class DrawSegmentList
|
|
|
|
{
|
|
|
|
public:
|
2017-02-03 23:25:37 +00:00
|
|
|
DrawSegmentList(RenderThread *thread);
|
2017-01-26 07:01:44 +00:00
|
|
|
|
2017-02-04 23:42:42 +00:00
|
|
|
TArray<DrawSegmentGroup> SegmentGroups;
|
|
|
|
|
2017-02-09 21:58:28 +00:00
|
|
|
unsigned int SegmentsCount() const { return Segments.Size() - StartIndices.Last(); }
|
2017-02-03 20:25:51 +00:00
|
|
|
DrawSegment *Segment(unsigned int index) const { return Segments[Segments.Size() - 1 - index]; }
|
2017-01-26 07:01:44 +00:00
|
|
|
|
2017-07-01 21:55:41 +00:00
|
|
|
unsigned int TranslucentSegmentsCount() const { return TranslucentSegments.Size() - StartTranslucentIndices.Last(); }
|
|
|
|
DrawSegment *TranslucentSegment(unsigned int index) const { return TranslucentSegments[TranslucentSegments.Size() - 1 - index]; }
|
2017-01-26 07:01:44 +00:00
|
|
|
|
|
|
|
void Clear();
|
2017-02-03 20:11:55 +00:00
|
|
|
void PushPortal();
|
|
|
|
void PopPortal();
|
|
|
|
void Push(DrawSegment *segment);
|
2017-07-01 21:55:41 +00:00
|
|
|
void PushTranslucent(DrawSegment *segment);
|
2017-01-26 07:01:44 +00:00
|
|
|
|
2017-02-04 23:42:42 +00:00
|
|
|
void BuildSegmentGroups();
|
|
|
|
|
2017-02-03 23:25:37 +00:00
|
|
|
RenderThread *Thread = nullptr;
|
|
|
|
|
2017-01-26 07:01:44 +00:00
|
|
|
private:
|
2017-02-03 20:11:55 +00:00
|
|
|
TArray<DrawSegment *> Segments;
|
|
|
|
TArray<unsigned int> StartIndices;
|
|
|
|
|
2017-07-01 21:55:41 +00:00
|
|
|
TArray<DrawSegment *> TranslucentSegments; // drawsegs that have something drawn on them
|
|
|
|
TArray<unsigned int> StartTranslucentIndices;
|
2017-02-04 23:42:42 +00:00
|
|
|
|
|
|
|
// For building segment groups
|
|
|
|
short cliptop[MAXWIDTH];
|
|
|
|
short clipbottom[MAXWIDTH];
|
2017-01-26 07:01:44 +00:00
|
|
|
};
|
2016-12-28 06:04:13 +00:00
|
|
|
}
|