mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-13 12:32:13 +00:00
- removed the old section builder
This commit is contained in:
parent
b0e4b49771
commit
f6d852b5a0
10 changed files with 40 additions and 405 deletions
|
@ -1058,7 +1058,6 @@ set (PCH_SOURCES
|
||||||
core/rendering/hw_models.cpp
|
core/rendering/hw_models.cpp
|
||||||
core/rendering/hw_voxels.cpp
|
core/rendering/hw_voxels.cpp
|
||||||
core/rendering/hw_palmanager.cpp
|
core/rendering/hw_palmanager.cpp
|
||||||
core/rendering/hw_sections.cpp
|
|
||||||
core/rendering/hw_sections2.cpp
|
core/rendering/hw_sections2.cpp
|
||||||
core/rendering/scene/hw_clipper.cpp
|
core/rendering/scene/hw_clipper.cpp
|
||||||
core/rendering/scene/hw_walls.cpp
|
core/rendering/scene/hw_walls.cpp
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "hw_sections.h"
|
#include "hw_sections.h"
|
||||||
#include "interpolate.h"
|
#include "interpolate.h"
|
||||||
#include "hw_sections2.h"
|
|
||||||
#include "games/blood/src/mapstructs.h"
|
#include "games/blood/src/mapstructs.h"
|
||||||
|
|
||||||
extern BitArray clipsectormap;
|
extern BitArray clipsectormap;
|
||||||
|
@ -489,7 +488,6 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
|
||||||
md4once(buffer.Data(), buffer.Size(), md4);
|
md4once(buffer.Data(), buffer.Size(), md4);
|
||||||
G_LoadMapHack(filename, md4, sprites);
|
G_LoadMapHack(filename, md4, sprites);
|
||||||
setWallSectors();
|
setWallSectors();
|
||||||
hw_BuildSections();
|
|
||||||
hw_CreateSections2();
|
hw_CreateSections2();
|
||||||
sectionGeometry.SetSize(sections2.Size());
|
sectionGeometry.SetSize(sections2.Size());
|
||||||
|
|
||||||
|
|
|
@ -1,372 +0,0 @@
|
||||||
/*
|
|
||||||
** hw_sectiona.cpp
|
|
||||||
** For decoupling the renderer from internal Build structures
|
|
||||||
**
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
** Copyright 2021 Christoph Oelckers
|
|
||||||
** All rights reserved.
|
|
||||||
**
|
|
||||||
** Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions
|
|
||||||
** are met:
|
|
||||||
**
|
|
||||||
** 1. Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in the
|
|
||||||
** documentation and/or other materials provided with the distribution.
|
|
||||||
** 3. The name of the author may not be used to endorse or promote products
|
|
||||||
** derived from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
**
|
|
||||||
** The sole reason for existence of this file is that Build's sector setup
|
|
||||||
** does not allow for easy splitting of sectors, either for having disjoint parts
|
|
||||||
** or requiring partial rendering. So we need to add a superstructure
|
|
||||||
** where we can shuffle around some content without disturbing the original
|
|
||||||
** order...
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "hw_sections.h"
|
|
||||||
#include "sectorgeometry.h"
|
|
||||||
#include "gamefuncs.h"
|
|
||||||
|
|
||||||
|
|
||||||
FMemArena tempsectionArena(102400);
|
|
||||||
TArray<SectionLine> sectionLines;
|
|
||||||
TArray<Section> Sections;
|
|
||||||
TArray<TArray<int>> sectionspersector; // reverse map, mainly for the automap
|
|
||||||
int numsectionlines;
|
|
||||||
|
|
||||||
void hw_SplitSector(int sector, int startpos, int endpos);
|
|
||||||
|
|
||||||
TArray<int> splits;
|
|
||||||
|
|
||||||
|
|
||||||
void hw_BuildSections()
|
|
||||||
{
|
|
||||||
Sections.Resize(numsectors);
|
|
||||||
memset(Sections.Data(), 0, numsectors * sizeof(Section));
|
|
||||||
sectionspersector.Resize(numsectors);
|
|
||||||
sectionLines.Resize(numwalls * 5 / 4); // cannot reallocate, unfortunately.
|
|
||||||
numsectionlines = numwalls;
|
|
||||||
for (int i = 0; i < numsectors; i++)
|
|
||||||
{
|
|
||||||
Sections[i].sector = i;
|
|
||||||
auto lines = (int*)tempsectionArena.Alloc(sector[i].wallnum * sizeof(int));
|
|
||||||
Sections[i].lines.Set(lines, sector[i].wallnum);
|
|
||||||
for (int j = 0; j < sector[i].wallnum; j++) Sections[i].lines[j] = sector[i].wallptr + j;
|
|
||||||
sectionspersector[i].Resize(1);
|
|
||||||
sectionspersector[i][0] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initial setup just creates a 1:1 mapping of walls to section lines and sectors to sections.
|
|
||||||
numsectionlines = numwalls;
|
|
||||||
for (int i = 0; i < numwalls; i++)
|
|
||||||
{
|
|
||||||
auto& wal = wall[i];
|
|
||||||
sectionLines[i].startpoint = sectionLines[i].wall = i;
|
|
||||||
sectionLines[i].endpoint = wal.point2;
|
|
||||||
sectionLines[i].partner = wal.nextwall;
|
|
||||||
sectionLines[i].section = wal.sector;
|
|
||||||
sectionLines[i].partnersection = wal.nextsector;
|
|
||||||
sectionLines[i].point2index = 0;
|
|
||||||
if (wal.sector == -1)
|
|
||||||
Printf("Warning: Wall %d without a sector!\n", wall.IndexOf(&wal));
|
|
||||||
else
|
|
||||||
sectionLines[i].point2index = wal.point2 - wal.sectorp()->wallptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < splits.Size(); i += 3)
|
|
||||||
hw_SplitSector(splits[i], splits[i + 1], splits[i + 2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void SplitSection(int section, int start, int end)
|
|
||||||
{
|
|
||||||
#if 0 // disabled until refactoring. This code is a mess and needs to be redone.
|
|
||||||
|
|
||||||
// note: to do this, the sector's lines must be well ordered and there must only be one outline and no holes.
|
|
||||||
// This also can only apply a single split to a given sector.
|
|
||||||
int firstsection = Sections.Reserve(2);
|
|
||||||
int secondsection = firstsection+1;
|
|
||||||
|
|
||||||
auto& sect = Sections[section];
|
|
||||||
Section* sect1 = &Sections[firstsection];
|
|
||||||
Section* sect2 = &Sections[secondsection];
|
|
||||||
sect1->sector = sect.sector;
|
|
||||||
sect2->sector = sect.sector;
|
|
||||||
sect1->lines.Clear();
|
|
||||||
sect2->lines.Clear();
|
|
||||||
for (int aline : sect.lines)
|
|
||||||
{
|
|
||||||
int line = sectionLines[aline].wall;
|
|
||||||
if (line < start || line >= end)
|
|
||||||
{
|
|
||||||
sect1->lines.Push(aline);
|
|
||||||
}
|
|
||||||
if (line == start)
|
|
||||||
{
|
|
||||||
sect1->lines.Push(-1);
|
|
||||||
sect2->lines.Push(-1);
|
|
||||||
}
|
|
||||||
if (line >= start && line < end)
|
|
||||||
{
|
|
||||||
sect2->lines.Push(aline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int firstnewline = numsectionlines;
|
|
||||||
int thisline = numsectionlines;
|
|
||||||
int splitline1 = 0, splitline2 = 0;
|
|
||||||
//numsectionlines += sect1->lines.Size() + 1;
|
|
||||||
for (unsigned i = 0; i < sect1->lines.Size(); i++)// auto& sline : sect1->lines)
|
|
||||||
{
|
|
||||||
int sline = sect1->lines[i];
|
|
||||||
sect1->lines[i] = thisline;
|
|
||||||
if (sline != -1)
|
|
||||||
{
|
|
||||||
SectionLine& newline = sectionLines[thisline];
|
|
||||||
newline = sectionLines[sline];
|
|
||||||
newline.section = Sections.IndexOf(sect1);
|
|
||||||
if (i != sect1->lines.Size() - 1) newline.point2index = thisline + 1 - firstnewline;
|
|
||||||
else newline.point2index = 0;
|
|
||||||
assert(newline.point2index >= 0);
|
|
||||||
|
|
||||||
// relink the partner
|
|
||||||
if (newline.partner >= 0)
|
|
||||||
{
|
|
||||||
auto& partnerline = sectionLines[newline.partner];
|
|
||||||
partnerline.partner = thisline;
|
|
||||||
partnerline.partnersection = newline.section;
|
|
||||||
}
|
|
||||||
thisline++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
splitline1 = thisline++;
|
|
||||||
sectionLines[splitline1].wall = -1;
|
|
||||||
sectionLines[splitline1].section = Sections.IndexOf(sect1);
|
|
||||||
sectionLines[splitline1].partnersection = Sections.IndexOf(sect2);
|
|
||||||
sectionLines[splitline1].startpoint = start;
|
|
||||||
sectionLines[splitline1].endpoint = end;
|
|
||||||
sectionLines[splitline1].point2index = splitline1 + 1 - firstnewline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
firstnewline = thisline;
|
|
||||||
for (unsigned i = 0; i < sect2->lines.Size(); i++)// auto& sline : sect1->lines)
|
|
||||||
{
|
|
||||||
int sline = sect2->lines[i];
|
|
||||||
sect2->lines[i] = thisline;
|
|
||||||
if (sline != -1)
|
|
||||||
{
|
|
||||||
SectionLine& newline = sectionLines[thisline];
|
|
||||||
newline = sectionLines[sline];
|
|
||||||
newline.section = Sections.IndexOf(sect1);
|
|
||||||
if (i != sect2->lines.Size() - 1) newline.point2index = thisline + 1 - firstnewline;
|
|
||||||
else newline.point2index = 0;
|
|
||||||
assert(newline.point2index >= 0);
|
|
||||||
|
|
||||||
// relink the partner
|
|
||||||
if (newline.partner >= 0)
|
|
||||||
{
|
|
||||||
auto& partnerline = sectionLines[newline.partner];
|
|
||||||
partnerline.partner = thisline;
|
|
||||||
partnerline.partnersection = newline.section;
|
|
||||||
}
|
|
||||||
thisline++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
splitline2 = thisline++;
|
|
||||||
sectionLines[splitline2].wall = -1;
|
|
||||||
sectionLines[splitline2].section = Sections.IndexOf(sect2);
|
|
||||||
sectionLines[splitline2].partnersection = Sections.IndexOf(sect1);
|
|
||||||
sectionLines[splitline2].startpoint = end;
|
|
||||||
sectionLines[splitline2].endpoint = start;
|
|
||||||
sectionLines[splitline2].point2index = splitline2 + 1 - firstnewline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sectionLines[splitline1].partner = splitline2;
|
|
||||||
sectionLines[splitline2].partner = splitline1;
|
|
||||||
|
|
||||||
sectionspersector[sect.sector].Resize(2);
|
|
||||||
sectionspersector[sect.sector][0] = Sections.IndexOf(sect1);
|
|
||||||
sectionspersector[sect.sector][1] = Sections.IndexOf(sect2);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void hw_SplitSector(int sectnum, int start, int end)
|
|
||||||
{
|
|
||||||
int wallstart = sector[sectnum].wallptr;
|
|
||||||
int wallend = wallstart + sector[sectnum].wallnum;
|
|
||||||
if (start < wallstart || start >= wallend || end < wallstart || end >= wallend || end < start) return;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < sectionspersector[sectnum].Size(); i++)
|
|
||||||
{
|
|
||||||
int sect = sectionspersector[sectnum][i];
|
|
||||||
bool foundstart = false, foundend = false;
|
|
||||||
for (int aline : Sections[sect].lines)
|
|
||||||
{
|
|
||||||
int line = sectionLines[aline].wall;
|
|
||||||
if (line == start) foundstart = true;
|
|
||||||
if (line == end) foundend = true;
|
|
||||||
}
|
|
||||||
if (foundstart && foundend)
|
|
||||||
{
|
|
||||||
sectionspersector[sectnum].Delete(i);
|
|
||||||
SplitSection(sect, start, end);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hw_SetSplitSector(int sectnum, int start, int end)
|
|
||||||
{
|
|
||||||
splits.Push(sectnum);
|
|
||||||
splits.Push(start);
|
|
||||||
splits.Push(end);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hw_ClearSplitSector()
|
|
||||||
{
|
|
||||||
splits.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// this got dumped here to move it out of the way.
|
|
||||||
static FVector3 CalcNormal(sectortype* sector, int plane)
|
|
||||||
{
|
|
||||||
return { 0,0,0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
class UVCalculator1
|
|
||||||
{
|
|
||||||
sectortype* sect;
|
|
||||||
int myplane;
|
|
||||||
int stat;
|
|
||||||
float z1;
|
|
||||||
int ix1;
|
|
||||||
int iy1;
|
|
||||||
int ix2;
|
|
||||||
int iy2;
|
|
||||||
float sinalign, cosalign;
|
|
||||||
FGameTexture* tex;
|
|
||||||
float xpanning, ypanning;
|
|
||||||
float xscaled, yscaled;
|
|
||||||
FVector2 offset;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UVCalculator1(sectortype* sec, int plane, FGameTexture* tx, const FVector2& off)
|
|
||||||
{
|
|
||||||
float xpan, ypan;
|
|
||||||
|
|
||||||
sect = sec;
|
|
||||||
tex = tx;
|
|
||||||
myplane = plane;
|
|
||||||
offset = off;
|
|
||||||
|
|
||||||
auto firstwall = sec->firstWall();
|
|
||||||
ix1 = firstwall->x;
|
|
||||||
iy1 = firstwall->y;
|
|
||||||
ix2 = firstwall->point2Wall()->x;
|
|
||||||
iy2 = firstwall->point2Wall()->y;
|
|
||||||
|
|
||||||
if (plane == 0)
|
|
||||||
{
|
|
||||||
stat = sec->floorstat;
|
|
||||||
xpan = sec->floorxpan_;
|
|
||||||
ypan = sec->floorypan_;
|
|
||||||
PlanesAtPoint(sec, ix1, iy1, nullptr, &z1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stat = sec->ceilingstat;
|
|
||||||
xpan = sec->ceilingxpan_;
|
|
||||||
ypan = sec->ceilingypan_;
|
|
||||||
PlanesAtPoint(sec, ix1, iy1, &z1, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
DVector2 dv = { double(ix2 - ix1), -double(iy2 - iy1) };
|
|
||||||
auto vang = dv.Angle() - 90.;
|
|
||||||
|
|
||||||
cosalign = float(vang.Cos());
|
|
||||||
sinalign = float(vang.Sin());
|
|
||||||
|
|
||||||
int pow2width = 1 << sizeToBits((int)tx->GetDisplayWidth());
|
|
||||||
int pow2height = 1 << sizeToBits((int)tx->GetDisplayHeight());
|
|
||||||
|
|
||||||
xpanning = xpan / 256.f;
|
|
||||||
ypanning = ypan / 256.f;
|
|
||||||
|
|
||||||
float scalefactor = (stat & CSTAT_SECTOR_TEXHALF) ? 8.0f : 16.0f;
|
|
||||||
|
|
||||||
if ((stat & (CSTAT_SECTOR_SLOPE | CSTAT_SECTOR_ALIGN)) == (CSTAT_SECTOR_ALIGN))
|
|
||||||
{
|
|
||||||
// This is necessary to adjust for some imprecisions in the math.
|
|
||||||
// To calculate the inverse Build performs an integer division with significant loss of precision
|
|
||||||
// that can cause the texture to be shifted by multiple pixels.
|
|
||||||
// The code below calculates the amount of this deviation so that it can be added back to the formula.
|
|
||||||
int len = ksqrt(uhypsq(ix2 - ix1, iy2 - iy1));
|
|
||||||
if (len != 0)
|
|
||||||
{
|
|
||||||
int i = 1048576 / len;
|
|
||||||
scalefactor *= 1048576.f / (i * len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xscaled = scalefactor * pow2width;
|
|
||||||
yscaled = scalefactor * pow2height;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVector2 GetUV(int x, int y, float z)
|
|
||||||
{
|
|
||||||
float tv, tu;
|
|
||||||
|
|
||||||
if (stat & CSTAT_SECTOR_ALIGN)
|
|
||||||
{
|
|
||||||
float dx = (float)(x - ix1);
|
|
||||||
float dy = (float)(y - iy1);
|
|
||||||
|
|
||||||
tu = -(dx * sinalign + dy * cosalign);
|
|
||||||
tv = (dx * cosalign - dy * sinalign);
|
|
||||||
|
|
||||||
if (stat & CSTAT_SECTOR_SLOPE)
|
|
||||||
{
|
|
||||||
float dz = (z - z1) * 16;
|
|
||||||
float newtv = sqrt(tv * tv + dz * dz);
|
|
||||||
tv = tv < 0 ? -newtv : newtv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tu = x - offset.X;
|
|
||||||
tv = -y - offset.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stat & CSTAT_SECTOR_SWAPXY)
|
|
||||||
std::swap(tu, tv);
|
|
||||||
|
|
||||||
if (stat & CSTAT_SECTOR_XFLIP) tu = -tu;
|
|
||||||
if (stat & CSTAT_SECTOR_YFLIP) tv = -tv;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { tu / xscaled + xpanning, tv / yscaled + ypanning };
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -50,10 +50,14 @@ struct Section
|
||||||
TArrayView<Section2Loop> loops;
|
TArrayView<Section2Loop> loops;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TArray<Section> Sections;
|
extern TArray<Section> sections2;
|
||||||
extern TArray<TArray<int>> sectionspersector; // reverse map, mainly for the automap
|
extern TArrayView<TArrayView<Section*>> sections2PerSector;
|
||||||
|
|
||||||
|
void hw_CreateSections2();
|
||||||
|
using Outline = TArray<TArray<vec2_t>>;
|
||||||
|
using Point = std::pair<float, float>;
|
||||||
|
using FOutline = std::vector<std::vector<Point>>; // Data type was chosen so it can be passed directly into Earcut.
|
||||||
|
Outline BuildOutline(Section* section);
|
||||||
|
|
||||||
void hw_BuildSections();
|
|
||||||
void hw_SetSplitSector(int sector, int startpos, int endpos);
|
void hw_SetSplitSector(int sector, int startpos, int endpos);
|
||||||
void hw_ClearSplitSector();
|
void hw_ClearSplitSector();
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "hw_sections2.h"
|
#include "hw_sections.h"
|
||||||
#include "memarena.h"
|
#include "memarena.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
|
|
||||||
|
@ -48,8 +48,10 @@ FMemArena sectionArena(102400);
|
||||||
CVAR(Bool, hw_sectiondebug, false, 0)
|
CVAR(Bool, hw_sectiondebug, false, 0)
|
||||||
TMap<int, bool> bugged;
|
TMap<int, bool> bugged;
|
||||||
|
|
||||||
TArray<Section*> sections2;
|
TArray<SectionLine> sectionLines;
|
||||||
|
TArray<Section> sections2;
|
||||||
TArrayView<TArrayView<Section*>> sections2PerSector;
|
TArrayView<TArrayView<Section*>> sections2PerSector;
|
||||||
|
TArray<int> splits;
|
||||||
|
|
||||||
struct loopcollect
|
struct loopcollect
|
||||||
{
|
{
|
||||||
|
@ -564,9 +566,8 @@ static void ConstructSections(TArray<sectionbuildsector>& builders)
|
||||||
auto& builder = builders[i];
|
auto& builder = builders[i];
|
||||||
for (unsigned j = 0; j < builder.sections.Size(); j++)
|
for (unsigned j = 0; j < builder.sections.Size(); j++)
|
||||||
{
|
{
|
||||||
auto section = (Section*)sectionArena.Calloc(sizeof(Section));
|
auto section = §ions2[cursection];
|
||||||
auto& srcsect = builder.sections[j];
|
auto& srcsect = builder.sections[j];
|
||||||
sections2[cursection] = section;
|
|
||||||
sections2PerSector[i][j] = section;
|
sections2PerSector[i][j] = section;
|
||||||
section->sector = i;
|
section->sector = i;
|
||||||
section->index = cursection++;
|
section->index = cursection++;
|
||||||
|
@ -678,6 +679,20 @@ Outline BuildOutline(Section* section)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void hw_SetSplitSector(int sectnum, int start, int end)
|
||||||
|
{
|
||||||
|
splits.Push(sectnum);
|
||||||
|
splits.Push(start);
|
||||||
|
splits.Push(end);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hw_ClearSplitSector()
|
||||||
|
{
|
||||||
|
splits.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "c_dispatch.h"
|
#include "c_dispatch.h"
|
||||||
#include "engineerrors.h"
|
#include "engineerrors.h"
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,2 @@
|
||||||
#include "hw_sections.h"
|
#include "hw_sections.h"
|
||||||
|
|
||||||
extern TArray<Section*> sections2;
|
|
||||||
extern TArrayView<TArrayView<Section*>> sections2PerSector;
|
|
||||||
|
|
||||||
void hw_CreateSections2();
|
|
||||||
using Outline = TArray<TArray<vec2_t>>;
|
|
||||||
using Point = std::pair<float, float>;
|
|
||||||
using FOutline = std::vector<std::vector<Point>> ; // Data type was chosen so it can be passed directly into Earcut.
|
|
||||||
Outline BuildOutline(Section* section);
|
|
||||||
|
|
|
@ -88,7 +88,8 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, binangle a1, b
|
||||||
|
|
||||||
void BunchDrawer::StartScene()
|
void BunchDrawer::StartScene()
|
||||||
{
|
{
|
||||||
unsigned numsections = Sections.Size();
|
//unsigned numsections = Sections.Size();
|
||||||
|
unsigned numsections = sections2.Size();
|
||||||
LastBunch = 0;
|
LastBunch = 0;
|
||||||
StartTime = I_msTime();
|
StartTime = I_msTime();
|
||||||
Bunches.Clear();
|
Bunches.Clear();
|
||||||
|
@ -565,7 +566,8 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
|
||||||
|
|
||||||
SetupSprite.Clock();
|
SetupSprite.Clock();
|
||||||
|
|
||||||
int sectnum = Sections[sectionnum].sector;
|
//int sectnum = Sections[sectionnum].sector;
|
||||||
|
int sectnum = sections2[sectionnum].sector;
|
||||||
if (!gotsector[sectnum])
|
if (!gotsector[sectnum])
|
||||||
{
|
{
|
||||||
gotsector.Set(sectnum);
|
gotsector.Set(sectnum);
|
||||||
|
@ -603,7 +605,8 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
|
||||||
|
|
||||||
//Todo: process subsectors
|
//Todo: process subsectors
|
||||||
inbunch = false;
|
inbunch = false;
|
||||||
auto section = &Sections[sectionnum];
|
//auto section = &Sections[sectionnum];
|
||||||
|
auto section = §ions2[sectionnum];
|
||||||
for (unsigned i = 0; i < section->lines.Size(); i++)
|
for (unsigned i = 0; i < section->lines.Size(); i++)
|
||||||
{
|
{
|
||||||
auto thisline = §ionLines[section->lines[i]];
|
auto thisline = §ionLines[section->lines[i]];
|
||||||
|
@ -651,17 +654,17 @@ void BunchDrawer::RenderScene(const int* viewsectors, unsigned sectcount, bool p
|
||||||
|
|
||||||
for (unsigned i = 0; i < sectcount; i++)
|
for (unsigned i = 0; i < sectcount; i++)
|
||||||
{
|
{
|
||||||
for (auto j : sectionspersector[viewsectors[i]])
|
for (auto j : sections2PerSector[viewsectors[i]])
|
||||||
{
|
{
|
||||||
sectionstartang[j] = 0;
|
sectionstartang[j->index] = 0;
|
||||||
sectionendang[j] = int(angrange.asbam());
|
sectionendang[j->index] = int(angrange.asbam());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i < sectcount; i++)
|
for (unsigned i = 0; i < sectcount; i++)
|
||||||
{
|
{
|
||||||
for (auto j : sectionspersector[viewsectors[i]])
|
for (auto j : sections2PerSector[viewsectors[i]])
|
||||||
{
|
{
|
||||||
ProcessSection(j, portal);
|
ProcessSection(j->index, portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (Bunches.Size() > 0)
|
while (Bunches.Size() > 0)
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "hw_drawstructs.h"
|
#include "hw_drawstructs.h"
|
||||||
#include "hw_renderstate.h"
|
#include "hw_renderstate.h"
|
||||||
#include "sectorgeometry.h"
|
#include "sectorgeometry.h"
|
||||||
#include "hw_sections2.h"
|
#include "hw_sections.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
CVAR(Int, gl_breaksec, -1, 0)
|
CVAR(Int, gl_breaksec, -1, 0)
|
||||||
|
@ -100,7 +100,7 @@ void HWFlat::MakeVertices()
|
||||||
if (Sprite == nullptr)
|
if (Sprite == nullptr)
|
||||||
{
|
{
|
||||||
TArray<int>* pIndices;
|
TArray<int>* pIndices;
|
||||||
auto mesh = sectionGeometry.get(sections2[section], plane, geoofs, &pIndices);
|
auto mesh = sectionGeometry.get(§ions2[section], plane, geoofs, &pIndices);
|
||||||
|
|
||||||
auto ret = screen->mVertexData->AllocVertices(pIndices->Size());
|
auto ret = screen->mVertexData->AllocVertices(pIndices->Size());
|
||||||
auto vp = ret.first;
|
auto vp = ret.first;
|
||||||
|
@ -162,7 +162,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
if (!Sprite)
|
if (!Sprite)
|
||||||
{
|
{
|
||||||
TArray<int> *indices;
|
TArray<int> *indices;
|
||||||
auto mesh = sectionGeometry.get(sections2[section], plane, geoofs, &indices);
|
auto mesh = sectionGeometry.get(§ions2[section], plane, geoofs, &indices);
|
||||||
state.SetNormal(mesh->normal);
|
state.SetNormal(mesh->normal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -63,7 +63,6 @@
|
||||||
#include "ns.h"
|
#include "ns.h"
|
||||||
#include "serialize_obj.h"
|
#include "serialize_obj.h"
|
||||||
#include "games/blood/src/mapstructs.h"
|
#include "games/blood/src/mapstructs.h"
|
||||||
#include "hw_sections2.h"
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -725,7 +724,6 @@ void SerializeMap(FSerializer& arc)
|
||||||
if (arc.isReading())
|
if (arc.isReading())
|
||||||
{
|
{
|
||||||
setWallSectors();
|
setWallSectors();
|
||||||
hw_BuildSections();
|
|
||||||
hw_CreateSections2();
|
hw_CreateSections2();
|
||||||
sectionGeometry.SetSize(sections2.Size());
|
sectionGeometry.SetSize(sections2.Size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "gamefuncs.h"
|
#include "gamefuncs.h"
|
||||||
#include "hw_sections.h"
|
#include "hw_sections.h"
|
||||||
#include "sectorgeometry.h"
|
#include "sectorgeometry.h"
|
||||||
#include "hw_sections2.h"
|
|
||||||
|
|
||||||
#include "blood.h"
|
#include "blood.h"
|
||||||
|
|
||||||
|
@ -728,7 +727,6 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
|
||||||
}
|
}
|
||||||
|
|
||||||
setWallSectors();
|
setWallSectors();
|
||||||
hw_BuildSections();
|
|
||||||
hw_CreateSections2();
|
hw_CreateSections2();
|
||||||
sectionGeometry.SetSize(sections2.Size());
|
sectionGeometry.SetSize(sections2.Size());
|
||||||
wallbackup = wall;
|
wallbackup = wall;
|
||||||
|
|
Loading…
Reference in a new issue