mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- use index fields in Section2Wall.
There's little benefit of using pointers here - it inflates a critical render struct, does not make any code more readable and requires quite deep refactoring of hw_bunchdrawer. Now, with all fields having the same tyoe and name a lot less code needs to be changed.
This commit is contained in:
parent
a407e86ff6
commit
f8f6c345fc
2 changed files with 22 additions and 20 deletions
|
@ -47,6 +47,7 @@ CVAR(Bool, hw_sectiondebug, false, 0)
|
|||
TMap<int, bool> bugged;
|
||||
|
||||
static FMemArena sectionArena(102400);
|
||||
TArray<Section2Wall*> section2walls;
|
||||
TArray<Section2*> sections2;
|
||||
TArrayView<TArrayView<Section2*>> sections2PerSector;
|
||||
|
||||
|
@ -534,9 +535,9 @@ static void ConstructSections(TArray<sectionbuildsector>& builders)
|
|||
}
|
||||
for (int i = 0; i < numwalls; i++)
|
||||
{
|
||||
wallmap[i]->v1 = &wall[i].pos;
|
||||
wallmap[i]->v2 = &wall[i].point2Wall()->pos;
|
||||
wallmap[i]->wall = &wall[i];
|
||||
wallmap[i]->startpoint = i;
|
||||
wallmap[i]->endpoint = wall[i].point2;
|
||||
wallmap[i]->wall = i;
|
||||
wallmap[i]->backside = validWallIndex(wall[i].nextwall)? wallmap[wall[i].nextwall] : nullptr;
|
||||
}
|
||||
|
||||
|
@ -593,14 +594,12 @@ static void ConstructSections(TArray<sectionbuildsector>& builders)
|
|||
{
|
||||
auto wal = wallmap[srcloop[w]];
|
||||
section->walls[curwall++] = loop.walls[w] = wal;
|
||||
wal->frontsection = section;
|
||||
wal->section = section->index;
|
||||
// backsection will be filled in when everything is done.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& wal : wallmap)
|
||||
if (wal->backside) wal->backsection = wal->backside->frontsection;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -636,12 +635,12 @@ void hw_CreateSections2()
|
|||
Printf(PRINT_LOG, "\t\tLoop, %d walls\n", loop.walls.Size());
|
||||
for (auto& wall : loop.walls)
|
||||
{
|
||||
Printf(PRINT_LOG, "\t\t\tWall %d, (%d, %d) -> (%d, %d)", ::wall.IndexOf(wall->wall), wall->v1->x / 16, wall->v1->y / -16, wall->v2->x / 16, wall->v2->y / -16);
|
||||
if (wall->wall->nextwall == -1) Printf(PRINT_LOG, "one-sided\n");
|
||||
Printf(PRINT_LOG, "\t\t\tWall %d, (%d, %d) -> (%d, %d)", wall->wall, wall->v1().x / 16, wall->v1().y / -16, wall->v2().x / 16, wall->v2().y / -16);
|
||||
if (wall->wallp()->nextwall == -1) Printf(PRINT_LOG, "one-sided\n");
|
||||
else
|
||||
{
|
||||
Printf(PRINT_LOG, " next wall = %d, next sector = %d", wall->wall->nextwall, wall->wall->nextsector);
|
||||
if (wall->wall->nextWall()->nextWall() != wall->wall) Printf(PRINT_LOG, " unreachable");
|
||||
Printf(PRINT_LOG, " next wall = %d, next sector = %d", wall->wallp()->nextwall, wall->wallp()->nextsector);
|
||||
if (wall->wallp()->nextWall()->nextWall() != wall->wallp()) Printf(PRINT_LOG, " unreachable");
|
||||
Printf(PRINT_LOG, "\n");
|
||||
}
|
||||
}
|
||||
|
@ -665,7 +664,7 @@ Outline BuildOutline(Section2* section)
|
|||
output[i].Resize(section->loops[i].walls.Size());
|
||||
for (unsigned j = 0; j < section->loops[i].walls.Size(); j++)
|
||||
{
|
||||
output[i][j] = *section->loops[i].walls[j]->v1;
|
||||
output[i][j] = section->loops[i].walls[j]->v1();
|
||||
}
|
||||
StripLoop(output[i]);
|
||||
}
|
||||
|
|
|
@ -10,15 +10,17 @@ enum ESEctionFlag
|
|||
|
||||
struct Section2Wall
|
||||
{
|
||||
// references to game data
|
||||
vec2_t* v1; // points to start vertex in wall[]
|
||||
vec2_t* v2; // points to end vertex in wall[]
|
||||
walltype* wall; // points to the actual wall this belongs to - this is NOT necessarily the same as v1 and can be null.
|
||||
|
||||
// references to section data
|
||||
Section2Wall* backside; // points to this wall's back side
|
||||
Section2* frontsection;
|
||||
Section2* backsection; // if this is null the wall is one-sided
|
||||
int index;
|
||||
int section;
|
||||
int startpoint;
|
||||
int endpoint;
|
||||
int wall; // points to the actual wall this belongs to - this is NOT necessarily the same as startpoint and can be -1.
|
||||
Section2Wall* backside; // this is better kept as pointer because of reindexing when splitting a section.
|
||||
|
||||
vec2_t v1() const { return ::wall[startpoint].pos; }
|
||||
vec2_t v2() const { return ::wall[endpoint].pos; }
|
||||
walltype* wallp() const { return &::wall[wall]; }
|
||||
|
||||
};
|
||||
|
||||
struct Section2Loop
|
||||
|
@ -40,6 +42,7 @@ struct Section2
|
|||
|
||||
extern TArray<Section2*> sections2;
|
||||
extern TArrayView<TArrayView<Section2*>> sections2PerSector;
|
||||
extern TArray<Section2Wall*> section2walls;
|
||||
|
||||
void hw_CreateSections2();
|
||||
using Outline = TArray<TArray<vec2_t>>;
|
||||
|
|
Loading…
Reference in a new issue