Commit Graph

645 Commits

Author SHA1 Message Date
Tyrann 2ef9568778 [PATCH] TyrUtils v0.2
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-23 21:02:00 +09:30
Tyrann 2ed0beb1c0 [PATCH] qbsp: Tweak epsilons
The choice of the various epsilon values is critical to having geometrically
complex maps compile correctly.

The one which seems most important (so far) is the ANGLE_EPSILON. This one
needs to be quite tight to avoid "bad things" happening when you create small
angles between adjacent surfaces.

Another epsilon inter-relationship I discovered, is that it seems
CONTINUOUS_EPSILON needs to be larger than EQUAL_EPSILON. It seems to play
havoc with the t-junction code otherwise.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-23 20:48:02 +09:30
Tyrann fba05c351a [PATCH] qbsp: Increase MAX_BSP_CLIPNODES
Offsets pointing to clipnodes were originally used as signed short (16-bit)
numbers, so that negative numbers could represent the various content types of
leaf nodes. However, only a small number of these types are required, so we
now make use of the rest of the clipnode range.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-23 20:48:02 +09:30
Tyrann 0a11bfd06b [PATCH] qbsp: Give enough space for the bsp stats output
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-23 20:48:02 +09:30
Tyrann 03edc38292 [PATCH] qbsp: Fix typo in PrintLeakTrail
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-23 20:48:02 +09:30
Tyrann 687d0d03b0 [PATCH] qbsp: Factor out WritePortals portal skip logic
When writing out portals for a node, we can skip over portals that separate
volumes with the same contents. The existing logic I find very hard to follow,
so I've separated that out in an attempt to make it more understandable.

While we're at it, equivalent logic is required in NumberLeafs, so re-use.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-23 20:48:02 +09:30
Tyrann d5f000838f [PATCH] qbsp: Remove big mapentity_t union
Remove the big union in mapentity_t, collecting together the information for
each lump in a struct. Still not 100% sure where I'm going with this, but I
think this will help me with removing some of the reliance on globals further
along (which will be important once it comes to multi-threading).

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-21 23:18:56 +09:30
Tyrann 1cfdcdb85a [PATCH] qbsp: Link against math lib
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-21 23:18:56 +09:30
Tyrann e71ab5bf24 [PATCH] qbsp: Remove weird check of cTexdata in qbsp.c::ProcessFile
Ugh, looks like this extraneous line snuck in with commit 6bb3ad32

While I'm here, I see no reason to zero pWorldEnt->cTexdata just above
either. It should already be zero'd memory from the malloc of map.rgEntities.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-21 23:18:56 +09:30
Tyrann 5b9cb50f11 [PATCH] qbsp: Fix AddHullEdge logic
Fix the logic that decided which edges were to be added to smooth the clipping
hulls. The original logic is completely backwards and throws away all the hull
edge clipping planes you want, while potentially keeping the worst corner
cases.

This patch corrects that logic - for that reason, regressions are expected as
we will now be adding more planes to the maps and clipping more things at
wierd angles. Compile times will probably increase and clipping errors will be
more common, at least until some more tuning of the various epsilons is done.

While we're hacking the function, hoist some calculations from the inner loops
up to the outermost loop. Not that this function is that performance critical.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-20 21:21:17 +09:30
Tyrann e1d076bbea [PATCH] qbsp: Re-use PlaneEqual functions in TestAddPlane
Small cleanup to TestAddPlane - re-use the PlaneEqual and PlaneInvEqual
functions and replace the "counts" array with simple booleans to record which
side of the plane has points.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-20 21:21:17 +09:30
Tyrann 01bda0c407 [PATCH] qbsp: Use hash in FindPlane
Use a hash to speed up FindPlane for maps that have huge numbers of
planes. Not many maps have enough planes that this is a win, but those maps
are the ones where speed matters most. :)

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-20 21:21:17 +09:30
Tyrann 984d696b46 [PATCH] qbsp: Make NormalizePlane tell us when the plane is flipped
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-20 21:21:17 +09:30
Tyrann de9f49f954 [PATCH] qbsp: Add missing float.h include from last patch
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-20 15:05:37 +09:30
Tyrann 1465e15bea [PATCH] qbsp: Use real int/float/double limits
Instead of just assuming that 9999 or similar is "big enough", use the
implementation defined type limits.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 20:17:23 +09:30
Tyrann 5a4499dc48 [PATCH] qbsp: select better non-axial split planes
Make ChooseMidPlaneFromList a bit more picky about the non-axial planes it
selects. This can matter a lot for maps which have a lot of non-axial-aligned
brushwork (e.g. terrain, etc.) The number of clipnodes can skyrocket if planes
are not chosen with at least a small amount of care.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 20:17:23 +09:30
Tyrann 00132a9ff0 [PATCH] qbsp: Factor out split plane metrics in solidbsp
Factor out the common split plane metric code from the SelectPlane*
functions. While we're at it, make it also work for non-axial planes using the
DivideBounds function.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 20:17:23 +09:30
Tyrann 6add073624 [PATCH] qbsp: implement sloping cuts for DivideNodeBounds
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 20:17:23 +09:30
Tyrann 0b70607015 [PATCH] qbsp: flush stdout when printing messages
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 20:17:23 +09:30
Tyrann 5cd1832e09 [PATCH] qbsp: remove trailing '/' from wadpath
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 05:32:46 +09:30
Tyrann f689c241e4 [PATCH] qbsp: Log to <mapname>.log instead of qbsp.log
To make testing easier, log the output of the job to mapname.log, rather than
qbsp.log. Probably more desirable to make the logfile selectable in the long
term, but this will help for now. Note that we now don't open the log file
until after parsing the command line options, so the Message function needs to
check the file handle before writing to it.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 05:32:46 +09:30
Tyrann 165055db7b [PATCH] qbsp: Add -wadpath option
Add the "-wadpath" command-line argument to allow the user to specify a
directory where wad files can be found. If no wadpath is given, the path
defaults to the directory where the map file is located. Absolute path names
in the worldspawn "wad" key should also work.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 05:32:46 +09:30
Tyrann eb7c5d5cca [PATCH] qbsp: Fix off-by-one error in command line parser string
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 05:32:46 +09:30
Tyrann 6bd69a0519 [PATCH] qbsp: Remove malloc retry logic
If we run out of memory, then too bad. Qbsp never _really_ takes so long that
you'd really care too much about starting again. Simplifies portability.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-08-19 05:32:46 +09:30
Tyrann b22ed2107a [PATCH] qbsp: Fix subdivide option parse error
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 22:52:02 +09:30
Tyrann c1380abe3b [PATCH] qbsp: Allow arbitrary length command lines
The options are currently parsed as a big text array, so that the parsing
function can be shared with the code to load options from a file. Anyway,
dynamically allocate the array to copy in the command line arguments rather
than restricting it to 512 bytes.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 22:52:02 +09:30
Tyrann c2084c0885 [PATCH] qbsp: Replace hard coded epsilons with defines
Fix numerous places where epsilons have been hard-coded, substituting one of
the defines from qbsp.h.

A couple of epsilons have actually been changed in this patch; the one used to
detect degenerate QuArK texture coordinates has been loosened (so the test is
actually a little more strict). The other is the test for flipped portals. If
my understanding is correct, then result would actually be < 0 if the portal
winding normal flipped, so this change _should_ be harmless.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 22:52:02 +09:30
Tyrann b7f84130de [PATCH] qbsp: Collect all epsilons together in qbsp.h
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 22:52:02 +09:30
Tyrann c221cc2f08 [PATCH] qbsp: Update IntroString / version number
I better replace the IntroString with my own, so it's obvious people are
running a modified version.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 13:47:08 +09:30
Tyrann 2e4a4a917f [PATCH] bsputil: Attempt correct byte-swapping in bsp -> wad export
Untested, but this should be all that is required.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 13:02:07 +09:30
Tyrann 05dab0640e [PATCH] qbsp: Tidy up PrintOptions
Let PrintOptions break the "80-columns" rule; it's less hideous that way.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-09 12:09:42 +09:30
Tyrann 6027e5aeb3 [PATCH] bsputil: Add texture extraction
Add the ability to extract texture information from a BSP file and write it
out as a WAD file. Not very robust in the face of errors or corrupt BSP files,
but it does the job for now.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-03 08:53:05 +09:30
Tyrann b05f86296d [PATCH] qbsp: Avoid some unnecessary face splits
Save some memory in CSGFaces by not splitting faces outside the brush being
processed. Normally these faces will be split by the planes of the brush, even
if the brush doesn't intersect with it at all. This also saves some time in
MergeFaces, since we don't need to re-assemble these faces again.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 20:14:01 +09:30
Tyrann 118916b825 [PATCH] qbsp: Refactor some winding clip/split code
Each of ClipWinding, DivideWinding and SplitFace need to calculate on which
side of the split plane each winding point lies. Split this operation out into
a shared function.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 19:46:43 +09:30
Tyrann fa7e4c9671 [PATCH] qbsp: Use winding_t for face_t's winding
Rather than using it's own type of winding, make face_t use the existing
winding_t struct to define it's edges. I tried dynamically allocating the
winding as needed, but it was a net performance loss (though much better for
memory usage). For now we'll just embed a winding_t struct inside face_t
instead.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 19:46:35 +09:30
Tyrann e214ca10db [PATCH] qbsp: Print human-readable peak memory usage values
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 19:11:59 +09:30
Tyrann d09b5657f2 [PATCH] qbsp: Fix reporting of peak winding memory use
The number reported for peak memory usage by winding_t structs was not
accurate, due to just using the sizeof(winding_t) for accounting. Track the
_bytes_ used by each type in a separate array. This is pretty much redundant
for everything except windings, but it's the simplest way to implement it for
now.

Also tidied up the verbose memory output a bit - the total column is pretty
useless, so just don't print it. Re-align the other columns and special case
the "Total" line, as only the "Peak Bytes" value is really interesting.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 17:56:34 +09:30
Tyrann 747631223c [PATCH] qbsp: Complete removal of wadlist_t
Make all WADList functions take a pointer to the first wad_t, rather than
embedding it inside the struct wadlist. wadlist_t is no longer needed.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 14:26:27 +09:30
Tyrann 39d6337fe3 [PATCH] qbsp: Remove numwads from wadlist_t
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 14:08:58 +09:30
Tyrann 582b3db593 [PATCH] qbsp: Pass numwads into other wadlist functions
After applying this patch, wadlist_t::numwads is essentially unused.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 14:03:12 +09:30
Tyrann 71c45cd883 [PATCH] qbsp: Return number of wads in WADList_Init
Begin breaking down the wadlist_t structure by having the Init function return
the number of wads loaded to the caller, rather than relying on just setting
it internally.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 13:52:33 +09:30
Tyrann 6bb3ad326e [PATCH] qbsp: Load mapname.wad when no other wads available
If the map has no wad key, or none of the wad files found in the key can be
loaded, then try loading mapname.wad as a default.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 13:39:42 +09:30
Tyrann 60d1e22160 [PATCH] qbsp: Fix warning about invalid wads
Add back the warning message about invalid wads. Don't bother to differentiate
between filesystem errors and bad magic, etc. The file is already open, so if
we can't read it's either too small or there might be some hardware problem
(not worth dealing with separately).

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 12:58:44 +09:30
Tyrann a2e9503fdc [PATCH] qbsp: WADList_Init/LoadLumpInfo cleanup
Move the logic from WADList_LoadLumpInfo into WADList_Init. Now the init
function will open all the wad files, testing for validity. Note that I still
need to tidy up the error handling and warnings a little bit to handle the
difference between filesystem/read errors and invalid/corrupt wad files.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 12:31:35 +09:30
Tyrann d578113a47 [PATCH] qbsp: Improve variable naming in WADList LoadLumpInfo
Renaming a few variables to keep things nice and clear:
- w    -> list      ; the wadlist_t
- list -> wadstring ; the string from the map's "wad" key
- wad  -> w         ; local pointer to a single wad

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 10:52:40 +09:30
Tyrann f089c31fce [PATCH] qbsp: More wad structure naming cleanups
Rename a couple more structure members to make their purposes clearer;
- wad_t::Wad -> wad_t::file             - it's a file handle
- wadlist_t::wadlist -> wadlist_t::wads - yes, we already know it's a list

Also, get rid of fileT from WADList_LoadLumpInfo.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 10:29:54 +09:30
Tyrann fbe06cdb51 [PATCH] qbsp: Swap wad_t and wadlist_t struct names
The wad_t struct is actually a list of wads, and the wadlist_t struct
represents the info for a single wad. This is kind of backwards, so reverse
the names. A few function renames went along with this to make things look
saner.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 10:00:12 +09:30
Tyrann bba30bcc2e [PATCH] qbsp: Remove unnecessary name field from wad_t
wad_t::name isn't required outside of some temporary usage in WAD_InitWadList
so doesn't really belong in the struct.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-02 09:30:27 +09:30
Tyrann c5b7fa7d2b [PATCH] qbsp: Account size of winding_t allocations
Memory stats are reported inaccurately because the memory allocated to
windings is not accounted correctly (when freed, in particular). Use the usual
technique of recording the allocated size in the same block of memory, just
before the portion returned to the caller.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-10-01 20:21:44 +09:30
Tyrann 47c83e7db7 [PATCH] qbsp: Don't overwrite wad list length
Fix a bug introduced in my class File -> stdio conversion. Don't use the len
variable to save the result of fread, since it's still needed as part of the
loop condition!

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-25 20:16:18 +09:30