Closed bgaesslein closed 8 months ago
This is an interesting take on this. I believed these to be actual sectors, faking boxes, but do you mean that they are a special case?
I honestly don't know, my knowledge about build engine maps isn't exactly extensive so far. They do look like they split the containing sector and might have something to do with the missing roof pieces. Just a hunch tho.
I tried skipping the rendering of all the box-sectors and it worked but the ceiling still isn't complete so I guess it's not that. I get how the boxes work, they're a sector that has four walls below the "floor" and the "ceiling" is blended into the room sector's ceiling. Interestingly the containing sector also has four walls for the insides of the boxes even though these should never be seen.
It is peculiar that the ceiling holes usually correlate with such thresholds/overlapping sectors. Needs further research on why this happens.
This is the ceiling without the boxes. Interestingly, part of the ceiling is simply not textured, including that one part isn't covered by the box "ceiling". There's still a good chunk missing tho. Is there a way to see all the triangles that are part of the ceiling thingy? It looks like there's one ceiling-triangle that should be textured but isn't.
Edit: figured out how to view the wireframe. Kinda messy for this ceiling.
I've seen missing triangles elsewhere, and possibly triangles where there should be no triangle. Could they all be accidentally shifted +1 somewhere? Not that I necessarily think that's it, because that should probably lead to much more messy stuff. More likely an issue with the triangle algo for sectors as you're alluding to
This is the ceiling mesh, the lines seem to sometimes stop when they hit another ceiling mesh, you can see the outline of two of the boxes there
Thought: Have you seen this on floors anywhere, or is it only ceilings?
One difference between floors and ceilings is that boxes and other things usually "stand" on the floor, while ceilings need to cover "air space" (empty space over another sector). Maybe we can't use the same creation method for the two (the code is separated, but copy/pasted)
Update: Ok the following was not it
Here's something. When we construct sector floor/ceiling we use the sectorWalls to get the edges. We use this method to find all walls. Can't work out in my head whether we get all points here, or if we actually miss out on 1 wall point
var sectorWalls = map.Walls.Skip(sector.FirstWallIndex).Take(sector.NumWalls);
I've been wondering, the code for creating ceilings and floors is exactly the same except for two lines that reverse the vertices and uv lists. This could probably be refactored to save on some code duplication but that's besidee the point, which is: I haven't seen floors with "holes" in them. And commenting out the reverse() functions actually leads to a flawlessly filled ceiling here - but only when viewed from above.
It is a copy and exactly that, I was thinking I'd refactor it later so please go ahead and do anything you feel would improve it.
That said, I agree that the reverse function is super dodgy. I figured it was a way to flip the normals, but kind of suspected it wouldn't be that easy. I think you found it's not the correct way to do it.
I am wondering if all of these reverse calls is really a sign of something worse: https://github.com/monsharen/build-engine-unity/issues/10
I probably started making something upside down somewhere, and then felt I had to reverse everything down the line #gutfeel
I think I kinda fixed it.
(Ignore anything else that's missing, I skipped rendering everything except this one sector for easier visibilty while debugging)
I'll refactor the methods into one, see if it breaks anything else, and commit a possible solution later today.
PS: yeah, looks pretty good. Shall I commit directly to main or do you prefer a pull request? :)
go for whatever is easiest
Made a pull request, gotta have some code review haha.
Also is it me or do ceilings and floors often have more triangles than they need? Could be something to optimize, maybe? Not sure what the impact is.