Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: 3d floor support in the map editor 3d mode. #966

Open
wants to merge 33 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@crisisinaptica
Copy link
Contributor

commented Nov 24, 2018

@sirjuddington I'm putting this up here to better asses what has to be done.
It's far from ready. The more feedback everyone can provide about this the better.

@crisisinaptica crisisinaptica changed the title Eevee 3d floors WIP: 3d floor support in the map editor 3d mode. Nov 24, 2018

@eevee

This comment has been minimized.

Copy link
Collaborator

commented Nov 24, 2018

Sorry for leaving this hanging for so long! I haven't gotten back to Doom stuff for a while.

Here's my own TODO list, though I can't guarantee it's entirely up to date:

  • Somewhat critical problem: a sector's 3D floors are ordered by height, but the selection in 3D mode is tracked by an index into that list of floors, which means the selection is wrong if you use mousewheel to move a selected 3D floor above/below another one

    Maybe I should get rid of the duplicated extra_floor_t struct and instead give each sector just a list of the control sectors that affect it, then identify by those instead of by "extra floor index"? It is possible to have the same control sector mapped to two 3d floors, though. And having 3D floors ordered by height is useful in some places, e.g. when figuring out where gravity should drop you to while walking around in 3D mode.

    Really wish I had faux flat/wall objects. Really, really wish I could just pass around sector pointers and bail if they're invalid.

  • Can't highlight or select an inner flat of a 3D floor

  • Mousewheel to change a regular ceiling height is super slow in my dump3 map; I think the full mapspecials recalculation thing is too expensive?

    The right thing here is to make map specials update incrementally in real time (rather than the current approach of constantly re-scanning the entire map), but that's much more complicated and requires a whole dependency tree. Or, at least, incremental slopes would require that; incremental 3D floors would be much simpler, since there's only one way to make a 3D floor. Might be a reasonable way to get started on incremental specials.

  • There was some kind of problem I had that I can no longer remember, to do with modifying 3D floors in real-time, argh

  • Currently, most of the properties are taken from the wrong place — e.g., the floor/ceiling textures should use the control sector's offsets and rotations and whatnot. For the most part, the only property of the target sector that's actually used is its geometry.

  • Don't draw wall textures on lines that have the same 3D floor on both sides

  • I keep abruptly popping out of 3D mode and I'm not sure why, or if it's even my fault? It stopped for a while, then started again when I added lighting code.

  • Translucent flats need to be sorted by distance in order to draw correctly

  • With flats_use_vbo off, slopes aren't rendered. Oops! Fix seems straightforward, in renderFlat. (Not actually related to 3D floors but this is where I noticed it.)

  • Support palette blends

  • Make sure transferring the sector color is correct?

  • Handle light effects

    • Flats need to propagate downwards to next floor
    • Walls: oof, quads might need splitting (consider interaction with slopes too)
  • Draw walls on two-sided lines

    • Support upper/lower flag as well
  • Sector info overlay still needs work

    • Says "ceiling texture", "ceiling height", etc when looking at a floor; is that right?
    • Flat lighting is wrong (I think mapspecials should intervene here)
    • Doesn't know about "flat plane at ceiling height"
    • Should probably show floor type?
    • Haven't touched walls at all and not sure how that should even work
  • Make all the 3D mode keybindings do the right thing when highlighting a 3D floor

    • changing wall texture, offset, scaling
    • changing flat texture, panning, scaling
    • resetting
    • changing flat height, wall height (should also understand "flat plane at ceiling height" flag)
    • changing linked lighting (flags relevant here too)
    • changing unlinked lighting
    • auto-align (!!!)
    • floodfill selection
  • Did I break the error rendering of a missing flat?

  • Support Vavoom floors, too

  • STILL some bizarre rendering errors

    • First time in 3D mode, the inside of a floor doesn't render; second time, it does?? what?
    • Very rarely, the VBOs break when switching back to 2D mode
    • Some sectors (without 3D floors!) don't have textures
    • Modifying sectors in 3D mode can corrupt the polygons in very strange ways, presumably VBOs getting crossed
    • 3D floors are now flickering between light levels; possibly trying to draw inside and outside flats simultaneously and they're z-fighting?
    • When moving the mouse directly from one 3D floor to another, the highlight briefly flickers to the floor of the actual sector rather than the 3D floor
    • 2D mode doesn't always correctly update VBOs when deleting a sector (or possibly while creating a new one, etc)
  • Code itself still has a bunch of TODOs

@crisisinaptica

This comment has been minimized.

Copy link
Contributor Author

commented Nov 24, 2018

@eevee Super helpful! Many thanks. This is going to give me a lot to think about while reading the code.

@sirjuddington

This comment has been minimized.

Copy link
Owner

commented Nov 25, 2018

There are a few things I was going to do in the refactor/cleanup that may affect (and/or help) this, particularly to do with how sector floors/ceilings are stored and handled. If you look at the std_string_313_refactor branch, I've added a Surface struct to MapSector which represents a floor or ceiling plane. I'll likely be doing something like this in master, in which case extra flats for 3d floors can be stored as extra Surfaces in each MapSector

Ideally I'd like to completely rewrite the 2d/3d rendering code to use modern opengl and have 3d floors in mind from the ground up, but that would be a lot of work :P Though if I ever want to properly support previewing some more advanced GZDoom features in 3d mode i'd probably have to do that anyway :/

@Gaerzi

This comment has been minimized.

Copy link
Collaborator

commented Nov 25, 2018

  • Sector info overlay still needs work
    • Says "ceiling texture", "ceiling height", etc when looking at a floor; is that right?

For a non-Vavoom 3D floor, that makes sense, since the top of the floor is the control sector's ceiling. The terms "upper plane" and "lower plane" could be used instead but you'd have to keep the Vavoom type in mind because for them the upper plane of the 3D floor is the control sector's floor. (The control sector in a Vavoom floor having a negative height, with the floor above the ceiling.)

@crisisinaptica crisisinaptica force-pushed the crisisinaptica:eevee_3d_floors branch from 9b25b10 to f4f0390 Nov 26, 2018

@crisisinaptica

This comment has been minimized.

Copy link
Contributor Author

commented Nov 26, 2018

There are a few things I was going to do in the refactor/cleanup that may affect (and/or help) this, particularly to do with how sector floors/ceilings are stored and handled. If you look at the std_string_313_refactor branch, I've added a Surface struct to MapSector which represents a floor or ceiling plane. I'll likely be doing something like this in master, in which case extra flats for 3d floors can be stored as extra Surfaces in each MapSector

Ideally I'd like to completely rewrite the 2d/3d rendering code to use modern opengl and have 3d floors in mind from the ground up, but that would be a lot of work :P Though if I ever want to properly support previewing some more advanced GZDoom features in 3d mode i'd probably have to do that anyway :/

A complete rewrite with all the GZDoom bells and whistles would be the coolest thing, but since it's probably something that's not going to happen any time soon... Would It be OK (the second coolest thing) if I bring to this branch some of the changes you have done in 'std_string_313_refactor'? From that spot we could rework some of this and finish it.

As it stands now, far from complete and unpolished, it's OK for my needs with a couple more adjustments, but leaving this to rot being so close to something release worthy would be a shame.

@sirjuddington

This comment has been minimized.

Copy link
Owner

commented Nov 26, 2018

Hmm, I'd say wait until I add it in master, to avoid a merge conflict mess :P I am currently in the process of working on the MapEditor source files cleanup - I'll do the MapSector/Surface stuff along with it so it shouldn't be too much longer to wait.

eevee and others added some commits Dec 23, 2015

Merge floors and ceilings in the 3D renderer
Preparation for supporting 3D floors.
WIP: Render 3D floors on 3D mode!
Lots of features are missing, there are no walls yet, sometimes the
alpha doesn't work right, and 2D mode is broken.  But it does work!
Fix all the VBO sector stuff I broke
Now each renderer just remembers its own VBO offsets per sector/flat,
which makes more sense anyway since they have their own VBOs.
Make some significant improvements to 3D floor rendering
- VBOs are no longer corrupted when making 3D edits!  This had haunted
  3D floor rendering since the beginning, but the problem turned out to
  not be in the renderer at all -- rather, MapSpecials kept re-adding
  the same 3D floors to the target sectors on every update, without
  clearing the originals.  The renderer would then dutifully create some
  flat structs, but because the geometry hadn't actually changed, the
  code that reassigns all the VBO offsets never ran, and the new structs
  had garbage offsets which wrote junk to who knows where.

  Now MapSpecials just nukes all the 3D floors on every update pass.  A
  more robust solution will involve incremental updates, but this is
  good enough for now.

  It may still be possible for corruption to occur if a tag or special
  is changed in such a way that the total number of 3D floors changes,
  but currently you can only make such a change in 2D mode, and I
  believe VBOs are recreated from scratch when switching into 3D mode.

- The "flat plane at ceiling height" flag is now supported.

- Floor and ceiling panning, rotation, and scale are now correct when
  switching to 3D mode.  They'd been unreliable for some time, and the
  culprit was just that the code that first creates VBOs doesn't check
  for those properties, but the code that updates existing VBOs does.

- The 3D renderer's cached flats remember their control sector, so 3D
  floors now correctly check floor/ceiling properties on the control
  sector rather than the target sector.

- Cleaned up VBO code a bit in general.  updateSector no longer has a
  silly argument for whether to skip half its effort; Polygon2D's
  updateVBOData was removed, as it's now identical to writeToVBO; we no
  longer reserve twice as much VBO space as necessary.
Fix spurious segfaults with camera gravity
The camera gravity is updated on a timer, so it could be called before
the sector flats were calculated.  The easy fix was to use the
original extra_floors instead of the sector flats, which turned out to
be easier anyway.

As an added bonus, now gravity only checks for solid 3D floors.
Propagate updated times from control sectors to 3D floors
This is necessary for 3D mode to know to update the floors when the
control sector's height changes.
Partial support for 3D floors in 3D edits and the overlay
- The 3D info overlay is now aware when it's looking at the top or
  bottom plane of a 3D floor, and (mostly) correctly checks for the
  properties on the control sector.

- Changing the height of a 3D floor's floor or ceiling with the mouse
  wheel now works correctly.
Stop applying individual line specials from the renderer
This was causing duplicated 3D floors and leading to more VBO
corruption.  It's no longer necessary, since we now recompute all
specials for the entire map every time something changes.
Fix rendered light level of 3D floor flats
By default, MapSector::getColour returns the sector color modified by
the light level, so effectively the light level was being squared.
Requesting the "fullbright" color fixes this.
3D floor editing improvements
(cherry picked from commit 6400c46dff4df41fe669954f378ee79657fb6935)
Made *ALMOST* fully working support for 3D floor side editing (except…
… flags like upper/lower texture for side)

(cherry picked from commit e05a9b7b131a8974f446d5c355f79e6be77e9f24)
DRAWBOTH on quads
(cherry picked from commit c0f85ee4c6c800df7642e495755bf705e7182b22)

usernameak and others added some commits Oct 31, 2018

Now 3D floors support scaling/offsets
(cherry picked from commit fd6768e5ded0e177159d7e6c4675ba984ca13af9)
Well-working 3D floor editing by faking sectors
(cherry picked from commit c0a517efe1d886a1826fb328982a9e1f66032f4d)
Add support for 3D floor flag 64
(cherry picked from commit 8adbf4c9e0347d89dd565d71779ff492f77d8db6)
Fixed crash on change texture, added 'Delete textuere'
(cherry picked from commit 13bf9ffa99db807fbc5bef321bef5a19851f24dd)
Now 3D floors account for the texture offsets on the lines of their d…
…estination sectors. Fixes #1

(cherry picked from commit 4edf93ccd0b38e16d95e989a59fceefe6af220fb)

@crisisinaptica crisisinaptica force-pushed the crisisinaptica:eevee_3d_floors branch from f4f0390 to 02a129a Dec 1, 2018

@OrdinaryMagician

This comment has been minimized.

Copy link

commented May 2, 2019

So when's this going to get picked up again?

@axredneck

This comment has been minimized.

Copy link

commented May 2, 2019

@OrdinaryMagician after refactoring of Slade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.