Commit Graph

200 Commits

Author SHA1 Message Date
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
Eric Wasylishen ab4fa45306 vis: various fixes for vising q2 maps
# Conflicts:
#	vis/vis.cc
2021-09-23 14:46:28 -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 2ebfdb096f Remove COM_Parse, use parser_t
Game controls hull sizes now
2021-09-20 19:45:09 -04:00
Jonathan 403bae7a7b Merge branch 'type-cleanup' of https://github.com/Paril/ericw-tools into type-cleanup
# Conflicts:
#	vis/vis.cc
2021-09-19 22:23:54 -04: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
Eric Wasylishen 195921a916 vis: various fixes for vising q2 maps 2021-09-18 00:04:33 -06:00
Jonathan 261f08f132 Attempt (but failure) at fixing Q2 vis 2021-09-17 04:49:04 -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 1dd4df1b20 calloc/malloc/free -> new/new/delete (except for specific scenarios) 2021-09-14 11:39:12 -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 7f8d2cfb49 Fix single line functions 2021-09-14 02:56:44 -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 c95a1e2ccb q2 and bug fixes
# Conflicts:
#	include/qbsp/qbsp.hh
#	include/qbsp/winding.hh
#	qbsp/brush.cc
#	qbsp/csg4.cc
#	qbsp/merge.cc
2021-09-12 08:34:01 -04:00
Eric Wasylishen 527c63f55f build: remove obsolete cmake min required in subprojects 2021-09-12 01:30:20 -06:00
Jonathan 00efa6e67d Fix operator<
Introduce gamedef, to reduce rewriting of data in bspversions
fix name of needs_subdivision
include value in texinfo, in prep for Q2
2021-09-07 01:41:32 -04:00
Jonathan 437459a4dd Finish using game everywhere 2021-09-06 18:09:13 -04:00
Jonathan 90973e1198
Q2bsp VIS support (#315)
* 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
2021-08-31 22:38:12 -06: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 d6c888bee9 vis add -nostate debug option, skips loading from state file 2021-08-15 13:22:57 -06:00
Eric Wasylishen c9570260fa gcc 11: pass constant to offsetof 2021-05-30 23:12:17 -06:00
Eric Wasylishen b5fcdec19e cleanup: remove "byte" typedef 2021-02-07 14:02:35 -07:00
Eric Wasylishen 9124653156 common: move EntData_ function to common 2021-01-30 21:11:25 -07:00
tk 19f8ac8110
Add -visdist param from bjptools (#300)
* Add support for -visdist param from bjp tools

* add mention to man

Co-authored-by: Shpuld Shpuldson <shp@cock.li>
2020-09-18 19:11:38 -06:00
Eric Wasylishen 74e1a0f6f0 vis: fix for microleafs blocking vis
Fixes #261
2019-03-24 21:14:57 -06:00
Eric Wasylishen 80dc99ebee vis: soundpvs.cc:SurfaceBBox: fix uninitialized mins[2]/maxs[2], spotted by anotak 2018-07-06 23:04:01 -06:00
Eric Wasylishen 7bb84a7119 vis: fix "average leafs visible" overflowing 2018-03-18 20:02:35 -06:00
Eric Wasylishen abf2a3665b vis: fix to use mbsp_t 2017-10-24 20:01:04 -07:00
Eric Wasylishen b85d627c8f change branding to ericw-tools 2017-10-19 16:35:37 -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 258f69a27f Revert "vis: remove max portals on leaf limit"
This reverts commit b111346cca.
2017-09-15 14:32:13 -06:00
Eric Wasylishen b111346cca vis: remove max portals on leaf limit 2017-09-13 13:29:46 -07:00
Eric Wasylishen 902c45c946 all: make VectorCompare take an explicit epsilon 2017-04-26 14:20:45 -06:00
Eric Wasylishen 8a4d1ff218 common: add 4x4 (from mesa) and 2x2 matrix inverse 2017-04-23 15:58:51 -06:00
Eric Wasylishen 880ad3b381 bpsutil, common, light, vis: bounds check bsp->dfaces access 2017-03-18 16:31:52 -06:00
Eric Wasylishen 2a17b4bccf build fix 2017-02-12 11:54:52 -07:00
Eric Wasylishen a6468984bf all: finish c++ification 2016-10-17 19:52:17 -06:00
Eric Wasylishen 299e68e7e5 build: support Ubuntu 14.04 2016-09-23 15:13:58 -06:00
Eric Wasylishen 9340ce223a build: clean up request for C++11. require cmake 3.1 (which introduced CMAKE_CXX_STANDARD) 2016-08-09 16:00:09 -06:00
Eric Wasylishen 67a64f9be4 vis: support PRT1-AM portals generated by txqbsp-xt 2016-04-29 12:20:35 -06:00
Eric Wasylishen c83fd942bd build: fix vis build on Windows 2016-04-18 13:54:47 -07:00
Eric Wasylishen b087f0f010 build: specify c99 2016-04-18 14:22:33 -06:00
Eric Wasylishen bfca3478cc build: link vis to libm, fixes build on Linux / GCC. 2016-04-18 14:02:49 -06:00
Eric Wasylishen 98a020fde7 vis: fix ambient sounds when using func_detail, broken in tyrutils-ericw-v0.15.3 2016-03-04 15:38:08 -07:00
Eric Wasylishen 99d5a4d4f9 build: setup CPack to package binaries in a zip file 2015-12-09 16:23:36 -08:00
Eric Wasylishen 420125cc67 replace tabs with spaces.
for FILE in $(find . -name "*.h" -or -name "*.c"); do cat $FILE | expand > temp; cat temp > $FILE; done
2015-12-07 15:08:48 -07:00
Eric Wasylishen c149ed2bf6 build: VS2015 support 2015-12-07 14:23:13 -07:00
Eric Wasylishen 3f03b6dfd5 vis: fix "average leafs visible" message after last change 2015-10-20 15:25:44 -06:00
Eric Wasylishen 545ba66ebc vis: Reuse each cluster's visdata for all leafs in the cluster 2015-10-20 02:26:35 -06:00
Eric Wasylishen 3005504fe5 vis, light: set low process priority on windows 2015-08-05 12:10:17 -06:00
Eric Wasylishen 3a109ac84d build: split up cmake build system into subprojects.
-DDOUBLEVEC_T now correctly used for qbsp only.
2015-05-05 12:34:39 -06:00
Kevin Shanahan 4b1e3aec1a light, vis, bsputil, bspinfo: Add BSP2 support
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>
2013-09-25 15:18:50 +09:30
Kevin Shanahan e970bea8c7 common: save the bsp version in the bspdata struct
Adjust the Load and Write API functions as appropriate.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-22 13:25:47 +09:30
Kevin Shanahan 89abf25218 common: convert all tools to instanced bsp data
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>
2013-08-22 11:01:08 +09:30
Kevin Shanahan d0617760f5 common: add the ability to pass an arg to spawned threads
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 19:27:40 +09:30
Kevin Shanahan 51419621ec common: add the bsp2/bsp29 data types
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>
2013-08-20 13:25:16 +09:30
Kevin Shanahan 31cdb99ac6 vis: make leaf recursion a warning in LeafFlow
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>
2013-05-08 11:33:35 +09:30
Kevin Shanahan 9ea5aaa1db vis: tidy up definitions of LogLeaf/LogWinding
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-05-08 11:32:57 +09:30
Kevin Shanahan c0d03cba32 vis: constify source argument to copy winding
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-05-08 11:32:12 +09:30
Kevin Shanahan 54e0e55113 vis: fix missing vertex on clipped portals (argh!!!)
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-25 07:58:43 +09:30
Kevin Shanahan a9cfbbc3dc trivial: fix missing newline at end of usage output
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 14:26:21 +09:30
Kevin Shanahan c3bf54e494 common: add printf attribute to Error() declaration in cmdlib.h
Fix a number of warnings now generated as a result.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-23 14:39:44 +09:30
Kevin Shanahan 37f87a28be vis, qbsp: improve robustness of ClipWinding/DivideWinding
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>
2013-04-23 14:00:31 +09:30
Kevin Shanahan d3a75f6c1a vis: use uintptr for FreeStackWinding index check
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>
2013-04-21 10:17:40 +09:30
Kevin Shanahan 97371bc6ab vis: allocate extra dist/sides slot in ClipStackWinding
We use one extra to simplify checking when an edge crosses the split
plane.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:14:54 +09:30
Kevin Shanahan ba88986462 vis: fix portal stack corruption in ClipStackWinding
Need to re-check numpoints before we add a split point.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:13:27 +09:30
Kevin Shanahan 186ca8863b vis: fix stack separator cache overflow check
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:10:13 +09:30
Kevin Shanahan d14793f7ab common: make LoadBSPFile take a bspdata struct
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>
2013-04-20 16:51:45 +09:30
Kevin Shanahan 35024bfa7d common: make dtexdata a union
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>
2013-04-20 16:34:30 +09:30
Kevin Shanahan 37a3a98eff common: make WriteBSPFile take a bspdata struct as input
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-20 15:52:31 +09:30
Kevin Shanahan 9c8cbfd601 vis: add the -noambient* options to disable auto ambient sounds
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-28 08:28:47 +10:30
Kevin Shanahan 34401e91ee vis: change the default testlevel to 4
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-14 11:36:41 +10:30
Kevin Shanahan 7b36c6fd2f build: query git for version info and print consistently for each util
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 14:26:14 +10:30
Kevin Shanahan c0f9b19868 vis: add detail brush / prt2 support
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>
2013-02-25 12:32:35 +10:30
Kevin Shanahan 3e12ff141d vis: pass the input buffer length into CompressRow
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-25 12:26:19 +10:30
Kevin Shanahan 5c0826168a vis: fix memory leaks in state load/save paths
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-12 09:33:31 +10:30
Kevin Shanahan ac75b94345 vis: include unistd.h header for unlink() call
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-09 16:55:19 +10:30
Kevin Shanahan 4161d10a68 vis: add saving and resuming of vis state to/from disk
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>
2013-02-09 16:40:37 +10:30
Kevin Shanahan 06e50087ad vis: remove unneeded carriage-returns from output
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-08 16:53:30 +10:30
Kevin Shanahan 3e20dae28e common: add start arg to RunThreadsOn to set initial progress
In case we are not starting work from 0, allow this to be set...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 20:51:04 +10:30
Kevin Shanahan 853761d0d6 common: remove pacifier argument from RunThreadsOn
Set to true everywhere, just use it unconditionally.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 20:46:33 +10:30
Kevin Shanahan f0d3172d77 vis: calculate shift from loop variable instead
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 19:44:48 +10:30
Kevin Shanahan 148b07ef17 vis: remove old progress output message
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-07 19:38:36 +10:30
Kevin Shanahan 815fd70265 vis: use leafbits_t struct and helpers to represent vis bit strings
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>
2013-01-19 12:12:47 +10:30
Kevin Shanahan 0192b3d732 vis: remove the MAX_PORTALS limit
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-26 17:49:20 +10:30
Kevin Shanahan ecb66fb2aa vis: convert full vis to use the thread progress code
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-26 14:01:26 +10:30
Kevin Shanahan b538bed05f trivial: whitespace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-26 11:29:11 +10:30
Kevin Shanahan 686d4451b8 vis: thread the base portal vis
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>
2012-12-26 11:27:29 +10:30
Kevin Shanahan c42f0e26b4 vis: use the common threads code
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-26 10:38:50 +10:30
Kevin Shanahan af9da631fd vis: create two separate verbosity levels
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>
2012-12-26 10:22:55 +10:30
Kevin Shanahan 2bbcdff931 vis: Try to propogate some extra vis info from completed portals
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>
2012-12-26 09:30:56 +10:30
Kevin Shanahan 725da016a4 vis: use INT_MAX in GetNextPortal
Tidy up variable names a little.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-25 21:30:00 +10:30
Kevin Shanahan a10316d7c9 vis: rename vstatus to pstatus
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-25 21:28:20 +10:30
Tyrann ad964e7f28 trivial: remove some redundant assignments and unused variables 2012-01-06 21:34:47 +10:30
Tyrann ce369bfdd6 Use offsetof() consistently
And include stddef.h where we do use it
2012-01-06 21:32:53 +10:30
Tyrann 2c2f3c8eb6 Import initial sources 2006-08-28 23:58:10 +09:30