- floatified the portal displacement

This commit is contained in:
Christoph Oelckers 2022-09-16 19:56:46 +02:00
parent c87b4a581b
commit c44fd07f37
5 changed files with 15 additions and 16 deletions

View file

@ -381,9 +381,7 @@ FSerializer& Serialize(FSerializer& arc, const char* key, PortalDesc& obj, Porta
if (arc.BeginObject(key)) if (arc.BeginObject(key))
{ {
arc("type", obj.type) arc("type", obj.type)
("dx", obj.dx) ("d", obj.delta)
("dy", obj.dy)
("dz", obj.dz)
("targets", obj.targets) ("targets", obj.targets)
.EndObject(); .EndObject();
} }

View file

@ -42,6 +42,7 @@
#include "hw_sections.h" #include "hw_sections.h"
#include "memarena.h" #include "memarena.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "gamefuncs.h"
void CreateVertexMap(); void CreateVertexMap();

View file

@ -11,7 +11,7 @@ void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortyp
struct PortalDesc struct PortalDesc
{ {
int type; int type;
int dx, dy, dz; DVector3 delta;
TArray<int> targets; TArray<int> targets;
}; };
@ -30,9 +30,7 @@ inline int portalAdd(int type, int target, const DVector3& offset)
auto& pt = allPortals[allPortals.Reserve(1)]; auto& pt = allPortals[allPortals.Reserve(1)];
pt.type = type; pt.type = type;
if (target >= 0) pt.targets.Push(target); if (target >= 0) pt.targets.Push(target);
pt.dx = offset.X * worldtoint; pt.delta = offset;
pt.dy = offset.Y * worldtoint;
pt.dz = offset.Z * zworldtoint;
return allPortals.Size() - 1; return allPortals.Size() - 1;
} }
@ -52,7 +50,7 @@ inline void mergePortals()
for (unsigned j = i + 1; j < allPortals.Size(); j++) for (unsigned j = i + 1; j < allPortals.Size(); j++)
{ {
auto& pt2 = allPortals[j]; auto& pt2 = allPortals[j];
if (pt1.type != pt2.type || pt1.dx != pt2.dx || pt1.dy != pt2.dy || pt1.dz != pt2.dz) continue; if (pt1.type != pt2.type || pt1.delta != pt2.delta) continue;
for (unsigned s = 0; s < pt1.targets.Size() && pt2.targets.Size(); s++) for (unsigned s = 0; s < pt1.targets.Size() && pt2.targets.Size(); s++)
{ {
for (unsigned t = 0; t < pt2.targets.Size(); t++) for (unsigned t = 0; t < pt2.targets.Size(); t++)

View file

@ -796,7 +796,7 @@ bool HWSectorStackPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *c
auto portal = origin; auto portal = origin;
auto &vp = di->Viewpoint; auto &vp = di->Viewpoint;
vp.Pos += DVector3(portal->dx / 16., portal->dy / -16., portal->dz / -256.); vp.Pos += DVector3(portal->delta.X, -portal->delta.Y, -portal->delta.Z);
vp.SectNums = portal->targets.Data(); vp.SectNums = portal->targets.Data();
vp.SectCount = portal->targets.Size(); vp.SectCount = portal->targets.Size();
type = origin->type; type = origin->type;

View file

@ -855,12 +855,13 @@ static void SpawnPortals()
{ {
if (act->spr.picnum == SECTOREFFECTOR && act->spr.lotag == tag) if (act->spr.picnum == SECTOREFFECTOR && act->spr.lotag == tag)
{ {
if (processedTags.Find(act->spr.hitag) == processedTags.Size()) int hitag = act->spr.hitag;
if (processedTags.Find(hitag) == processedTags.Size())
{ {
DukeStatIterator it2(STAT_RAROR); DukeStatIterator it2(STAT_RAROR);
while (auto act2 = it2.Next()) while (auto act2 = it2.Next())
{ {
if (act2->spr.picnum == SECTOREFFECTOR && act2->spr.lotag == tag + 1 && act2->spr.hitag == act->spr.hitag) if (act2->spr.picnum == SECTOREFFECTOR && act2->spr.lotag == tag + 1 && act2->spr.hitag == hitag)
{ {
if (processedTags.Find(act->spr.hitag) == processedTags.Size()) if (processedTags.Find(act->spr.hitag) == processedTags.Size())
{ {
@ -868,15 +869,15 @@ static void SpawnPortals()
s1->portalflags = PORTAL_SECTOR_FLOOR; s1->portalflags = PORTAL_SECTOR_FLOOR;
s2->portalflags = PORTAL_SECTOR_CEILING; s2->portalflags = PORTAL_SECTOR_CEILING;
DVector2 diff = act->spr.pos.XY() - act2->spr.pos.XY(); DVector2 diff = act->spr.pos.XY() - act2->spr.pos.XY();
s1->portalnum = portalAdd(PORTAL_SECTOR_FLOOR, sectnum(s2), DVector3(-diff, act->spr.hitag * zmaptoworld)); s1->portalnum = portalAdd(PORTAL_SECTOR_FLOOR, sectnum(s2), DVector3(-diff, hitag)); // uses delta.Z as temporary storage, not a real coordinate.
s2->portalnum = portalAdd(PORTAL_SECTOR_CEILING, sectnum(s1), DVector3(diff, act->spr.hitag * zmaptoworld)); s2->portalnum = portalAdd(PORTAL_SECTOR_CEILING, sectnum(s1), DVector3(diff, hitag));
processedTags.Push(act->spr.hitag); processedTags.Push(act->spr.hitag);
} }
else else
{ {
for (auto& p : allPortals) for (auto& p : allPortals)
{ {
if (p.type == PORTAL_SECTOR_FLOOR && p.dz == act->spr.hitag) if (p.type == PORTAL_SECTOR_FLOOR && p.delta.Z == hitag)
{ {
p.targets.Push(act2->sectno()); p.targets.Push(act2->sectno());
} }
@ -889,7 +890,7 @@ static void SpawnPortals()
{ {
for (auto& p : allPortals) for (auto& p : allPortals)
{ {
if (p.type == PORTAL_SECTOR_CEILING && p.dz == act->spr.hitag) if (p.type == PORTAL_SECTOR_CEILING && p.delta.Z == hitag)
{ {
p.targets.Push(act->sectno()); p.targets.Push(act->sectno());
} }
@ -942,7 +943,8 @@ static void SpawnPortals()
} }
nexti:; nexti:;
} }
for (auto& p : allPortals) p.dz = 0; // clean out the tags we stored in delta.Z
for (auto& p : allPortals) p.delta.Z = 0;
mergePortals(); mergePortals();
} }