ericwa / ericw-tools

Quake/Hexen 2 Map compiling tools - branch of http://disenchant.net/utils
http://ericwa.github.io/ericw-tools
GNU General Public License v2.0
309 stars 56 forks source link

Q2RE PMove(in a Q2RTX fork) and CONTENTS_LADDER. #420

Closed WatIsDeze closed 2 months ago

WatIsDeze commented 2 months ago

Using ericw-tools-2.0.0-alpha7 I found that my maps with ladders started failing. The ladder trace uses a contentmask of CONTENTS_LADDER. Adding CONTENTS_SOLID to the trace allows it to work. Another fix was removing the leaf node contentmask tests.

The current temporary solution is an in-engine fix which seemingly is also how Q2RE fixes it for old maps. However the actual problem comes from ericw-tools not assigning the leaf nodes their proper contents.

ericwa commented 2 months ago

If a leaf has the solid content bit set, we intentionally clear all other content bits in the leaf (but preserve them in the brush).

So e.g. if the map file contains ladder | solid, we'll write the bsp leaf as solid and the bsp brush as ladder | solid.

I'm guessing this is what you're seeing?

As for why this is done, we were copying the original Q2 tools; this is the specific place this happens in qbsp3: https://github.com/id-Software/Quake-2-Tools/blob/master/bsp/qbsp3/brushbsp.c#L695

and also here, two neighbouring leafs that both have solid in them get turned into pure solid: https://github.com/id-Software/Quake-2-Tools/blob/master/bsp/qbsp3/tree.c#L180

I don't remember if we ever really figured out a good explanation for why the original did it that way (it might have been just so more solid stuff can get merged into single larger leafs?).

Paril commented 2 months ago

Yeah, it might have been for the merging, but we have to merge the leaf contents back on the engine side so I think it'd be better if the leaves always contain their brush contents.

WatIsDeze commented 2 months ago

Agreed with Paril. It in fact, simply breaks testing and tracing for various content masks if not done so. (This probably concerns most if not all engines, which optimize the test/trace code by first checking the leaf contents before checking each individual leaf brush.)

ericwa commented 2 months ago

Took a first attempt at fixing this after discussing with Paril.

Now, whatever brush contents are in the .map get added together and saved to the leaf contents.

The only special case is, structural solid causes the detail bit to get cleared (otherwise, having "detail solid" go through a wall would cause a map to leak.) We'll now write "detail | solid" where we didn't previously, or "ladder | solid", "water | solid" etc.