- bsp store vectors now
- vis stored in a way that is compatible with both Q2 and Q1
- binary reading of stuff, so swapping is done at load time now
- vis cleanup, although there's still a lot of raw long modification that should get simplified later
- main mbsp types are declared first in the files, and types that were single-member are now not structs
- conversion is handled by the sub-types themselves. Currently no diagnostic for *what* members overflow, but, overflow is handled via thrown exceptions on all overflowable members
- aabb type is used where appropriate now, simplifying a few areas
Cleanup/rework of logging system. I'm not too happy about it still, but, it's at least a bit easier to follow now.
Started cleanup of file-related stuff.
In preparation for converting all of the vec_t[3] to qvec's, the Vector routines are now templated and work with any type that provides indexing operators.
Polylib.cc is gone, since this all needs to be in header now
qvec can now implicitly convert from T[N]
constexpr where appropriate
static inline -> inline
side_t is now an enum, moved into mathlib
stdbool not required
_vsnprintf and _snprintf are standard in MSVC since 2015, so I just use them directly now. They'll be replaced by std::fmt later anyways.
use <thread> for threading, instead of pthreads/windows.h thread directly
typedef -> using
include guards -> pragma once
typedef struct x { } y; -> struct y { }
some fixes to extremely old code that shouldn't be required any more
* Add QBSP - the BSP2-esque variant to Q2BSP - to bspinfo, and all of its accompanying structures.
* pass around ident, since Q2 needs it - admittedly it's a bit ugly, but it works for now.
conversion for QBSP
* Fix light
* _qbsp_ -> _qbism_
* Introduced bspversion_t, a struct that holds pertinent information about different BSP versions and also acts as a tagged pointer type for direct comparisons. This makes a lot of code paths simpler. I'm not entirely set on the wordings or usages yet, and maybe we can stuff boolean flags inside of them for different behaviors (for instance Q2, QBism and HL would have the "colored lightmap" boolean set to true, which replaces the check-for-all-three in the lightmapper)
Swapped arguments to ConvertBSPFormat to have the conversion target last instead of first
Finished rename of qbsp -> qbism
Tested:
- bspinfo on various BSPs I had laying around (Q1, Q2, Qbism)
- bsputil converting between Q2 and Qbism, and that they loaded in engine/roundtripped properly
Not tested:
- vis/rad on anything major (I still can't run rad due to embree being weird)
- bsputil conversion of Q1-esque maps
* Q2 VIS
Almost working, just in-game is not 100% functional
* PHS! Q2 VIS!
* Fix missing loadversion assignment
Fix missing \n
* Implement q2bsp -> mbsp visdata copy
fix sky lighting to use arghrad compat
* Add QBSP - the BSP2-esque variant to Q2BSP - to bspinfo, and all of its accompanying structures.
* pass around ident, since Q2 needs it - admittedly it's a bit ugly, but it works for now.
conversion for QBSP
* Fix light
* _qbsp_ -> _qbism_
* Introduced bspversion_t, a struct that holds pertinent information about different BSP versions and also acts as a tagged pointer type for direct comparisons. This makes a lot of code paths simpler. I'm not entirely set on the wordings or usages yet, and maybe we can stuff boolean flags inside of them for different behaviors (for instance Q2, QBism and HL would have the "colored lightmap" boolean set to true, which replaces the check-for-all-three in the lightmapper)
Swapped arguments to ConvertBSPFormat to have the conversion target last instead of first
Finished rename of qbsp -> qbism
Tested:
- bspinfo on various BSPs I had laying around (Q1, Q2, Qbism)
- bsputil converting between Q2 and Qbism, and that they loaded in engine/roundtripped properly
Not tested:
- vis/rad on anything major (I still can't run rad due to embree being weird)
- bsputil conversion of Q1-esque maps
Add BSP2 support to the remaining utils. Since these share the common
bspfile.[ch] files, it was more effort than is justifiable to break this
into multiple staged patches - so you just get this disgustingly big
commit instead. Here is basically what was done:
* Modify the bspdata_t struct with a union of the two bsp formats
* Modify the tools to use bsp2_t for all internal processing
* Split out the byte swapping routines for the different bsp data types
* Add simple (although verbose) code to convert bsp29 <-> bsp2
Hundreds of lines added to bspfile.c, but mostly trivial stuff. The tools
internally had little modification except to substitute the bsp2 type
names.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Transition all tools to access the BSP data via the bspdata struct instead
of the shared globals. Remove the compatibility code from bspfile which
copied the global values to/from the instanced bspdata struct.
Mostly the changes just involved passing along the bspdata struct to the
various functions which needed to reference the data. TraceLine and
MakeTNodes in light got some extra changes so that we cache the node
dplane pointer and remove the need to pass the bspdata struct to every
trace operation!
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Rename the default bsp29 data types and add the bsp2 data types to
the common bspfile.h. Propogate the bsp29 names into the other tools as
simple renames for now.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Make CheckStack return an error code if we have recursed and print
some information about the offending leaf/portals before continuing.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Carry over some correctness fixes from recent changes to vis into the
qbsp versions of ClipWinding and make the implementations more
consistent overall.
Most importantly:
* Ensure we always have allocated one extra dists/sides slot for wrap around
* Check we have space for a new vertex every time we try to add one
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Just in case unsigned long isn't big enough to capture the pointer
offsets. Also, cast STACK_WINDINGS to the correct type before doing the
comparison.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
No longer update the globals in this function - make the callers do it
instead.
bspinfo no longer refers to the globals at all.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Just having one base pointer was kind of annoying because you have to cast
to get to the lump offsets, then cast to byte * to find the miptex, etc.
Now we can access the same pointer using the correct types in each case.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
First pass at detail support as implemented in tyr-qbsp, using the PRT2
file format (hopefully nobody else already decided to use that?)
Because the "leaf" terminology is pervasive across the source, I've left
it there for now (so "leaf" usually now means "cluster") and added a few
variables with the "_real" suffix when they actually mean the real leafs
and not the clusters which vis still calls leafs. A bit disgusting, but it
actually works so I'll go through and clean up naming, etc. later.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Inspired by the implementation of Benjt Jardrup, save the current state of
the vis job to disc at regular intervals so that we can resume from that
point in case the computer needs to be rebooted/shutdown or crash/power
issues occur.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Importing parts of this from TyrQuake - means that the base type used for
managing the bit vectors is unsigned long. Not really a performance win or
anything here, just a bit nicer to not have to cast from (byte *) to
(long *) - just adds a little extra work before writing out the compressed
data.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Make the base portal vis thread safe and run on multiple threads. Use the
common thread progress indicator code.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Add -vv option to hide extra verbose messages behing. Move a couple of
debug messages to the extra verbose level.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
When a portal is completed, check the updated vis information for leafs
that can no longer be seen from the leaf the portal is attached to. Update
the portals on these no-longer-visible leaves to indicated that they can
no longer see our leaf.
Seems to be at least a small gain on my test maps. I suspect there is
some further improvement to be gained by taking better advantage of this
optimisation by changing out choice of portals in GetNextPortal. Couldn't
find anything trivial that worked though.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>