From 721b2fb21d4075b92bc9a16a1a5135faa40b96df Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Dec 2016 21:16:42 +0100 Subject: [PATCH] - fixed: Instant floor movers should disable z-interpolation for all affected actors. --- src/dsectoreffect.cpp | 46 ++++++++++++++++++++--------------------- src/p_3dmidtex.cpp | 4 ++-- src/p_3dmidtex.h | 4 ++-- src/p_floor.cpp | 7 +++++-- src/p_linkedsectors.cpp | 42 ++++++++++++++++++------------------- src/p_local.h | 2 +- src/p_map.cpp | 31 ++++++++++++++++++++++++++- src/p_spec.h | 1 + src/r_defs.h | 4 ++-- 9 files changed, 87 insertions(+), 54 deletions(-) diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index 3c33d1634..072b89f02 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -134,17 +134,17 @@ DMovingCeiling::DMovingCeiling (sector_t *sector, bool interpolate) if (interpolate) interpolation = sector->SetInterpolation(sector_t::CeilingMove, true); } -bool sector_t::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed) +bool sector_t::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed, bool instant) { - if (!P_Scroll3dMidtex(this, crush, move, !!floorOrCeiling) && resetfailed) + if (!P_Scroll3dMidtex(this, crush, move, !!floorOrCeiling, instant) && resetfailed) { - P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling); + P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling, instant); return false; } - if (!P_MoveLinkedSectors(this, crush, move, !!floorOrCeiling) && resetfailed) + if (!P_MoveLinkedSectors(this, crush, move, !!floorOrCeiling, instant) && resetfailed) { - P_MoveLinkedSectors(this, crush, -move, !!floorOrCeiling); - P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling); + P_MoveLinkedSectors(this, crush, -move, !!floorOrCeiling, instant); + P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling, instant); return false; } return true; @@ -156,7 +156,7 @@ bool sector_t::MoveAttached(int crush, double move, int floorOrCeiling, bool res // (Use -1 to prevent it from trying to crush) // dest is the desired d value for the plane // -EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush) +EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant) { bool flag; double lastpos; @@ -174,15 +174,15 @@ EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direct { move = floorplane.HeightDiff(lastpos, dest); - if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed; + if (!MoveAttached(crush, move, 0, true, instant)) return EMoveResult::crushed; floorplane.setD(dest); - flag = P_ChangeSector(this, crush, move, 0, false); + flag = P_ChangeSector(this, crush, move, 0, false, instant); if (flag) { floorplane.setD(lastpos); - P_ChangeSector(this, crush, -move, 0, true); - MoveAttached(crush, -move, 0, false); + P_ChangeSector(this, crush, -move, 0, true, instant); + MoveAttached(crush, -move, 0, false, instant); } else { @@ -193,16 +193,16 @@ EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direct } else { - if (!MoveAttached(crush, -speed, 0, true)) return EMoveResult::crushed; + if (!MoveAttached(crush, -speed, 0, true, instant)) return EMoveResult::crushed; floorplane.setD(movedest); - flag = P_ChangeSector(this, crush, -speed, 0, false); + flag = P_ChangeSector(this, crush, -speed, 0, false, instant); if (flag) { floorplane.setD(lastpos); - P_ChangeSector(this, crush, speed, 0, true); - MoveAttached(crush, speed, 0, false); + P_ChangeSector(this, crush, speed, 0, true, instant); + MoveAttached(crush, speed, 0, false, instant); return EMoveResult::crushed; } else @@ -231,16 +231,16 @@ EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direct { move = floorplane.HeightDiff(lastpos, dest); - if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed; + if (!MoveAttached(crush, move, 0, true, instant)) return EMoveResult::crushed; floorplane.setD(dest); - flag = P_ChangeSector(this, crush, move, 0, false); + flag = P_ChangeSector(this, crush, move, 0, false, instant); if (flag) { floorplane.setD(lastpos); - P_ChangeSector(this, crush, -move, 0, true); - MoveAttached(crush, -move, 0, false); + P_ChangeSector(this, crush, -move, 0, true, instant); + MoveAttached(crush, -move, 0, false, instant); } else { @@ -251,12 +251,12 @@ EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direct } else { - if (!MoveAttached(crush, speed, 0, true)) return EMoveResult::crushed; + if (!MoveAttached(crush, speed, 0, true, instant)) return EMoveResult::crushed; floorplane.setD(movedest); // COULD GET CRUSHED - flag = P_ChangeSector(this, crush, speed, 0, false); + flag = P_ChangeSector(this, crush, speed, 0, false, instant); if (flag) { if (crush >= 0 && !hexencrush) @@ -266,8 +266,8 @@ EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direct return EMoveResult::crushed; } floorplane.setD(lastpos); - P_ChangeSector(this, crush, -speed, 0, true); - MoveAttached(crush, -speed, 0, false); + P_ChangeSector(this, crush, -speed, 0, true, instant); + MoveAttached(crush, -speed, 0, false, instant); return EMoveResult::crushed; } ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos)); diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 26e9cf58b..39263dd91 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -51,7 +51,7 @@ // //============================================================================ -bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling) +bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling, bool instant) { extsector_t::midtex::plane &scrollplane = ceiling? sector->e->Midtex.Ceiling : sector->e->Midtex.Floor; @@ -69,7 +69,7 @@ bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling) for(unsigned i = 0; i < scrollplane.AttachedSectors.Size(); i++) { - res |= P_ChangeSector(scrollplane.AttachedSectors[i], crush, move, 2, true); + res |= P_ChangeSector(scrollplane.AttachedSectors[i], crush, move, 2, true, instant); } return !res; } diff --git a/src/p_3dmidtex.h b/src/p_3dmidtex.h index a24daff83..c363e2f2b 100644 --- a/src/p_3dmidtex.h +++ b/src/p_3dmidtex.h @@ -9,14 +9,14 @@ struct sector_t; struct line_t; class AActor; -bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling); +bool P_Scroll3dMidtex(sector_t *sector, int crush, double move, bool ceiling, bool instant = false); void P_Start3dMidtexInterpolations(TArray &list, sector_t *sec, bool ceiling); void P_Attach3dMidtexLinesToSector(sector_t *dest, int lineid, int tag, bool ceiling); bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot); bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side); bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, struct FLineOpening &open, bool restrict=false); -bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling); +bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling, bool instant = false); void P_StartLinkedSectorInterpolations(TArray &list, sector_t *sector, bool ceiling); bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype); void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling); diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 4b1f243d5..fbfa70f2e 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -86,7 +86,8 @@ void DFloor::Serialize(FSerializer &arc) ("pausetime", m_PauseTime) ("steptime", m_StepTime) ("persteptime", m_PerStepTime) - ("crushmode", m_Hexencrush); + ("crushmode", m_Hexencrush) + ("instant", m_Instant); } //========================================================================== @@ -129,7 +130,7 @@ void DFloor::Tick () if (m_Type == waitStair) return; - res = m_Sector->MoveFloor (m_Speed, m_FloorDestDist, m_Crush, m_Direction, m_Hexencrush); + res = m_Sector->MoveFloor (m_Speed, m_FloorDestDist, m_Crush, m_Direction, m_Hexencrush, m_Instant); if (res == EMoveResult::pastdest) { @@ -286,6 +287,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, floor->m_Speed = speed; floor->m_ResetCount = 0; // [RH] floor->m_OrgDist = sec->floorplane.fD(); // [RH] + floor->m_Instant = false; switch (floortype) { @@ -451,6 +453,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, (floor->m_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step { floor->StopInterpolation(true); + floor->m_Instant = true; // [Graf Zahl] // Don't make sounds for instant movement hacks but make an exception for diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index 37743455d..0487ede18 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -93,12 +93,12 @@ bool sector_t::IsLinked(sector_t *other, bool ceiling) const // //============================================================================ -static bool MoveCeiling(sector_t *sector, int crush, double move) +static bool MoveCeiling(sector_t *sector, int crush, double move, bool instant) { sector->ceilingplane.ChangeHeight (move); sector->ChangePlaneTexZ(sector_t::ceiling, move); - if (P_ChangeSector(sector, crush, move, 1, true)) return false; + if (P_ChangeSector(sector, crush, move, 1, true, instant)) return false; // Don't let the ceiling go below the floor if (!sector->ceilingplane.isSlope() && !sector->floorplane.isSlope() && @@ -108,12 +108,12 @@ static bool MoveCeiling(sector_t *sector, int crush, double move) return true; } -static bool MoveFloor(sector_t *sector, int crush, double move) +static bool MoveFloor(sector_t *sector, int crush, double move, bool instant) { sector->floorplane.ChangeHeight (move); sector->ChangePlaneTexZ(sector_t::floor, move); - if (P_ChangeSector(sector, crush, move, 0, true)) return false; + if (P_ChangeSector(sector, crush, move, 0, true, instant)) return false; // Don't let the floor go above the ceiling if (!sector->ceilingplane.isSlope() && !sector->floorplane.isSlope() && @@ -133,7 +133,7 @@ static bool MoveFloor(sector_t *sector, int crush, double move) // //============================================================================ -bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling) +bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling, bool instant) { extsector_t::linked::plane &scrollplane = ceiling? sector->e->Linked.Ceiling : sector->e->Linked.Floor; bool ok = true; @@ -143,55 +143,55 @@ bool P_MoveLinkedSectors(sector_t *sector, int crush, double move, bool ceiling) switch(scrollplane.Sectors[i].Type) { case LINK_FLOOR: - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move, instant); break; case LINK_CEILING: - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move, instant); break; case LINK_BOTH: if (move < 0) { - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move); - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move, instant); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move, instant); } else { - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move); - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move, instant); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move, instant); } break; case LINK_FLOORMIRROR: - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move, instant); break; case LINK_CEILINGMIRROR: - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move, instant); break; case LINK_BOTHMIRROR: if (move > 0) { - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move); - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move, instant); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move, instant); } else { - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move); - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move, instant); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move, instant); } break; case LINK_FLOOR+LINK_CEILINGMIRROR: - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move); - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, move, instant); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, -move, instant); break; case LINK_CEILING+LINK_FLOORMIRROR: - ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move); - ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move); + ok &= MoveFloor(scrollplane.Sectors[i].Sector, crush, -move, instant); + ok &= MoveCeiling(scrollplane.Sectors[i].Sector, crush, move, instant); break; default: diff --git a/src/p_local.h b/src/p_local.h index 41f980d44..c66792549 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -303,7 +303,7 @@ enum }; void P_FindFloorCeiling (AActor *actor, int flags=0); -bool P_ChangeSector (sector_t* sector, int crunch, double amt, int floorOrCeil, bool isreset); +bool P_ChangeSector (sector_t* sector, int crunch, double amt, int floorOrCeil, bool isreset, bool instant = false); DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget = NULL, DAngle vrange = 0., int flags = 0, AActor *target = NULL, AActor *friender = NULL); diff --git a/src/p_map.cpp b/src/p_map.cpp index 9b21a4c02..1f53181f1 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5713,6 +5713,7 @@ struct FChangePosition int crushchange; bool nofit; bool movemidtex; + bool instant; }; TArray intersectors; @@ -5993,6 +5994,12 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) intersect->SetZ(oldz); return 2; } + if (cpos->instant) + { + intersect->Prev.Z += intersect->Z() - oldz; + if (intersect->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + } + intersect->UpdateRenderSectorList(); } thing->CheckPortalTransition(true); @@ -6084,6 +6091,11 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9) && thing->Z() - thing->floorz <= cpos->moveamt)) { + if (cpos->instant) + { + thing->Prev.Z += thing->floorz - oldz; + if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + } thing->SetZ(thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); thing->UpdateRenderSectorList(); @@ -6093,6 +6105,11 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) { if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { + if (cpos->instant) + { + thing->Prev.Z += -oldfloorz + thing->floorz; + if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + } thing->AddZ(-oldfloorz + thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); thing->UpdateRenderSectorList(); @@ -6128,6 +6145,12 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) return; // do not move bridge things } intersectors.Clear(); + if (cpos->instant) + { + thing->Prev.Z += thing->floorz - thing->Z(); + if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + } + thing->SetZ(thing->floorz); } else @@ -6136,6 +6159,11 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) { intersectors.Clear(); thing->AddZ(-oldfloorz + thing->floorz); + if (cpos->instant) + { + thing->Prev.Z += -oldfloorz + thing->floorz; + if (thing->CheckLocalView(consoleplayer)) R_ResetViewInterpolation(); + } } else return; } @@ -6268,7 +6296,7 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) // //============================================================================= -bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, bool isreset) +bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, bool isreset, bool instant) { FChangePosition cpos; void(*iterator)(AActor *, FChangePosition *); @@ -6280,6 +6308,7 @@ bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, b cpos.moveamt = fabs(amt); cpos.movemidtex = false; cpos.sector = sector; + cpos.instant = instant; // Also process all sectors that have 3D floors transferred from the // changed sector. diff --git a/src/p_spec.h b/src/p_spec.h index 8a0729d6a..ea98c82c1 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -515,6 +515,7 @@ public: EFloor m_Type; int m_Crush; bool m_Hexencrush; + bool m_Instant; int m_Direction; secspecial_t m_NewSpecial; FTextureID m_Texture; diff --git a/src/r_defs.h b/src/r_defs.h index edb478a06..da1b26cf0 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -627,9 +627,9 @@ struct sector_t // Member functions private: - bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed); + bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed, bool instant = false); public: - EMoveResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush); + EMoveResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false); EMoveResult MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush); inline EMoveResult MoveFloor(double speed, double dest, int direction)