Commit Graph

701 Commits

Author SHA1 Message Date
Eric Wasylishen 177e037de3 qbsp: better bounds checking for mapbrush_t::face and mapentity_t::mapbrush 2016-03-20 20:02:39 -06:00
Eric Wasylishen 86e92ee6b3 qbsp: add missing include 2016-03-20 14:08:34 -06:00
Eric Wasylishen 60c0b64906 qbsp: change mapdata_t to use std::vector 2016-03-20 14:02:31 -06:00
Eric Wasylishen f3639eb1e3 qbsp: csg: rewrite planefaces structure to use std::map 2016-03-12 14:23:26 -07:00
Eric Wasylishen 4ee88ede3b qbsp: turn map.num* into functions 2016-03-12 13:50:24 -07:00
Eric Wasylishen 3db441eea2 qbsp: rename files to .cc 2016-03-12 13:02:28 -07:00
Eric Wasylishen ecff3f77a8 qbsp: add casts to compile as c++ 2016-03-12 13:00:33 -07:00
Eric Wasylishen 923118dfc6 qbsp: convert qbsp.c to c++ 2016-03-11 20:43:05 -07:00
Eric Wasylishen 4f66bd7ddc qbsp: grow texinfo array as needed 2016-03-11 19:30:20 -07:00
Eric Wasylishen 6e94f6a1c2 qbsp: c++ compat changes 2016-03-11 19:25:55 -07:00
Eric Wasylishen a4c24ac0fa qbsp: add -objexport flag to export to obj 2016-03-11 18:29:24 -07:00
Eric Wasylishen 41972a376a qbsp, light: Strip texinfo flags other than TEX_SPECIAL.
Write extended ones to a "mapname.texinfo" file.
Support "_dirt" and "_minlight" flags on func_detail/group.
2016-03-05 00:26:54 -07:00
Eric Wasylishen 492d94c1fe light: new phong shading keys, "_phong_angle" and "_phong".
"_phong" "1" is a shortcut for "_phong_angle" "89".
"_phong_angle" sets the max angle in degrees between faces that will get smoothed.
2016-03-02 20:00:05 -07:00
Eric Wasylishen 1a436d8f13 qbsp: fix for comments not incrementing line count.
fixes https://github.com/ericwa/tyrutils-ericw/issues/11
2016-02-25 13:17:53 -07:00
Eric Wasylishen 7128a8e956 code formatting, normalize most whitespace to 4 spaces 2016-02-15 16:20:29 -07:00
Eric Wasylishen 1da64c0db4 Fix bspx lump padding logic 2016-02-15 16:20:29 -07:00
Eric Wasylishen 1f05b7976a fix wrong FindTexinfo call
fix Lightmap_ForStyle call
change M_PI to Q_PI
switch to Q_strncasecmp
2016-02-15 16:18:51 -07:00
Eric Wasylishen 1630b8756e tyrutils-ericw-spike rebased on to 998c9d3acb 2016-02-15 16:16:37 -07:00
Eric Wasylishen 998c9d3acb qbsp: add hint to use -bsp2 to fix "Too many vertices" error. 2015-12-16 12:27:57 -07:00
Eric Wasylishen ab268ab9ba qbsp: CheckFace: print position of non-convex face 2015-12-10 15:58:40 -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 dd440699fc qbsp: remove 128 character limit on key+value line 2015-12-08 23:25:53 -07:00
Eric Wasylishen 063786bf02 build: fix spurious errors in VS2015 IDE 2015-12-07 14:37:46 -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 0ec1c96a06 build: fix warning 2015-12-07 14:40:44 -07:00
Eric Wasylishen c149ed2bf6 build: VS2015 support 2015-12-07 14:23:13 -07:00
Eric Wasylishen 5face9dd51 qbsp: round texture vector values that are within ZERO_EPSILON of integers,
to attempt to attempt to work around corrupted lightmap sizes in DarkPlaces
(it uses 32 bit precision in CalcSurfaceExtents)
2015-12-04 15:49:23 -08:00
Eric Wasylishen fee62faa24 qbsp: Print coordinates in "CheckFace: too few points" error 2015-11-20 17:15:59 -07:00
Eric Wasylishen a5a2de6c6f qbsp: add coordinates to "New portal was clipped away" warning, from txqbsp-xt 2015-10-26 13:42:42 -06:00
Eric Wasylishen fddb87287a qbsp: DividePlane: always use bugfix from 7e7d851 regardless of maxNodeSize setting 2015-10-23 17:22:05 -06:00
Eric Wasylishen 0bc85020d2 qbsp: ChooseMidPlaneFromList: mark detail separators on the final SolidBSP pass. 2015-10-19 20:19:25 -06:00
Eric Wasylishen 44e1eccca6 qbsp: change detail handling, from qbsp-xt.
MidSplit now does two passes (structural/detail), like ChoosePlaneFromList.
Now, the first pass will pick among planes that have at least one structural face, and zero or more detail faces.
The second pass will pick among planes that have no structural faces, and zero or more detail faces.

This fixes the hull 1 leak in telefragged.map introduced when I added txqbsp's maxNodeSize feature,
and also reduces the cluster and portal count in jam6_ericwtronyn.map a bit.
2015-10-18 14:28:36 -06:00
Eric Wasylishen ddfa2c7ad5 merge: don't merge detail and non-detail 2015-10-18 00:21:09 -06:00
Eric Wasylishen a596187841 hexen2 support: fix "qbsp -onlyents" which broke with the hexen2 patch 2015-10-17 01:38:24 -06:00
Eric Wasylishen a3b985e721 hexen2 support, patch from Spike 2015-10-16 21:18:53 -06:00
Eric Wasylishen a75de817b1 qbsp: add -epsilon option to set ON_EPSILON, from txqbsp-xt 2015-09-27 00:53:55 -06:00
Eric Wasylishen 7e7d851fdb qbsp: DividePlane: add missing recalculation of surface bbox for the parallel case.
Thanks to rebb for the idea, txqbsp has the workaround in SelectPartition that recomputes the surface bbox; I think this fixes the underlying bug though.

Note: this makes telefragged.map (from the RRP devkit) leak in hull 2.
However, the point file starts at a func_detail staircase that, if turned into func_wall, fixes the leak.
2015-09-16 22:49:33 -06:00
Eric Wasylishen 3322ffb8f3 qbsp: add -maxnodesize option from txqbsp-xt. Defaults to on, nodes with a bbox with any dimension exceeding 1024. 2015-09-16 21:31:44 -06:00
Eric Wasylishen 20901a5a7d qbsp: update usage text 2015-08-09 13:45:30 -06:00
Eric Wasylishen 3877a213a0 qbsp: use -oldaxis by default 2015-08-09 13:36:13 -06:00
Eric Wasylishen a7b1ae851b qbsp: make degenerate edge error in tjunc.c into a warning. from txqbsp-xt. 2015-08-01 20:07:51 -06:00
Eric Wasylishen 9fd7305479 qbsp: make "mixed face contents" error non-fatal if one of the leafnode or face is CONTENTS_EMPTY. from txqbsp-xt.
Fixes an issue necros was having.
2015-07-30 18:33:52 -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
Eric Wasylishen 67cec03ac8 qbsp: fix broken -onlyents option by moving model allocation from map.c to ExportDrawNodes 2015-04-29 16:07:14 -06:00
Eric Wasylishen ed66ed112e qbsp: fix texture offset on rotate_object, so they match in the editor. Added "-oldrottex" flag to revert to old behaviour. From txqbsp-xt. 2015-04-29 16:07:07 -06:00
Eric Wasylishen d77a7d768c qbsp: switch to hardcoded MAX_MAP_PLANES. counting unique planes was slow 2015-04-25 23:09:35 -06:00
Eric Wasylishen 28e460be9a qbsp: MakeFaceEdges: accelerate with a hash table to avoid slow O(n^2) search for edges 2015-04-25 22:49:40 -06:00
Eric Wasylishen 1812734037 qbsp: ChooseMidPlaneFromList: fix off-by-one error in axial plane test. On the first SolidBSP pass, gives fewer split nodes on bbin1.map (128k vs 199k) 2015-04-25 21:01:49 -06:00
Eric Wasylishen 5111c5485c qbsp: account for miptex struct in wad3 lump disksize
Here's another little tyrutils patch: in qbsp, I believe the
calculation of the "disksize" field of the miptex lumps when using
WAD3 textures is missing the size of the dmiptex_t struct (40 bytes),
causing the resulting bsp file to be slightly truncated.

I noticed this because one of Tronyn's levels (jam2_tronyn.bsp) was
crashing Quakespasm for me; it turned out the engine was trying to
read 40 bytes past the end of the file when loading the last texture
in the bsp. I got him to send over his map source, wads, and compiler;
he was using tyrutils 0.15 and wad3 format textures, and I confirmed
that this patch fixes the engine crash.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-10-30 12:54:36 +10:30
Kevin Shanahan 90aa616866 qbsp: fix coordinates in degenerate edge error in tjunc.c
The error message was actually displaying the edge vector, which is
always going to be ~(0,0,0).  Pass in the edge end points and then we
can display both the length of the edge and the location of one end
point.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-05-06 20:30:15 +09:30
Kevin Shanahan df9c82eb91 qbsp: improve a few error messages using new line number info
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-02-13 15:57:01 +10:30
Kevin Shanahan 06583de238 qbsp: save line number information when generating faces
To improve debug messages, save the line number of the faces as we
generate them and in the case of hull generation, save a pointer back
to the source brush.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-02-13 15:55:23 +10:30
Kevin Shanahan e40c68a8b8 qbsp: use explicit cast to short in ExportLeaf_BSP2 node bounds
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2014-02-13 15:00:05 +10:30
Kevin Shanahan fa48825cb5 qbsp: make transparent water the default for visibility calculations
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-12-24 19:08:46 +10:30
Kevin Shanahan f9d1f50cf3 qbsp: increase MAXEDGES from 32 to 64
Should still be enough stack space... I think.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-12-24 19:04:57 +10:30
Kevin Shanahan 88db6a79b1 qbsp: remember to ignore func_group entities for -onlyents compiles
Otherwise, we break the brush model names (numbering).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-12-02 15:06:40 +10:30
Kevin Shanahan e8d1f59d11 qbsp: fix parsing of texture names containing curly braces
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-10-04 09:21:04 +09:30
Kevin Shanahan 456565d17f qbsp: add the -2psb command line option to output RMQ style BSP2
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-10-03 11:09:25 +09:30
Kevin Shanahan f972f19f39 qbsp: ignore leading path in texture names for Quake 2 compatibility
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-10-01 12:42:25 +09:30
Kevin Shanahan 1196dd8a82 qbsp: ignore extra surface flags found in Quake 2 map files
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-10-01 12:34:59 +09:30
Kevin Shanahan 4a487955c8 qbsp: add a PARSE_OPTIONAL parser flag
Enables us to check if there is extra data on the same line, without
advancing the parser past the end of line.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-10-01 12:34:01 +09:30
Kevin Shanahan ae060bf0fe qbsp: add any extra animation frames for used textures
Search the WADs for extra frames on any animated textures used and add
them to the bsp.  This restores the old behaviour which was mistakenly
removed, but now we have the assurance that textures are added in
order and all lower numbered animation frames are added a warning is
printed if it is missing from the wad.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-30 13:09:45 +09:30
Kevin Shanahan 55d717d3fe qbsp: fudge miptex count to work around tiny maps with lots of animating textures
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-30 13:08:10 +09:30
Kevin Shanahan 543d177d66 qbsp: correctly handle func_groups with no solid brushes
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-30 12:29:41 +09:30
Kevin Shanahan 83686fe0f1 qbsp: consistently use strcasecmp to compare entity keys
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-30 12:27:53 +09:30
Kevin Shanahan cb091642c7 qbsp: fix non-solid sky brushes in the collision hulls
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-29 08:40:07 +09:30
Kevin Shanahan 50b78f3d61 qbsp, common: support both DP and RMQ variants of the BSP2 format
Turns out there are two types of "BSP2" format - one that I think was
created by MH and implemented in the RMQ project (this is the one I
implemented previously) and one by LordHavoc which exteneded the
coordinate limits beyond 32k, implemented in Darkplaces.  The
Darkplaces version of BSP2 will get the name BSP2 and the RMQ version,
which is more limited, will get the name BSP2rmq.

qbsp will only create the BSP29 or BSP2 formats, but will cope with a
BSP2rmq format file for an -onlyents compile.  The rest of the tools
can use any of the three formats.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-09-28 11:48:37 +09:30
Kevin Shanahan 5facda6ff9 common: constify vec3_origin
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 13:30:05 +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 69c86e59b8 common: move AMBIENT and MAXLIGHTMAP definitions
Keep the ambient sound definitions near the leaf and lightmaps limit near
the face definition.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 12:20:57 +09:30
Kevin Shanahan 58c6335434 qbsp: don't bail out on 65535 verticies for bsp2 output
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 17:09:23 +09:30
Kevin Shanahan 85581b6c0c qbsp: output leafs, nodes and marksurfaces in bsp2 format
This completes the basic BSP2 support.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 17:09:10 +09:30
Kevin Shanahan ce26465f57 qbsp: output clipnodes in bsp2 format
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 16:39:24 +09:30
Kevin Shanahan 083dc9fda1 qbsp: add output of faces and edges using bsp2 format
Won't produce a working bsp2 file yet, but if you ask for bsp2 on the
command line now, faces and edges will be output in bsp2 format.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 16:20:55 +09:30
Kevin Shanahan 9c3613e47f qbsp: duplicate the MemSizes array for the two BSP formats
Kind of taking a step backwards here to where we were, but make the
MemSizes array dynamically changable so that we can switch out and
allocate BSP2 sized elements when we want to write a file in that format.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 14:36:40 +09:30
Kevin Shanahan bf3ea6374c qbsp: separate the lump numbering from the memory sizes array order
Some of the bsp2 data structures are bigger than the bsp29 structures, so
we need to know the difference in allocation size.  Stop using the data
structure enum for lump numbers.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 12:22:21 +09:30
Kevin Shanahan 2d65515d0f qbsp: add bsp2 data types to bspfile.h
In preparation for bsp2 support, add the data types for bsp2 structures
to bspfile.h and rename the bsp29 structures to properly differentiate them.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 10:25:17 +09:30
Kevin Shanahan 32973e6779 qbsp: re-format the memsize global array
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 10:13:11 +09:30
Kevin Shanahan 330d5270dd qbsp: separate out bspfile.h from qbsp.h
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 09:46:23 +09:30
Kevin Shanahan d7d6c4939c qbsp: minor cleanup in FindFaceEdges
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 17:14:36 +09:30
Kevin Shanahan 876ac97cbe qbsp: small cleanups in GetVertex
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 17:01:24 +09:30
Kevin Shanahan 0269ad8edb qbsp: show the error margin when non-convex faces are found
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:57:40 +09:30
Kevin Shanahan aa4f577a6d qbsp: constify some more arguments to GetEdge
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:41:44 +09:30
Kevin Shanahan ad25768498 qbsp: exit with error if vertices exceed 65535
Unable to represent this in the bsp29 format, so let the user know instead
of silently corrupting the bsp.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:11:41 +09:30
Kevin Shanahan 0bf7fc3374 qbsp: remove ununsed c_tryedges variable
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 15:05:21 +09:30
Kevin Shanahan ca02e17b60 qbsp: minor cleanups to CheckFace
Print the length of the degenerate edge if one is detected,
Rename a few variables, etc.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-16 13:03:45 +09:30
Kevin Shanahan 221d6ca2a3 qbsp: make sure to add animating texture frames in order
We take care of adding extra animation frames during loading of the map
file to ensure that we add lower-numbered texture frames before the higher
numbered frames.  Most Quake engines will choke on a BSP if the texture
frames are presented out of order (including the original).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-13 16:27:05 +09:30
Kevin Shanahan 272816d24f qbsp: increase MAXTOKEN to 1024 to cope with long "wad" keys
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-05 10:08:49 +09:30
Kevin Shanahan e3a5b57ba4 qbsp: add "-forcegoodtree" command line option
Normally we build a fast, unoptimized bsp tree for the world before
culling outside surfaces.  This command line switch forces the use of
the more expensive algorithm for this processing stage.  Seems to have
a positive effect on the final BSP in terms of reduced marksurfaces
and smaller file size, at the expense of longer processing time.

Marked experimental for now, as it may be removed later (either by
making this behaviour the default or removing it altogether).

Credit to Rebb from func_msgboard for implementing this tweak first in
his qbsp util.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-25 13:59:24 +09:30
Kevin Shanahan 7882af13a9 qbsp: replace global face list with local in tjunc_fix_r
Explicitly pass the face list around to be added to as needed instead
of implicit reference to the global 'newlist'.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-25 11:00:24 +09:30
Kevin Shanahan 06166f43d8 qbsp: allocate the superface for tjunc fixes dynamically
Remove the global static buffer and allocate the superface when
processing tjuncs.  Also check that we are not overflowing the buffer
before adding more vertices - probably something went wrong if this
ever overflows, so better to crash with a definite error than scribble
random memory.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-25 10:39:00 +09:30
Kevin Shanahan 53a340ff04 qbsp: trivial typo in comment
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-24 14:04:23 +09:30
Kevin Shanahan 83b54b90f7 qbsp: improve calculation of allocation for dmiptexlump
Use offsetof for the count/offsets and tidy up the local comments
while we're at it.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-24 14:00:58 +09:30
Kevin Shanahan 7a65efbc00 qbsp: define offsetof to builtin if not defined
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-24 13:58:58 +09:30
Kevin Shanahan ff9bb3eab0 qbsp: tweak T_EPSILON to be greater than EQUAL_EPSILON
The way wedge_t and wvert_t were hashed and compared was resulting in
FixFaceEdges being able to get stuck in a loop adding verticies to a face
if two consecutive verticies were very close to EQUAL_EPSILON apart.
Avoid these problems by tweaking T_EPSILON to be slightly wider than
EQUAL_EPSILON.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 14:22:13 +09:30
Kevin Shanahan 6d6a787185 qbsp: comment wvert_t and wedge_t structures
Took me some time to work out what this was all representing and that t
was the parameter to the parametric equations of the edge's line in 3-d
space.  May as well make it easier for others and my future self.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 14:20:54 +09:30
Kevin Shanahan 3cfc4a27cc qbsp: access f->w through local pointer in SplitFaceForTjunc
No functional changes, just making the previous cleanup more consistent.
Pointer is non-const now, but no matter.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 14:19:50 +09:30
Kevin Shanahan 91ae3d16d9 qbsp: cleanups in SplitFaceForTjunc
Mainly tidy up long lines and rename dir/test variables to edgevec[2]
since these are the edge vectors we are testing the angles between.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 11:37:40 +09:30
Kevin Shanahan 72fd4caab7 qbsp: rename wedge_t locals from 'w' to 'edge'
Since 'w' is commonly used for a winding variable, this makes the code
harder to read.  Use the name 'edge' instead for these tjunc local types.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 11:35:28 +09:30
Kevin Shanahan 523f927b8e qbsp: trivial cleanups in FaceSide
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 10:56:41 +09:30
Kevin Shanahan 550b883de2 qbsp: more tjunc cleanups; braces and comments
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-22 20:59:42 +09:30
Kevin Shanahan 46c990c617 qbsp: trivial cleanups in SplitFaceForTjunc
Rename 'v' local to 'angle' and re-format some comments.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-22 20:58:31 +09:30
Kevin Shanahan 8939d1f6db qbsp: fix adding animated textures for alt-anim textured brushes
If brushes in the map are textured with alt-animations, and the second
character (i.e. the 'a' in +abutton) is lower case then we have the
lowercase texture name in the miptex list, but when we add alt textures we
use the uppercase, so it gets duplicated.  Duplicated animating textures
cause most engines to exit with an error.

Since the map file could use uppercase texture names as well, really we
should either be normalizing texture names to upper or lower case, or we
need to do case-insensitive matching - so I just changed to
case-insensitive matching.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-25 21:43:59 +09:30
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 414d3dda51 qbsp: add fflush back for msgScree
Otherwise progress output doesn't show on unix terminals.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 15:05:07 +09:30
Kevin Shanahan 47d2b9841b qbsp: use 5 spaces instead of tab to pad msgStat
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 15:04:35 +09:30
Kevin Shanahan 280df62f55 qbsp: fix MidpointWinding bug, which fixes the bad leak lines!
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-24 08:54:26 +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 4c6142e97f qbsp: use the common logfile code
Not too intrusive, since the Message() layer still acts as a shim
here.  Most of the changes are for the Makefile.  Qbsp now links to
the threading code as a result, but no thread support... yet!

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-23 15:48:32 +09:30
Kevin Shanahan bf9bc549d2 qbsp: remove unneccessary extern from function declarations
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-23 14:41:54 +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 347020879d qbsp: rename Error_() to Error()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 20:21:17 +09:30
Kevin Shanahan 51bed53570 qbsp: remove remaining enum errors
Remove the enum Error() function and global error strings as well.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 20:15:09 +09:30
Kevin Shanahan ea5e46f9df qbsp: replace error enums in surfaces.c, solidbsp.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 19:16:53 +09:30
Kevin Shanahan b9fa895988 qbsp: replace enum errors in portals.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:47:36 +09:30
Kevin Shanahan 15da0d818a qbsp: replace enum errors in parser.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:40:13 +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 c01397ed5b qbsp: replace enum errors in file.c and wad.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:23:24 +09:30
Kevin Shanahan 02e81df39b qbsp: replace error enums in csg4.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 18:20:02 +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 7203d3407b qbsp: replace enum errors in brush.c
One shared message in surfaces.c replaced as well.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 17:59:36 +09:30
Kevin Shanahan d5adbcd8ca qbsp: replace enum errors in qbsp.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 17:39:56 +09:30
Kevin Shanahan 30caae09e5 qbsp: re-factor ParseBrush into smaller pieces
Factor out some of the processing involved with parsing a brush.  When
checking for duplicate planes, use the same "PlaneEqual" functions as
used in brush.c.

Replace the enum style errors with the new Error_ function for all of
map.c so the error string is at the call site.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 17:33:16 +09:30
Kevin Shanahan 39ccae145a qbsp: create an Error() function similar to the other tools
Call it Error_() for now while I work on transitioning away from the
arrays of global strings hidden away by error enums.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-22 11:40:22 +09:30
Kevin Shanahan bb02e6d20a qbsp: fix portal generation mixed water/empty detail clusters
We don't want to terminate the recursion in ClusterContents when we reach
a non-detail separator because we need to know the contents of the leafs!
This was working okay for simple cases but fails when the detail clusters
become more complex.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 13:05:11 +09:30
Kevin Shanahan fa93a21598 qbsp: fix surfedge corruption when using skip surfaces
Don't count skip surface verticies at all in CountData_r because this
count actually gets used as the surfedge count and we need that to be
precise.

Don't try to save memory be allocating less verticies than edges, even
though many will probably be shared.  The saving is not that significant
anyway.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-21 10:05:17 +09:30
Kevin Shanahan 4b10bd23d9 qbsp: remove global progress counter for MakeFaceEdges
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 16:53:54 +09:30
Kevin Shanahan 2a93375e0e qbsp: small cleanup in MakeFaceEdges
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 14:43:35 +09:30
Kevin Shanahan 683a894290 qbsp: trivial cleanups in GrowNodeRegion_r
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 11:28:54 +09:30
Kevin Shanahan 8e57b7c9e6 qbsp: factor out special texture name recognition
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 11:28:11 +09:30
Kevin Shanahan 3dc06c6f21 qbsp: add a -noskip option for troubleshooting skip related problems
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-19 09:48:43 +09:30
Kevin Shanahan 7e6474c03d qbsp: keep verticies from skip/hint faces in vertex count
We still end up short if we just discard these counts - still don't
need faces for them, but every edge could be real unless it's shared
with another skip face.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-18 12:58:46 +09:30
Kevin Shanahan cd188ebc99 qbsp: increase unique vertex estimate to cope with skip faces
The old assumption about unique verticies is sometimes untrue when
skip faces are included in the map.  Be more generous with the vertex
memory allocation. This is not an area of peak memory usage anyway, so
shouldn't be a big deal.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-18 08:21:27 +09:30
Kevin Shanahan dec714eac9 qbsp: add hintskip texture support
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-04 13:30:47 +10:30
Kevin Shanahan f1396045c6 qbsp: support *waterskip, *slimeskip and *lavaskip
Extend skip support to recognise the liquid skip texturenames the same as
metlslime's "newskip" utility.  Add documentation and describe hint
surfaces (briefly) as well.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-04 12:59:09 +10:30
Kevin Shanahan dce122ea3a qbsp: fix loading func_group/detail brushes into worldspawn
The old logic did not deal properly with the case where the source entity
did not add any brushes.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-04-04 10:18:39 +10:30
Kevin Shanahan 1a0ff742eb qbsp: enable use of clip-only bmodels
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-15 14:43:11 +10:30
Kevin Shanahan 323a0af0ae qbsp: use PLANENUM_LEAF instead of magic constant
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-15 13:22:09 +10:30
Kevin Shanahan ed1cdfb6c5 qbsp: include clip brushes in model bounds
Normally the engine won't do collision detection against a bmodel
unless the entity being tested is within the model's bounds.  This
means collision doesn't work as expected when a model has clip brushes
that extend beyond the bounds of any visible brushes. This fixes that
case.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-15 11:17:34 +10:30
Kevin Shanahan 91cc81da04 qbsp: fix handling of missing textures
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-14 19:53:20 +10:30
Kevin Shanahan a9e05ffd07 qbsp: make wadlist a null-terminated linked list of wads
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-13 12:56:57 +10:30
Kevin Shanahan 0348f64274 qbsp: add WADList_FindTexture helper
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-13 12:03:15 +10:30
Kevin Shanahan 3676261441 qbsp: add support for WAD3 texture wad format
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-13 10:58:31 +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 e94d2b5cdd qbsp: Rework CopyFacesToOutside as CopyBrushFaces
New version returns the list of copied faces. This was the last user of
the inside and outside globals outside of CSGFaces, so they now move onto
the local stack there.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 14:01:47 +10:30
Kevin Shanahan 83c0fd541a qbsp: Rename KeepInsideFaces as SaveInside Faces
The list onto which to save the faces is now passed in instead of
implicitly using the global outside list.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 13:48:23 +10:30
Kevin Shanahan 3d45b05040 qbsp: readability improvements for CSGFaces
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 13:38:37 +10:30
Kevin Shanahan 6f33083868 qbsp: get rid of global 'validfaces' plane->face map
Only used in two places and not a whole lot of calls, so just allocate the
map while it's needed and free it afterwards. There is no relationship
between the two users, so no need to share a common block of memory.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 13:13:37 +10:30
Kevin Shanahan b11e671254 qbsp: pass plane-to-face hash into BuildSurfaces
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 13:02:58 +10:30
Kevin Shanahan cd043e53f4 qbsp: rework SaveOutside as SaveFacesToPlaneList
We pass in the face list and the plane map to link the faces to. Update
the comments to make it clearer what the function actually does.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 12:47:43 +10:30
Kevin Shanahan c6895c28c8 qbsp: Rework ClipInside to take inside/outside lists as arguments
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 12:08:39 +10:30
Kevin Shanahan faeb3d6942 qbsp: rework CheckInside function as RemoveOutsideFaces
Pass the inside and outside lists in rather than implicitly manipulating
the global lists.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 11:27:53 +10:30
Kevin Shanahan ba6d8e18a8 qbsp: misc naming changes to csg4.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 10:35:57 +10:30
Kevin Shanahan 406acb62d1 qbsp: fix underwater hint brushes
At load time we defaulted to CONTENTS_EMPTY, but if part or all of the
brush lies underwater, then inherit the water contents type.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-07 07:25:29 +10:30
Kevin Shanahan 7fa24021c8 qbsp: move the hint split check to the correct place
Check that the hint face would actually get split before we discount the
candidate split plane...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 22:44:41 +10:30
Kevin Shanahan 6b25dbd2cc qbsp: add hint brush support
Similar to the skip texture handling, add miptex flags, handle
appropriately in CSGFaces and SolidBSP, then remove the surfaces before
writing out the bsp.

Lightly tested, but seems to do all the right things.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 16:58:14 +10:30
Kevin Shanahan 151370b06a qbsp: Split FreeInside into FreeFaces and KeepInsideFaces
FreeInside was a strange name, since depending on the arguments we
actually wanted to keep the faces.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-06 16:25:12 +10: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 926cf8eb95 qbsp: return first face number from MakeFaceEdges and pass to ExportDrawNodes
Removes another global variable.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 15:17:40 +10:30
Kevin Shanahan 26c2789d7e qbsp: make planemap local to ExportNodePlanes{,_r}
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 15:11:31 +10:30
Kevin Shanahan 6dd0fbd085 qbsp: misc local variable naming changes for writebsp.c
Shouldn't be any functional changes to the code.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 14:54:04 +10:30
Kevin Shanahan fe89facbd0 qbsp: rename face->texturenum to texinfo
Since it is an index into the global texinfo, not miptex.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 14:34:02 +10:30
Kevin Shanahan d289742f1e trivial: remove not-very-helpful comment from surfaces.c
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 14:15:39 +10:30
Kevin Shanahan 7ca00ded1f qbsp: don't bother subdiving skip surfaces
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 14:15:03 +10:30
Kevin Shanahan 1432d99049 qbsp: cleanup texinfo flags before writing bsp
The TEX_SKIP flag isn't needed and although it *shouldn't* upset any
engines, better to not write it out at all.

Well, even better to not write anything about the skip texture to the BSP
file, but need to re-organise things a bit more before that can happen.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 14:13:23 +10:30
Kevin Shanahan 38722f9eab qbsp: don't output skip surfaces in the bsp file
* Don't create edges in MakeFaceEdges
* Don't output faces in GrowNodeRegions
* Don't output marksurfaces in CountLeaves/ExportLeaf

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 14:00:23 +10:30
Kevin Shanahan a37ee84d17 qbsp: don't worry about preserving alignment of skip textures
And potentially save some texinfos.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 13:55:37 +10:30
Kevin Shanahan b1144517b5 qbsp: don't worry about splitting skip faces when selecting split planes
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 13:34:53 +10:30
Kevin Shanahan 8e4c6e65ac qbsp: output detail brush count only if non-zero
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 13:32:38 +10:30
Kevin Shanahan 4ff4acb8c5 qbsp: create a skip flag for SKIP textures
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-05 12:01:15 +10:30
Kevin Shanahan 3426e7e8c2 qbsp: add func_group support
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-04 21:18:55 +10:30
Kevin Shanahan bf6a5e2bfa qbsp: comment possible csg optimisation for later testing
Not really the performance hot spot right now though.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-02 11:41:22 +10:30
Kevin Shanahan 98ccc06ede qbsp: support Valve's version 220 map format
https://developer.valvesoftware.com/wiki/MAP_file_format

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-03-01 08:24:00 +10:30
Kevin Shanahan e8f5c6f18a qbsp: fix pedantic compiler warning for init using stack variable addresses
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-27 21:19:32 +10:30
Kevin Shanahan 92ff448966 qbsp: parse texture rotation and shift as floats
Some editors will work with floating point rotations, so let them keep the
precise texture alignment written to the .map file.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-27 11:14:28 +10:30
Kevin Shanahan a473fedcc9 qbsp: keep portals on top node of detail cluster
Took a while to find this - need to make sure that we actually count and
write out the portals which get attached to the top node of a detail
cluster (with ->detail_separator set true).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-25 12:21:49 +10:30
Kevin Shanahan 19a8dc29c4 qbsp: calculate a useful contents value for detail clusters
Update PortalThru() to take the portal as it's argument, then we can
examine the two nodes on either side of the cluster. The nodes could
either be leafs or clusters.

Walk the detail clusters recursively and if the contents are all the same,
return that, otherwise if there is some empty space, leave it as empty.
Similarly, if there is some water, return water, etc. Basically non-solids
take precedence over solids in calculating the contents of the cluster.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-25 12:05:41 +10:30
Kevin Shanahan e39fa9bff8 qbsp: write a -1 terminator to each clustermap line
Kind of messy but necessary to either write the number of entries at the
start of the line or write a terminator for vis' fscanf style of parsing
to work easily on the .prt file. Writing a terminator is easier for the
way qbsp is currently set up, so do that.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-25 12:03:26 +10:30
Kevin Shanahan 15ab7386ff qbsp: implement the clustermap for PRT2 files
Now that I've done this I realise there could be a more compact
representation by just specifying the number of leafs per cluster, since
leaves are sequentially numbered... but this format is okay as well. And
easy to parse, etc.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-24 12:35:44 +10:30
Kevin Shanahan 0835b01da5 qbsp: write portals to a new file format if using detail clusters
Fairly simple extension of the original "PRT1" format; the first four
lines are:

Identifier := "PRT2"
Number of Leafs := INTEGER
Number of Clusters := INTEGER
Number of Portals := INTEGER

Followed by one line for each portal made up of the following, separated
by whitespace:

Number of points on the portal winding := INTEGER
Cluster Number on the front side of the portal := INTEGER
Cluster Number on the back side of the portal := INTEGER
For each point, a coordinate in the format ( x y z ), where x, y, z are FLOATs.

After the portal descriptions, there will be one line for each cluster
which lists the leaf numbers included in that cluster.

LEAF1 LEAF2 LEAF3 ...

I should probably write this up in BNF somewhere, but it's pretty straight
forward.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-24 12:00:35 +10:30
Kevin Shanahan 520a8bbfdf qbsp: fix comment in PortalThru helper
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-24 11:59:48 +10:30
Kevin Shanahan 08ef637d97 qbsp: assign vis cluster numbers to leafs
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-24 09:26:37 +10:30
Kevin Shanahan 49376dce50 qbsp: don't generate portals on detail splits
Also, compile fix for incomplete commit da3aa26ee.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-24 09:23:51 +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 383726df9f qbsp: always set the detail_separator flag on bsp nodes
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-23 20:46:57 +10:30
Kevin Shanahan 4efab46b86 qbsp: rename poorly named SameContent() function as PortalThru()
The test here was really to see if we need to add a portal between two
adjacent leafs with the given content. Rename and re-arrange the code a
little to make it a bit easier to read.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-23 20:18:25 +10:30
Kevin Shanahan 8134601ef3 qbsp: misc naming and comment cleanups for CutNodePortals_r
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 21:06:23 +10:30
Kevin Shanahan a86e38e5b1 qbsp: misc const correctness improvements for windings
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 21:04:38 +10:30
Kevin Shanahan d9e73cf194 qbsp: constify arguments to FaceSide()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 16:03:41 +10:30
Kevin Shanahan da3aa26ee5 qbsp: flag when a surface/node is a detail separator
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 15:57:47 +10:30
Kevin Shanahan 32b94e4843 qbsp: more local variable renaming in solidbsp.c
No more surfaces called 'p' (not sure why I ever used that).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 15:42:49 +10:30
Kevin Shanahan 5abd0e369c qbsp: separate the bsp split plane selection into two passes
All non-detail surfaces are considered and used before any detail
surfaces.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 14:29:44 +10:30
Kevin Shanahan 5275c24393 qbsp: clearer local variable names for Choose{,Mid}PlaneFromList
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 14:03:25 +10:30
Kevin Shanahan 996042482b qbsp: rename FreeBrushsetBrushes -> FreeBrushes
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 13:57:34 +10:30
Kevin Shanahan 146986e74a qbsp: propogate contents flags into faces during csg stage
This will allow us to properly order the bsp nodes/leafs containing detail
brushes.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 11:08:12 +10:30
Kevin Shanahan 66feee616f qbsp: maintain proper precendence ordering of brushes
Need to be a little more careful to order brushes correctly when adding
detail to the worldspawn. CSGFaces assumes that the brushes are ordered
such that earlier brushes have chunks carved out of them by any later
brushes that intersect them.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-22 10:43:05 +10:30
Kevin Shanahan 1b3a8b049f qbsp: only set planenum for face allocations of one element
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 15:10:33 +10:30
Kevin Shanahan e922d6a395 qbsp: trivial change to detail brush stat output
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 14:17:31 +10:30
Kevin Shanahan 341fe08630 qbsp: add contents flag field for brushes and flag detail brushes
During conversion from map brushes to bsp brushes, set the brush detail
flag for later use in CSGFaces().

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 14:15:25 +10:30
Kevin Shanahan d77f2a35c1 qbsp: tidy up output for Brush_LoadEntity
Pull the progress output up into the caller (not ideal) to deal with the
fact we are making extra calls to load the detail entities for the
worldspawn.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 14:13:46 +10:30
Kevin Shanahan bbcb4263d2 qbsp: don't write detail entity key/values to bsp
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 11:32:15 +10:30
Kevin Shanahan 6894518485 qbsp: don't allocate bmodel space for detail entities
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 11:31:22 +10:30
Kevin Shanahan 6bc1df862a qbsp: don't assign model keys for func_detail entities
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-21 11:30:27 +10:30
Kevin Shanahan 2f016cbb09 qbsp: treat func_detail entities as additional brushes for worldspawn
The first step towards supporting detail brushes for Quake 1. This gives
us a way to add detail brushes to a map within the existing mapping tools. A
mapper can simply add a definition for a "func_detail" entity to their
editor and create func_detail entities.

Of course, currently they will behave exactly like world brushes. Future
patches will start to treat them differently.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 16:41:51 +10:30
Kevin Shanahan 918333cfe9 qbsp: Enable loading brushes from one entity into another
Make Brush_LoadEntity() take a source and destination entity arguments. In
order for this to work, intialisation is done before calling and then the
BSP brushes generated from the source entity's map brushes are added to
whatever is already in the destination entity.

Reasons for doing this will become obvious with the following patch! :)

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 16:38:43 +10:30
Kevin Shanahan a5ac09fbd1 qbsp: fix missing declaration of CONTENTS_CLIP from previous patch
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 16:22:22 +10:30
Kevin Shanahan e1c52985a2 qbsp: move brush contents logic up into Brush_LoadEntity
Now LoadBrush doesn't need to know about entities anymore.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 15:53:21 +10:30
Kevin Shanahan 3989b1b28d qbsp: factor out logic for deciding brush contents by texture name
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 15:40:28 +10:30
Kevin Shanahan edbd84c5ae qbsp: hoist FixRotateOrigin up into Brush_LoadEntity
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 15:19:01 +10:30
Kevin Shanahan bb9b11921a qbsp: Lift bsp model rotate origin up one level into LoadBrush
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 15:11:27 +10:30
Kevin Shanahan 54acacb2c2 qbsp: make ValueForKey return empty string if key not found
Less error prone as it's usually followed by a strn?cmp or something.
Callers that were relying on null checks updated.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-20 14:39:38 +10:30
Kevin Shanahan 746a210f2a qbsp: remove hullnum global and pass to CreateSingleHull()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-18 11:01:11 +10:30
Kevin Shanahan 53e61c28ca qbsp: pass hullnum into ExportClipNodes()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-18 10:33:28 +10:30
Kevin Shanahan 27252d9104 qbsp: pass hullnum into PortalizeWorld()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-18 10:32:55 +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 ef4e53b735 qbsp: pass hullnum into Brush_LoadEntity()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-18 09:51:33 +10:30
Kevin Shanahan 9e4f207d3e qbsp: trivial argument rename for FreeBrushsetBrushes in header
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 21:37:34 +10:30
Kevin Shanahan cfde5514dd qbsp: remove comment about regenerating dplane_t->type
The on disk format is set at this stage.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 21:36:13 +10:30
Kevin Shanahan d152382691 qbsp: constify FindPlane plane argument
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 21:35:22 +10:30
Kevin Shanahan 04c8c73ef6 qbsp: make Plane{,Inv}Equal take two planes as arguments
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 21:34:47 +10:30
Kevin Shanahan 47dc7108eb qbsp: a few more local variable renames
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 21:28:32 +10:30
Kevin Shanahan b8ffeca2c0 qbsp: encapsulate mapbrush => brush conversion data on stack
Still have the limitations of MAX_FACES, etc. but in practice it's
probably not going to be an issue.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 20:09:04 +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 d1839943c9 qbsp: make parser state non-global
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 15:21:48 +10:30
Kevin Shanahan bbe203629a qbsp: switch to using time() instead of ftime()
We don't need very precise time - only used for telling the user how long
the compile took, so use the most portable API. Fixes compilation on
OpenBSD/FreeBSD.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 11:25:47 +10:30
Kevin Shanahan fda99aac20 qbsp: change LoadFile spec so we don't need to cast when calling
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-17 11:03:09 +10:30
Kevin Shanahan 31a9bf78c7 qbsp: normalize quaked style texture rotation between 0 and 359
Probably not hugely important, but might save a few sin/cos
calculations...

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-16 18:22:46 +10:30
Kevin Shanahan a9dd2de5ec qbsp: skip only the face, not brush for degenerate normals
The previous code would possibly leak faces with weird effects if we
iterate over the face data e.g. 0 -> map.numfaces.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 18:23:15 +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 6e39de60c9 qbsp: minor cleanups in FindTexinfo()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 15:28:07 +10:30
Kevin Shanahan d17622ab48 qbsp: constify argument to FindMiptex()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 15:11:02 +10:30
Kevin Shanahan e3752dc02d qbsp: remove unneccessary cast from LoadMapFile()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 14:09:18 +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 9639e5037f qbsp: compile fixes for FreeAllMem
Not enabled, but may as well keep it up to date in case we want to start
using it. Might be useful as a simple check that we aren't leaking memory
somewhere.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 10:58:22 +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 af2cae7ae2 qbsp: move allocation of bspmodel struct outside ParseEntity()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-15 10:00:53 +10:30
Kevin Shanahan 9a50342353 qbsp: similar to map.iBrushes, get rid of map.iFaces
* ParseEntity/ParseBrush now take a mapface_t argument, endface
* mapbrush_t now defines a pointer to first face and count of faces
* entity->iFaces no longer needed

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 21:51:11 +10:30
Kevin Shanahan 02eec4fc68 qbsp: tidy up texinfo setup functions
Tidy up the functions that calculate the texinfo data for either QuakeEd
or QuArK texture coordinates.

* Remove cleverness in SetTexinfo_QuArK where checking style1 or style2
  just expand the loop for both cases for increased clarity.
* Pass the face plane into SetTexinfo_QuakeEd so it doesn't need to rely
  on map.iFaces.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 16:22:52 +10:30
Kevin Shanahan f163b35932 qbsp: get rid of map.iEntities
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 15:17:31 +10:30
Kevin Shanahan eb9ed6beb1 qbsp: remove reliance on map.iEntities from ProcessEntity()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 14:41:46 +10:30
Kevin Shanahan 1cbd5a8a0b qbsp: increase and check model name buffer size
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 14:40:48 +10:30
Kevin Shanahan 2f7809ddcb qbsp: pass entity pointer into PrintEntity()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 14:36:07 +10:30
Kevin Shanahan 2c3e7509e6 qbsp: pass entity into ParseEpair()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 14:21:01 +10:30
Kevin Shanahan d6cb5d9680 trivial: comment tidy up
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 14:03:42 +10:30
Kevin Shanahan 16c0dffe8c qbsp: re-organise mapentity_t structure
Instead of iBrushStart and iBrushEnd, we now store a pointer into the
mapbrush array and store the count of brushes for this entity. pBrushes
and cBrushes members are renamed to brushes and numbrushes, respectively.

The iBrushes member of mapentity_t is no longer needed.

At this stage we still go through hoops to load the brushes in reverse.
The original comment indicates that this was needed for compatibility, I
may try simplifying and loading in map file order and see if that has any
ill effects on compilation of test maps.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 14:03:06 +10:30
Kevin Shanahan e315d97464 qbsp: pass brush pointer into ParseBrush()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 12:06:44 +10:30
Kevin Shanahan 9646303bf5 qbsp: de-constify entity argument to LoadBrush and pass to CreateBrushFaces
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 11:51:23 +10:30
Kevin Shanahan bf29969480 qbsp: pass entity into CreateBrushFaces()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 11:42:49 +10:30
Kevin Shanahan c39d9a2dc4 qbsp: Pass entity pointer into FixRotateOrigin, don't pass in/out origin
Make the caller look up the fixed origin again if they need it rather than
always passing in/out an origin. FindTargetEntity also now returns a
pointer rather than entity number.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 11:36:22 +10:30
Kevin Shanahan 3bf10bef02 qbsp: pass entity pointer into key/value get/set functions
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 11:08:22 +10:30
Kevin Shanahan a06e60b5fa qbsp: rework of LoadBrush
* Pass in pointer to the entity and mapbrush instead of brush number
* Rename some local variables for better readability

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-14 10:45:17 +10:30
Kevin Shanahan f561e6867f qbsp: include stdlib.h instead of malloc.h
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-12 08:53:35 +10:30
Kevin Shanahan cb59bfdc63 qbsp: trivial constification of a few strings/args
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 20:05:30 +10:30
Kevin Shanahan a6280d8bd8 qbsp: constify return value from ValueForKey()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 19:00:11 +10:30
Kevin Shanahan 0cadff9056 qbsp: don't modify string returned from ValueForKey in ProcessFile()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 18:59:19 +10:30
Kevin Shanahan 6c8aa11988 qbsp: don't modify the wadstring argument in WADList_Init()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 18:56:44 +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
Kevin Shanahan d691ff951a qbsp: get rid of pCurEnt
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:58:52 +10:30
Kevin Shanahan 2d45184f59 qbsp: use local pointer instead of pCurEnt global in CreateSingleHull()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:57:49 +10:30
Kevin Shanahan 5c2c024ead qbsp: pass entity into ProcessEntity()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:56:12 +10:30
Kevin Shanahan a58e461dda qbsp: use local pointer instead of pCurEnt in LoadMapFile()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:53:21 +10:30
Kevin Shanahan 76ba40f621 qbsp: pass entity into Export{Draw,Clip}Nodes
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:49:27 +10:30
Kevin Shanahan 6faca2fc86 qbsp: pass entity down through MakeFaceEdges()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:28:09 +10:30
Kevin Shanahan d6bcd02e20 qbsp: pass entity into SolidBSP()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:14:06 +10:30
Kevin Shanahan 3713c4492b qbsp: pass entity into TJunc, capitalise function name
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:09:05 +10:30
Kevin Shanahan 36360e273d qbsp: pass entity down into PortalizeWorld()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:05:45 +10:30
Kevin Shanahan 51b6089318 qbsp: pass entity into CSGFaces()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 17:01:32 +10:30
Kevin Shanahan 158c422476 qbsp: pass entity into Brush_LoadEntity()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 16:56:56 +10:30
Kevin Shanahan c0430051b9 qbsp: pass brush list into FreeBrushsetBrushes
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 16:52:01 +10:30
Kevin Shanahan a6990fb2b6 qbsp: pass entity into AddToBounds
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-10 16:43:37 +10:30
Kevin Shanahan 262ffab5d5 qbsp: replace last malloc with AllocMem
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-09 17:38:56 +10:30
Kevin Shanahan b5c84dafa3 trivial: whitespace
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-09 17:38:36 +10:30
Kevin Shanahan 662a745202 qbsp: use correct array indicies comparing texinfo
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-26 09:38:44 +10:30
Kevin Shanahan ee015abe53 qbsp: fix incorrect size for memset of planemapping
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2012-12-17 12:39:26 +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 c6d6d44326 trivial: fix printf integer size type mismatch 2012-01-06 21:35:55 +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 9da84b6ee1 [PATCH] qbsp: use fast sphere test in SplitFace
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 21:04:28 +09:30
Tyrann 1d2cc1b780 [PATCH] qbsp: copy face sphere attributes in NewFaceFromFace
Makes sure we maintain the sphere, e.g. in SplitFace.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 21:04:23 +09:30
Tyrann accc80ef2f [PATCH] qbsp: always fix tjunctions, remove option
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 21:04:16 +09:30
Tyrann 11ca5bf377 [PATCH] qbsp: Remove unneeded plane variable
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 20:46:32 +09:30
Tyrann 7ce4402dfc [PATCH] qbsp: Use fast sphere test in FaceSide
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 20:46:28 +09:30
Tyrann 67981816c7 [PATCH] qbsp: Set up sphere around face for fast intersect checks
Set up a sphere around each face so we can do quick tests against planes to
see if there's any chance that it intersects the face. Since we're only using
it for a fast check, don't bother shrinking the sphere when a face gets cut or
split, just grow it when necessary (only in TryMerge AFIACT).

Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 20:46:22 +09:30
Tyrann 17c994c430 [PATCH] qbsp: Fix mem leak in DividePlane
Signed-off-by: Tyrann <tyrann@disenchant.net>
2007-09-23 20:46:17 +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 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 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 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