2021-03-15 22:46:03 +00:00
|
|
|
#pragma once
|
|
|
|
#include "build.h"
|
2021-12-06 17:17:45 +00:00
|
|
|
#include "gamefuncs.h"
|
2021-03-15 22:46:03 +00:00
|
|
|
|
2021-03-24 17:42:00 +00:00
|
|
|
class FSerializer;
|
2021-03-28 17:22:51 +00:00
|
|
|
struct IntRect;
|
2021-03-24 17:42:00 +00:00
|
|
|
|
2022-12-05 05:09:43 +00:00
|
|
|
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, sectortype* sectnum, const DRotator& angles, double interpfrac, float fov = -1);
|
|
|
|
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, const DRotator& angles, FGameTexture* camtex, IntRect& rect, double interpfrac);
|
2022-09-06 11:35:50 +00:00
|
|
|
|
2021-03-21 13:48:35 +00:00
|
|
|
struct PortalDesc
|
|
|
|
{
|
|
|
|
int type;
|
2022-09-16 17:56:46 +00:00
|
|
|
DVector3 delta;
|
2021-03-21 13:48:35 +00:00
|
|
|
TArray<int> targets;
|
|
|
|
};
|
|
|
|
|
2021-03-24 17:42:00 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* key, PortalDesc& obj, PortalDesc* defval);
|
|
|
|
|
|
|
|
|
2021-03-21 13:48:35 +00:00
|
|
|
extern TArray<PortalDesc> allPortals;
|
|
|
|
|
|
|
|
inline void portalClear()
|
|
|
|
{
|
|
|
|
allPortals.Clear();
|
|
|
|
}
|
|
|
|
|
2022-09-05 22:40:53 +00:00
|
|
|
inline int portalAdd(int type, int target, const DVector3& offset)
|
|
|
|
{
|
|
|
|
auto& pt = allPortals[allPortals.Reserve(1)];
|
|
|
|
pt.type = type;
|
|
|
|
if (target >= 0) pt.targets.Push(target);
|
2022-09-16 17:56:46 +00:00
|
|
|
pt.delta = offset;
|
2022-09-05 22:40:53 +00:00
|
|
|
return allPortals.Size() - 1;
|
|
|
|
}
|
|
|
|
|
2021-03-24 17:42:00 +00:00
|
|
|
// merges portals in adjoining sectors.
|
2021-03-21 13:48:35 +00:00
|
|
|
inline void mergePortals()
|
|
|
|
{
|
2021-03-24 17:42:00 +00:00
|
|
|
//Printf("Have %d portals\n", allPortals.Size());
|
2021-03-21 13:48:35 +00:00
|
|
|
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];
|
2022-09-16 17:56:46 +00:00
|
|
|
if (pt1.type != pt2.type || pt1.delta != pt2.delta) continue;
|
2021-03-24 22:11:06 +00:00
|
|
|
for (unsigned s = 0; s < pt1.targets.Size() && pt2.targets.Size(); s++)
|
2021-03-21 13:48:35 +00:00
|
|
|
{
|
|
|
|
for (unsigned t = 0; t < pt2.targets.Size(); t++)
|
|
|
|
{
|
2021-12-06 17:17:45 +00:00
|
|
|
if (sectorsConnected(pt1.targets[s], pt2.targets[t]))
|
2021-03-21 13:48:35 +00:00
|
|
|
{
|
|
|
|
pt1.targets.Append(pt2.targets);
|
|
|
|
pt2.targets.Reset();
|
|
|
|
pt2.type = -1;
|
2021-12-24 08:19:43 +00:00
|
|
|
for (auto& sec : sector)
|
2021-03-21 13:48:35 +00:00
|
|
|
{
|
2021-03-24 17:42:00 +00:00
|
|
|
//Printf("Merged %d and %d\n", i, j);
|
2021-12-24 08:19:43 +00:00
|
|
|
if (sec.portalnum == (int)j) sec.portalnum = i;
|
2021-03-21 13:48:35 +00:00
|
|
|
}
|
2021-03-24 22:11:06 +00:00
|
|
|
didsomething = true;
|
|
|
|
break;
|
2021-03-21 13:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-08 17:06:41 +00:00
|
|
|
}
|