Commit Graph

415 Commits

Author SHA1 Message Date
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