mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
f6568fee0c
This was by far the messiest game, there's two reasons for this. First, the portal links do not need to be in an actual portal sector, so they cannot be used to detect portal sectors. Second, the game moves portals in place, so all offsets are (0,0,0) so that not even these can be used for detection. The only working method is the super-complicated original way to look up portals at run time, just being done at map start. Having static portal links should reduce the render glitches quite significantly because the renderer knows now which sectors belong to a portal and can use this information to ensure proper processing.
76 lines
No EOL
1.8 KiB
C++
76 lines
No EOL
1.8 KiB
C++
#pragma once
|
|
#include "build.h"
|
|
|
|
class FSerializer;
|
|
|
|
void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sectnum, binangle angle, fixedhoriz horizon, lookangle rollang);
|
|
|
|
struct PortalDesc
|
|
{
|
|
int type;
|
|
int dx, dy, dz;
|
|
TArray<int> targets;
|
|
};
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* key, PortalDesc& obj, PortalDesc* defval);
|
|
|
|
|
|
extern TArray<PortalDesc> allPortals;
|
|
|
|
inline void portalClear()
|
|
{
|
|
allPortals.Clear();
|
|
}
|
|
|
|
inline int portalAdd(int type, int target, int dx = 0, int dy = 0, int dz = 0)
|
|
{
|
|
auto& pt = allPortals[allPortals.Reserve(1)];
|
|
pt.type = type;
|
|
if (target >= 0) pt.targets.Push(target);
|
|
pt.dx = dx;
|
|
pt.dy = dy;
|
|
pt.dz = dz;
|
|
return allPortals.Size() - 1;
|
|
}
|
|
|
|
// merges portals in adjoining sectors.
|
|
inline void mergePortals()
|
|
{
|
|
//Printf("Have %d portals\n", allPortals.Size());
|
|
bool didsomething = true;
|
|
while (didsomething)
|
|
{
|
|
didsomething = false;
|
|
for (unsigned i = 0; i < allPortals.Size(); i++)
|
|
{
|
|
auto& pt1 = allPortals[i];
|
|
if (pt1.type == PORTAL_SECTOR_CEILING || pt1.type == PORTAL_SECTOR_FLOOR)
|
|
{
|
|
for (unsigned j = i + 1; j < allPortals.Size(); j++)
|
|
{
|
|
auto& pt2 = allPortals[j];
|
|
if (pt1.type != pt2.type || pt1.dx != pt2.dx || pt1.dy != pt2.dy || pt1.dz != pt2.dz) continue;
|
|
for (unsigned s = 0; s < pt1.targets.Size() && pt2.targets.Size(); s++)
|
|
{
|
|
for (unsigned t = 0; t < pt2.targets.Size(); t++)
|
|
{
|
|
if (findwallbetweensectors(pt1.targets[s], pt2.targets[t]) >= 0)
|
|
{
|
|
pt1.targets.Append(pt2.targets);
|
|
pt2.targets.Reset();
|
|
pt2.type = -1;
|
|
for (int n = 0; n < numsectors; n++)
|
|
{
|
|
//Printf("Merged %d and %d\n", i, j);
|
|
if (sector[n].portalnum == j) sector[n].portalnum = i;
|
|
}
|
|
didsomething = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |