From c338b9cde312e1c70e347bfdd90cd362624342a1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Feb 2016 16:26:27 +0100 Subject: [PATCH] - some more portal preparation . --- src/g_strife/a_thingstoblowup.cpp | 1 + src/p_enemy.cpp | 5 +++++ src/p_map.cpp | 3 +++ src/p_sectors.cpp | 13 +++++++++++++ src/portal.h | 24 ++++++++++++++++++++++++ src/r_data/r_interpolate.cpp | 2 ++ src/r_defs.h | 18 ++++++++++++++++++ 7 files changed, 66 insertions(+) diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index a1899e60b..4cf4f6861 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -104,6 +104,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut) sec->floorplane.d = sec->floorplane.PointToDist (spot, newheight); fixed_t newtheight = sec->floorplane.Zat0(); sec->ChangePlaneTexZ(sector_t::floor, newtheight - oldtheight); + sec->CheckPortalPlane(sector_t::floor); for (int i = 0; i < 8; ++i) { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index ad286fdd4..eaf729771 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2582,6 +2582,11 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) abs(corpsehit->Y() - viletry.y) > maxdist) continue; // not actually touching // Let's check if there are floors in between the archvile and its target + + // if in a different section of the map, only consider possible if a line of sight exists. + if (corpsehit->Sector->PortalGroup != self->Sector->PortalGroup && !P_CheckSight(self, corpsehit)) + continue; + sector_t *vilesec = self->Sector; sector_t *corpsec = corpsehit->Sector; // We only need to test if at least one of the sectors has a 3D floor. diff --git a/src/p_map.cpp b/src/p_map.cpp index 6416e0a6e..0e3cb6617 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5532,6 +5532,7 @@ bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool } } } while (n); + sec->CheckPortalPlane(!floorOrCeil); } } P_Recalculate3DFloors(sector); // Must recalculate the 3d floor and light lists @@ -5595,6 +5596,8 @@ bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool } } while (n); // repeat from scratch until all things left are marked valid + sector->CheckPortalPlane(floorOrCeil); // check for portal obstructions after everything is done. + if (!cpos.nofit && !isreset /* && sector->MoreFlags & (SECF_UNDERWATERMASK)*/) { // If this is a control sector for a deep water transfer, all actors in affected diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index a1cf2077f..a10568388 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -871,6 +871,19 @@ int sector_t::GetTerrain(int pos) const return terrainnum[pos] >= 0 ? terrainnum[pos] : TerrainTypes[GetTexture(pos)]; } +void sector_t::CheckPortalPlane(int plane) +{ + ASkyViewpoint *portal = SkyBoxes[plane]; + if (!portal || portal->special1 != SKYBOX_LINKEDPORTAL) return; + + fixed_t planeh = planes[plane].TexZ; + int obstructed = PLANEF_OBSTRUCTED * (plane == sector_t::floor ? + planeh > portal->threshold : planeh < portal->threshold); + planes[plane].Flags = (planes[plane].Flags & ~PLANEF_OBSTRUCTED) | obstructed; +} + + + FArchive &operator<< (FArchive &arc, secspecial_t &p) { if (SaveVersion < 4529) diff --git a/src/portal.h b/src/portal.h index 5e3d5bb8d..893f3ae69 100644 --- a/src/portal.h +++ b/src/portal.h @@ -8,6 +8,30 @@ #include "p_local.h" #include "m_bbox.h" +struct FDisplacement +{ + fixed_t x, y; + bool isSet; + BYTE indirect; // just for illustration. +}; + +struct FDisplacementTable +{ + TArray data; + int size; + + void Create(int numgroups) + { + data.Resize(numgroups*numgroups); + memset(&data[0], 0, numgroups*numgroups*sizeof(data[0])); + size = numgroups; + } + + FDisplacement &operator()(int x, int y) + { + return data[x + size*y]; + } +}; enum { diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index ed12cbf4e..760850bb4 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -469,6 +469,7 @@ void DSectorPlaneInterpolation::Restore() sector->SetPlaneTexZ(sector_t::ceiling, baktexz); } P_RecalculateAttached3DFloors(sector); + sector->CheckPortalPlane(ceiling? sector_t::ceiling : sector_t::floor); } //========================================================================== @@ -505,6 +506,7 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) *pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio); sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio)); P_RecalculateAttached3DFloors(sector); + sector->CheckPortalPlane(pos); } } diff --git a/src/r_defs.h b/src/r_defs.h index 7b86e00de..da122e14a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -518,6 +518,7 @@ struct sector_t DInterpolation *SetInterpolation(int position, bool attach); ASkyViewpoint *GetSkyBox(int which); + void CheckPortalPlane(int plane); enum { @@ -738,6 +739,22 @@ struct sector_t Flags &= ~SECF_SPECIALFLAGS; } + inline bool PortalBlocksView(int plane) + { + return !!(planes[plane].Flags & (PLANEF_NORENDER | PLANEF_DISABLED | PLANEF_OBSTRUCTED)); + } + + inline bool PortalBlocksMovement(int plane) + { + return !!(planes[plane].Flags & (PLANEF_NOPASS | PLANEF_DISABLED | PLANEF_OBSTRUCTED)); + } + + inline bool PortalBlocksSound(int plane) + { + return !!(planes[plane].Flags & (PLANEF_BLOCKSOUND | PLANEF_DISABLED | PLANEF_OBSTRUCTED)); + } + + int GetTerrain(int pos) const; void TransferSpecial(sector_t *model); @@ -830,6 +847,7 @@ struct sector_t // [RH] The sky box to render for this sector. NULL means use a // regular sky. TObjPtr SkyBoxes[2]; + int PortalGroup; int sectornum; // for comparing sector copies