- automap work to transition to new sections.

This commit is contained in:
Christoph Oelckers 2021-12-14 09:03:19 +01:00
parent b3873be514
commit 4364e68d05
5 changed files with 18 additions and 12 deletions

View file

@ -45,7 +45,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "v_draw.h"
#include "sectorgeometry.h"
#include "gamefuncs.h"
#include "hw_sections.h"
#include "hw_sections2.h"
#include "coreactor.h"
CVAR(Bool, am_followplayer, true, CVAR_ARCHIVE)
CVAR(Bool, am_rotate, true, CVAR_ARCHIVE)
@ -581,12 +581,14 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang)
int picnum = sect->floorpicnum;
if ((unsigned)picnum >= (unsigned)MAXTILES) continue;
for (auto ii : sectionspersector[i])
for (auto sect : sections2PerSector[i])
{
auto mesh = sectorGeometry.get(ii, 0, { 0.f,0.f });
vertices.Resize(mesh->vertices.Size());
for (unsigned j = 0; j < mesh->vertices.Size(); j++)
TArray<int>* indices;
auto mesh = sectionGeometry.get(sect, 0, { 0.f, 0.f }, &indices);
vertices.Resize(indices->Size());
for (unsigned jj = 0; jj < indices->Size(); jj++)
{
int j = (*indices)[jj];
int ox = int(mesh->vertices[j].X * 16.f) - cposx;
int oy = int(mesh->vertices[j].Y * -16.f) - cposy;
int x1 = DMulScale(ox, xvect, -oy, yvect, 16) + (width << 11);

View file

@ -492,6 +492,7 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
hw_BuildSections();
hw_CreateSections2();
sectorGeometry.SetSize(Sections.Size());
sectionGeometry.SetSize(sections2.Size());
wallbackup = wall;

View file

@ -568,8 +568,10 @@ static void ConstructSections(TArray<sectionbuildsector>& builders)
{
auto section = (Section2*)sectionArena.Calloc(sizeof(Section2));
auto& srcsect = builder.sections[j];
sections2[cursection++] = section;
sections2[cursection] = section;
sections2PerSector[i][j] = section;
section->sector = &sector[i];
section->index = cursection++;
int sectwalls = srcsect.wallcount;
auto walls = (Section2Wall**)sectionArena.Calloc(sectwalls * sizeof(Section2Wall*));
@ -620,11 +622,11 @@ void hw_CreateSections2()
ConstructSections(builders);
//if (hw_sectiondebug)
if (hw_sectiondebug)
{
for (int i = 0; i < numsectors; i++)
{
if (sections2PerSector[i][0]->flags == 0 && !bugged.CheckKey(i)) continue;
//if (sections2PerSector[i][0]->flags == 0 && !bugged.CheckKey(i)) continue;
Printf(PRINT_LOG, "Sector %d, %d walls, %d sections\n", i, sector[i].wallnum, sections2PerSector[i].Size());
for (auto& section : sections2PerSector[i])
{

View file

@ -257,7 +257,7 @@ ETriangulateResult TriangulateOutlineEarcut(const FOutline& polygon, int count,
// Sections are already validated so we can assume that the data is well defined here.
auto indices = mapbox::earcut(polygon);
if (indices.size() < 3 * count)
if (indices.size() < 3 * (count + polygon.size() * 2 - 2))
{
// this means that full triangulation failed.
return ETriangulateResult::Failed;
@ -271,7 +271,7 @@ ETriangulateResult TriangulateOutlineEarcut(const FOutline& polygon, int count,
points[p++] = { pt.first, pt.second };
}
}
indicesOut.Resize(count * 3);
indicesOut.Resize((unsigned)indices.size());
for (unsigned i = 0; i < indices.size(); i++)
{
indicesOut[i] = indices[i];
@ -313,7 +313,7 @@ ETriangulateResult TriangulateOutlineLibtess(const FOutline& polygon, int count,
// Add contours.
for (auto& loop : polygon)
tessAddContour(tess, 2, &loop.data()->first, (int)sizeof(*loop.data()), loop.size());
tessAddContour(tess, 2, &loop.data()->first, (int)sizeof(*loop.data()), (int)loop.size());
int result = tessTesselate(tess, TESS_WINDING_POSITIVE, TESS_POLYGONS, 3, 2, 0);
if (!result)
@ -556,7 +556,7 @@ SectionGeometryPlane* SectionGeometry::get(Section2* section, int plane, const F
if (!section || section->index >= data.Size()) return nullptr;
auto sectp = section->sector;
if (sectp->dirty) MarkDirty(sectp);
if (section->flags & EDirty::GeometryDirty)
if (data[section->index].dirty & EDirty::GeometryDirty)
{
bool res = CreateMesh(section);
if (!res)

View file

@ -731,6 +731,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
hw_BuildSections();
hw_CreateSections2();
sectorGeometry.SetSize(Sections.Size());
sectionGeometry.SetSize(sections2.Size());
wallbackup = wall;
sectorbackup = sector;
}