Disclaimer: this isn't really a feature/pull request, since the code is incomplete. This is still a WIP though so it might later actually become a feature request. The whole approach is pretty hacky and coding is done in the style "if it works, then yay!"
Basically this is a combination of (slightly fixed) mirrors and Teleport_Line.
Spoiler: VideoFeatures:
- Doesn't require empty space behind portals (same applies to render part of mirrors now, btw);
- Works with arbitrary line angles
- Works with arbitrary floor/ceiling heights on both sides of the portal
- Works with polyobjects
- Works with 2-sided lines
- Can be turned on and off dynamically (SetLineSpecial works)
- Actors teleport
- Hitscan teleports
- Railgun teleports
- Autoaim teleports
- Radius damage teleports into all nearby portals
- Things should be spawned through the portal
- Collisions work
- Using lines/things through portals works
- Handling of movement across Teleport_Line has been fixed (for details see my comment in P_XYMovement in p_mobj.cpp)
- Makes ZDoom support wall part of EE linked portals through xlat (to the extent specified above)
- The game randomly crashes on actor going through. The crash seems to happen inside P_ActivateLineSpecial.
- Monsters are unable to walk through the portal
- If a thing stands in two portals at once, it will be linked into the blockmap behind only one of them.
- For the reason unknown yet, the walls IN FRONT of a mirror inside a portal aren't clipped by the walls that are also in front of that mirror, but closer to the viewer. (that green transporter box)*
- A moving polyobject won't "swallow" actors in it's path. It should.
- Chasecam will get blocked by portal lines
- View interpolation should use P_TeleportPoint in order to have smooth transition through the portal instead of just resetting PrevX/Y
- Didn't even touch monster AI (and have no idea [yet?] how to touch it, advices welcome)
- BFG tracers won't be spawned in the right direction if the ball explodes inside a portal (partially related to the AI issue, requires sight tracer to go into portals as well)
- Shooting at visible top/bottom parts of two-sided line portal won't work as expected
How to use:
This adds two specials, 155:Line_SetVisualPortal and 156:Line_SetPortal.
Both take three arguments, target line ID, current line ID (for Hexen maps, ignored in UDMF format), and linked plane.
If linked plane is 1, then the portal is moved vertically in such a way that floor planes of the current sector and receiving sector match. If linked plane is 2, then the same thing is done but with the ceiling.
Both can be set dynamically via SetLineSpecial.
Line_SetVisualPortal can point to any valid line ID, while Line_SetPortal requires destination ID to also have this special (although they shouldn't necessarily match each other).
Two lines can share common ID and have it set on both lines as destination, it will work.
Source: https://github.com/jewalky/zdoom/tree/portals
Binary with example map, if anyone is interested in testing this: http://www.mediafire.com/download/h7q7a ... zdoomx.zip
Separate demo map made by Gez: http://www.mediafire.com/download/dms9e ... _test0.zip (it's cooler than Eternity linked portal demo )
Notes:
r_portal_recursions 64, 1920x1080, pretty old 1.8ghz dual core CPU.
FPS drops from 60 to ~32 on Gez's test map compared to 4 recursions (infinite hallway, not pacman. pacman drops fps to 8 without changing r_portal_recursions :V)
This means that r_portal_recursions set to 16/32 is relatively reasonable (to avoid noticeable glitches with effects like that infinite hallway).
Current status:
6 critical bugs are to be fixed. Slowly. A serious refactoring for less code duplication is required.
New branch exists: https://github.com/jewalky/zdoom/tree/portals2
No build here until the refactoring branch has the same feature list as the old one. Same with updating the description above.
Spoiler: Differences to the old version