Commit Graph

57 Commits

Author SHA1 Message Date
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
Kevin Shanahan 7caeafb714 trivial: pad counts to 8 digits, sizes to 10 in output
Also do a quick sweep of the source and consistently use %d instead of
%i (no real difference, but just pick one).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 15:18:01 +09:30
Kevin Shanahan 653daa111a qbsp: invert sense of fillnode side initialisation
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 07:02:38 +09:30
Kevin Shanahan 1e39a7e614 qbsp: factor out leafnode intersection from LineIntersect_r
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 07:01:37 +09:30
Kevin Shanahan 4543817f59 qbsp: use a memset to simplify leakstate initialization
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 07:00:34 +09:30
Kevin Shanahan 347020879d qbsp: rename Error_() to Error()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 20:21:17 +09:30
Kevin Shanahan 0e586916b1 qbsp: replace error enums in outside.c, merge.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:32:52 +09:30
Kevin Shanahan 58b33cc3d4 qbsp: remplace error enums in bspfile.c
Overlapped with outside.c and portals.c for some of the file errors.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:15:38 +09:30
Kevin Shanahan b7d4127583 qbsp: delay creation of .pts and .por files until needed
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 14:47:06 +10:30
Kevin Shanahan 1e4d4225d6 qbsp: pull the .por and .pts file pointers into leakstate
That should be the last of the outside.c globals.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 14:14:42 +10:30
Kevin Shanahan 18cc6cc809 qbsp: get rid of globals v1 and v2 in outside.c
Used for working with leak lines - just pass them on the stack instead.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 13:43:47 +10:30
Kevin Shanahan 47f55c8186 qbsp: misc trivial stylistic changes to outside.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 13:30:07 +10:30
Kevin Shanahan a7e0ad3889 qbsp: trivial cleanups to WriteLeakNode
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 13:11:46 +10:30
Kevin Shanahan 2eb9c36e28 qbsp: use pointer to entity instead of index in leakstate
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 13:06:51 +10:30
Kevin Shanahan fb8852dddf qbsp: consolidate leak state into single struct
Now consolidate the leak state into a single leakstate_t struct. Rename
the leaks/numleaks/maxleaks members as portals/numportals/maxportals for
improved clarity. What was numportals previously is now numwritten.

Outleafs is now returned from the FillOutside_r function instead of
passing in a struct or int to be incremented by the function.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 12:51:36 +10:30
Kevin Shanahan 6b50c2e5ac qbsp: Separate finding leaks from outside filling
Finding leaks carries a lot more state which is not needed for the final
outside fill stage, so let's separate the two. Get rid of fillparms_t
since the only thing left was the fillmark.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 12:31:20 +10:30
Kevin Shanahan 0aa5cf42d0 qbsp: move backdraw counter into the bspleak struct
Only related to the leak files, not filling.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 11:56:44 +10:30
Kevin Shanahan 6cc26fe878 qbsp: numportals parm is more accurately maxleaks
It seems clearer now that the numportals parameter is actually used to
check that the number of leak portals we accumulate doesn't exceed the
allocated memory. Update the structs to reflect that.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 11:51:00 +10:30
Kevin Shanahan 7dbee11b78 qbsp: move leaknode into the bspleak struct
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 11:40:26 +10:30
Kevin Shanahan 2bc8a01a31 qbsp: free the leaks array after writing leak file
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 11:32:04 +10:30
Kevin Shanahan bd827266a8 qbsp: move pLeaks and numleaks into the bspleak struct
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 11:31:22 +10:30
Kevin Shanahan 54de345635 qbsp: encapsulate bspleak state in separate struct
Move the 'firstone' global into the bspleak state as a flag to indicate
whether the header has been written yet, since that's why the flag exists.
Move numportals and hit_occupied (renamed to "entity") in there as well to
keep leak related data all together.

MarkLeakTrail now directly increments bspleak->numportals so doesn't need
to return a value indicating what was written.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 10:58:25 +10:30
Kevin Shanahan 9f2691e3b6 qbsp: fix name of .por file in output
Was showing up as blah.prt.por because we had messed with the filename to
remove the prt file previously.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 10:22:31 +10:30
Kevin Shanahan 7e9b2dd43a qbsp: move number of .por portals written into fillstate
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 10:21:12 +10:30
Kevin Shanahan 744f542203 qbsp: fix handling of leak files
Previously, leak files would only be written for a leak in hull 2. This is
actually pretty bad because a small leak in hull 0 or 1 might not show up
in hull 2 and you would never get a leak file to chase it down.

Place a flag in the global mapdata to indicate whether we have written a
leak file or not so we only write for the first hull that leaks. Hullnum
is no longer needed as a parameter to RecursiveFillOutside, so remove
that from the fillparms struct.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 09:45:29 +10:30
Kevin Shanahan 4fea8f28b5 qbsp: place outside filling number into mapdata global
Remove the (file) global fillmark from outside.c and place into the global
mapadata. Pass the fillmark into RecursiveFillOutside as a read-only
parameter instead.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 09:39:15 +10:30
Kevin Shanahan 546aa817d8 qbsp: start pulling some of the global state for FillOutside onto the stack
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 08:51:03 +10:30
Kevin Shanahan 462792e03b qbsp: rename node member valid->fillmark
This is not a yes/no flag it's an integer mark to see if we have visited
the node within the same fill pass.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 08:45:47 +10:30
Kevin Shanahan d65dc77ac7 qbsp: lift the hullnum check out of MarkLeakTrail
Makes it kind of obvious now that there is a bug here - if we have a small
leak in hull 0 or 1 which is sealed in hull 2 (due to brush expansion), then
we won't get a leak trail!

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 16:01:25 +10:30
Kevin Shanahan 75ef5aa9d8 qbsp: trivial rename of local ent variables to entity
Somewhat self indulgent, but this reads easier to me now.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 15:34:52 +10:30
Kevin Shanahan 3123d51db5 qbsp: make num_visportals local to portals.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-23 20:49:14 +10:30
Kevin Shanahan e943a14944 qbsp: pass hullnum down into FillOutSide()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-18 10:27:13 +10:30
Kevin Shanahan 44a22eaa38 qbsp: move global plane and miptex data into mapdata struct
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 17:04:03 +10:30
Kevin Shanahan 0ff1446df3 qbsp: load map brushes/faces into memory in order
Instead of doing awkward gymnastics to try and load the brushes and faces
into memory in reverse order for compatibility with the original qbsp,
just load them in map file order.

Simplifies iteration over the data, particularly if I want to load less
items than the pre-parse found.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 18:15:39 +10:30
Kevin Shanahan 963b14ab3a qbsp: add mapdata struct members to track numbers of items used
Future work will break the assumption that the number of used items will
be equal to the maximum number of items, so separate the two numbers.
Replace use of maxblah with numblah as appropriate.

This makes the reverse order loading or brushes, etc. look even more
painful, so will look at whether we can change that now. As far as I know
no editors do clever things that would make the map compile "better" in a
different order - it's just that it might break some previously working
maps if they were an edge case that different ordering makes the precision
flip in a non-favourable direction.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 14:04:18 +10:30
Kevin Shanahan 40034e28d0 qbsp: rename mapdata array members to remove rg prefix
It does make them somewhat less greppable, but makes the variable naming
style more consistent with the rest of the quake utilities.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 11:13:48 +10:30
Kevin Shanahan 4750c67749 qbsp: rename count members of mapdata_t
The count members are actually where we store how much memory has been
allocated for each type of item in the mapdata struct, so rename these to
indicate these are the maximum counts.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 10:55:30 +10:30
Kevin Shanahan 7b285c347b qbsp: trivial rename of some local variables in outside.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 18:55:57 +10:30
Kevin Shanahan df7a73ca5a qbsp: Make iterative version of PointInLeaf()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 18:49:07 +10:30
Kevin Shanahan b852a4cbd4 qbsp: mark MarkLeakTrail with attribute 'noinline'
Stop RecursiveFillOutside from blowing up the stack by making sure it
doesn't pull in MarkLeakTrail when GCC optimiser starts inlining stuff.

Might be an idea to make a non-recursive version of FillOutside at some
point, since it can go *very* deep on complex maps.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 18:44:23 +10:30
Tyrann 3136594bc4 Create separate Error() function so it can be marked "noreturn"
Silences some false warnings from the compiler
2012-01-07 16:48:02 +10: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 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 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 e660c87c32 [PATCH] qbsp: remove strange comment...
Perhaps just a remnant from some previous debugging work..?

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 19:52:36 +09:30
Tyrann d6b1b4de87 [PATCH] qbsp: Utilise bsp tree properties in line intesection test
Since we've already generated a bsp tree at this point, we may as well use our
knowledge about it's properties. If our line is completely on one side of the
decision node, we only need to recurse down one of the child nodes.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 19:34:26 +09:30
Tyrann 45c5ec349b [PATCH] qbsp: Allow for FP imprecision in LineIntersect_r
We need to allow for floating-point imprecisions when testing a line against
collision with bsp surfaces. This fixes a problem where the simplified leak
line generated would appear to pass through solid surfaces in the bsp.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 19:34:21 +09:30
Tyrann bffce8c99b [PATCH] qbsp: refactor leak trail printing
Consolidate identical code from MarkLeakTrail and SimplifyLeakLine into a
separate function.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 19:34:17 +09:30
Tyrann bdbae95003 [PATCH] qbsp: Fix typo in leak file generation
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 19:34:13 +09:30
Tyrann 4464491807 [PATCH] qbsp: Use double-precision floating point
Set the vec_t type to "double" using the DOUBLEVEC_T preproccessor define. Fix
up hard-coded usages of float in various places throughout the code. Note that
texinfo_t is an on-disk structure, so that needs to stay as float and we work
around incompatibilities with the vector functions using a temporary vec3_t.

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