Commit Graph

53 Commits

Author SHA1 Message Date
Eric Wasylishen e8d2a53255 bspinfo, bsputil: rename options -> bspinfo_options, bsputil_options 2022-07-10 17:32:23 -06:00
Jonathan 44c50717c3 move generic image loading routine to `img`
move light-specific "load textures from BSP" routine to light
fix a couple bugs with external wad textures (there should always be at least a 40-byte miptex in there)
light can now load external textures
move -paths to common settings
fix bug with missing texture not filling miptex name
2022-06-28 01:37:12 -04:00
Jonathan 510023e089 step 1 of finishing the rewrite I started of the image subsystems.
- for Quake-likes, WADs will be added as file system archives directly when the first brush is encountered since the wad key is ready to go by that point.
- after loading the .map and before constructing the BSP, what I call secondary textures (animation frames for Quake-likes) are added to the list, and the BSP's miptex data is filled.
- BSP miptex data is now opaque to the BSP process; the BSP simply copies the raw miptex information from the input. This simplifies the BSP structures and reading/writing routines.
- the img subsystem supports reading from raw miptexes now, although in practice this only happens for Quake-likes atm
- instead of a "wal cache", maps now have a "meta cache" which stores the metadata information for all games instead of just Quake II
- texture meta can now be ref'd out rather than needing to be copied every time (mainly only a gain for the std::string)
- wad.cc/wad.hh is gone; wads are now pushed into the filesystem archive
- fixed broken wad_archive
- fs subsystem iterated on a little bit; supports marking archives as external (only used for wads currently; see `LoadTextureData`)
- load_tga has better error handling
- add in foot-gun protection to the BSP readers; now they assert on failure to read instead of silently propagating that error throughout the rest of the process
- bsputil uses img stuff now, so it should handle palettes better
2022-06-27 03:58:23 -04:00
Jonathan 812797f7ed enable lighting for warp/sky in Q2
simplify bitflag definitions
change nudging light warning to make more sense
another #define -> constexpr pass
2022-06-10 06:29:14 -04:00
Eric Wasylishen fe31e1c1ce bsputil: add --decompile-ignore-brushes option for visualizing leafs in q2 maps 2022-06-06 00:07:31 -06:00
Jonathan c81e9ace28 remove old threading code entirely
add new parallel logging stuff in common/parallel which wraps parallel_for(_each) and provides automatic percentage indicator
fix issue with light not pulling in settings
move logging stuff into its own namespace and simplify
2022-03-01 10:28:59 -05:00
Jonathan df92d9ce12
Command line args systems (#2)
* cmd

* cmake change for tbb DLLs
add in test for double-hyphens

* cmd

* game version

* settings!

* bsp texture usage
decompile fix for q1bsp

* finish up the options for qbsp

* light finished?

* finish up the few missing bits

* move scalar/int32 up

* Run clang-format pass

* natvis for our mathlib
use slightly faster storage for winding
fix light tests

* allow dictionary to be a base type

* re-run style

* Remove cfg_static
Fix options summary

* natvis for lockable_value<T>

* last-ish pass?

* format

* forgot last few lockables
2022-02-27 00:01:57 -05:00
Jonathan 686cdf4217 add entity lump replacement to bsputil 2022-01-29 10:15:50 -05:00
Jonathan 8dbb18cc94 Use stem() instead of filename() when we're only wanting to change filename without extension 2022-01-22 17:55:37 -05:00
Jonathan 8cadf06d81 New FS!
First FS test: use it for decompile for Q2 to prevent unnecessary suffixes
2021-11-05 19:25:37 -04:00
Jonathan 1a1b4bdfb1 Re-ordered code to be easier to follow and write out all at once rather than doing it per-step 2021-10-31 19:28:52 -04:00
Jonathan 0e361f9323 Support for Q2BSP decompilation
- there's still a couple failure cases - specifically base1 in the outdoor area has a side that wasn't able to match to a face
- the clip brush at the start of base1 gets cut into a bunch of pieces because of the whole "check for texinfo, compare and split into multiple pieces" thing, but I'm pretty sure it's just one single brush - we need to ignore the splitting thing on clip brushes since they don't care about texture
- triggers don't pull in a temp texture
- origin brushes?
2021-10-27 17:56:56 -04:00
Jonathan 74253fd189 Fixed Unix/Clang compilation
Adjusted makefile to work with both clang and msvc on win32
Removed "WIN32", use the standard _WIN32 instead
Fixed bad VectorCopy's
Use qvec4b instead of special color_rgba type
qvec now follows built-in type procedures for handling operators; this means that (qvec3i + qvec3f) will now properly produce a float, as one would expect, instead of adding the float to the integers without casting to the common type.
2021-10-23 07:35:41 -04:00
Jonathan a21be0362c replace VectorCompare, CrossProduct, DotProduct
qv::dot handles inputs a bit more gracefully now
plane::distance_to for distance checks, and dplane has the fast version
2021-10-21 23:25:19 -04:00
Jonathan a7de4bdae2 Remove unused thingies
Use qplane3 where we can
2021-10-17 06:24:02 -04:00
Jonathan e6fd6b653e A few more vec3_t -> qvec
qmat follows other type conventions (T, N, M) and is annotated differently so it's not as confusing to follow
Removed qmat::operator[] - it's not clear from calling it that it's column-major (as evidenced by the comments needing to explicitly make clear at call sites that it's column, not row), so I've collapsed them into two separate functions that explicitly fetch either a column or a row. This also ties them nicely into qvec<N>.
2021-10-12 12:03:59 -04:00
Jonathan 01b8abf93c Removed a lot of unused functions
Moved vector-related operations from mathlib to qvec, moved a few into qv::
Use clamp/max/min directly instead of #define'ing them
Move a few single-use functions directly above their usages
2021-10-10 14:04:09 -04:00
Jonathan 52839d4e7f Run clang-format pass 2021-10-05 15:54:06 -04:00
Jonathan 0833d84a7a Calculate tangents and bitangents (need to clean this up)
Implement formatters for qvec
Add -nolighting, which skips all non-lightstyled lights
2021-10-05 01:07:13 -04:00
Jonathan 792951792c some more cleanup 2021-10-02 05:56:45 -04:00
Jonathan 9d828d2085 Structured texture data!
Move vis decompress/compress back to vis since phs is handled there now too
Fix missing textures in Q1BSP
Comment areaportaling for now
2021-09-30 11:33:04 -04:00
Jonathan 87d31e6d4f A lot of type-y stuff here:
- 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
2021-09-25 23:58:02 -04:00
Jonathan 41b9a79e83 Merge branch 'qbsp-contentflags' into type-cleanup
# Conflicts:
#	bsputil/bsputil.cc
#	common/bspfile.cc
#	common/cmdlib.cc
#	include/common/bspfile.hh
#	include/common/cmdlib.hh
#	qbsp/brush.cc
#	qbsp/portals.cc
#	qbsp/writebsp.cc
#	vis/vis.cc
2021-09-23 18:42:25 -04:00
Jonathan 6ff2d67d12 major C++-esque change to BSP conversion:
- 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
2021-09-22 17:30:46 -04:00
Eric Wasylishen 80a4aa1b97 Merge branch 'master' into qbsp-contentflags 2021-09-22 00:12:27 -06:00
Jonathan 49fd62b9f3 Lotta more file stuff. Have to think about fscanf though. 2021-09-19 22:20:39 -04:00
Jonathan 326626f127 Remove some old stuff
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.
2021-09-19 18:17:28 -04:00
Jonathan 17606fde4b Use variant instead of having all BSP types allocated at once (even though they are smol)
Move ownership of pointers to the bsp structures themselves for now.
2021-09-16 11:52:37 -04:00
Jonathan e8bd554cc0 winding_t is now a C++ type - a hybrid stack/heap array.
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
2021-09-16 03:10:51 -04:00
Jonathan eb6bb81d61 use the C++ includes
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
2021-09-14 08:46:03 -04:00
Jonathan 4e7542b111 Clang format pass
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
2021-09-14 02:32:26 -04:00
Jonathan facf3490c7 typedef changes 2021-09-13 13:04:18 -04:00
Ozkan Sezer 69cb6b981f
bsputil: write ents in binary mode and print its crc in 4-digit hex (#317) 2021-09-08 17:50:32 -06:00
Jonathan b01fddf7f1 More Q2 support 2021-09-04 18:49:01 -04:00
Jonathan eaa86c71c6
Q2BSP + QBSP (#313)
* 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
2021-08-23 09:56:33 -06:00
Eric Wasylishen c8b2f6f8e6 decompile: fix "done" message 2021-02-08 23:35:07 -07:00
Eric Wasylishen b5fcdec19e cleanup: remove "byte" typedef 2021-02-07 14:02:35 -07:00
Eric Wasylishen fcb0da5190 decompile: add a simplifed --decompile-geomonly mode 2021-02-07 00:30:49 -07:00
Eric Wasylishen d4aa42f0ab bsputil: decompiler wip 2021-01-30 14:49:18 -07:00
Eric Wasylishen 569e7fad02 bsputil: make --settexinfo operate in place on the .bsp 2020-05-14 19:53:48 -06:00
Eric Wasylishen 78e902b75e bsputil: add option for swapping a face's texinfo, --findfaces 2020-05-14 17:32:54 -06:00
Eric Wasylishen 8a47233bbf bsputil: start a --compare feature for helping with qbsp testing 2019-01-10 02:58:37 -07:00
Eric Wasylishen 5e472bf817 bsputil: --check: log world mins/maxs 2017-12-12 20:48:57 -07:00
Eric Wasylishen b85d627c8f change branding to ericw-tools 2017-10-19 16:35:37 -06:00
Eric Wasylishen b52c495574 common: fix q2 conversion bugs 2017-10-02 23:32:06 -06:00
Eric Wasylishen 7e429c560c bsputil: add --convert option 2017-10-02 18:27:20 -06:00
Eric Wasylishen 8813d272cb common, light, vis: change from bsp2_t to mbsp_t 2017-10-01 22:32:20 -06:00
Eric Wasylishen 7236e47ef4 bsputil: print used lighstyles 2017-06-25 16:40:06 -06:00
Eric Wasylishen 989f0305ba bsputil: add checks for degenerate faces, unused planes/texinfo/verts,
clipnodes
2017-06-21 16:36:12 -06:00
Eric Wasylishen 13922a2b92 bsputil --check: add some stats on visleafs and vis clusters 2017-06-21 13:24:05 -06:00