Commit Graph

1266 Commits

Author SHA1 Message Date
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
Tyrann a2e9503fdc [PATCH] qbsp: WADList_Init/LoadLumpInfo cleanup
Move the logic from WADList_LoadLumpInfo into WADList_Init. Now the init
function will open all the wad files, testing for validity. Note that I still
need to tidy up the error handling and warnings a little bit to handle the
difference between filesystem/read errors and invalid/corrupt wad files.

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

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

Also, get rid of fileT from WADList_LoadLumpInfo.

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

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

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

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

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-25 20:16:18 +09:30
Tyrann b9a0bf538e [PATCH] qbsp: Add support for QuArK map files
QuArK generates floating point values for the brush face plane points and also
has it's own way of defining texture placement. Read in all plane points as
floats (does no harm maps that use integers) and also parse the extra comment
at end of line which indicates that the special texturing rules apply to the
face (two variants).

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-17 21:36:01 +09:30
Tyrann 3feeec1778 [PATCH] qbsp: Factor out texture vector calculation
Move the QuakeEd style texture vector calculations out of the ParseBrush
function. This will keep things tidier when adding other the other types of
texture vector calculation.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-17 10:02:43 +09:30
Tyrann ad5e555e89 [PATCH] qbsp: Enable map file parser to return comment tokens
Change the boolean argument to parsetoken to a set of optional flags. Calls
that previously had crossline == false now pass PARSE_SAMELINE instead. Add
PARSE_COMMENT flag to parse the next token as a comment. If the token isn't a
comment, then return false.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 22:24:09 +09:30
Tyrann e660c87c32 [PATCH] qbsp: remove strange comment...
Perhaps just a remnant from some previous debugging work..?

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 19:52:36 +09:30
Tyrann 50f526d44c [PATCH] qbsp: Constify VectorXX functions
Specify const where applicable in the VectorXX functions. This fixes a
compiler warning introduced in the last patch.

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

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

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

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

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 16:36:16 +09:30
Tyrann b550faf877 [PATCH] qbsp: Remove unnecessary cast of malloc return value
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 16:31:06 +09:30
Tyrann dc9b279203 [PATCH] qbsp: remove unused filename variable
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 16:31:02 +09:30
Tyrann 41d3de5180 [PATCH] qbsp: Don't forget to call Wad destructor
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 16:30:58 +09:30
Tyrann 90710dc8d8 [PATCH] qbsp: Fix cast of data pointer for LoadFile callers
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-16 16:20:56 +09:30
Tyrann 073959d654 [PATCH 15/15] qbsp: writebsp.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:46:03 +09:30
Tyrann b38a84b657 [PATCH 14/15] qbsp: util.c statics
Make needlessly global functions/variables static.
Move 'extern' declarations to qbsp.h.
Don't compile unused FreeAllMem function.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:46:02 +09:30
Tyrann 5afe45acda [PATCH 13/15] qbsp: tjunc.c static
Make needlessly global functions/variables static.
Remove unused function PrintFace.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:46:02 +09:30
Tyrann b6e104e2b4 [PATCH 12/15] qbsp: surfaces.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:46:01 +09:30
Tyrann c47243a1c1 [PATCH 11/15] qbsp: solidbsp.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:46:01 +09:30
Tyrann 4b9560a60c [PATCH 10/15] qbsp: qbsp.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:46:00 +09:30
Tyrann 0a230cc79d [PATCH 09/15] qbsp: portals.c statics
Make needlessly global functions/variables static.
Move some checking functions inside an #ifdef PARANOID section.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:59 +09:30
Tyrann a79e5c28b2 [PATCH 08/15] qbsp: parser.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:59 +09:30
Tyrann e89f25be80 [PATCH 07/15] qbsp: outside.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:58 +09:30
Tyrann 898f66d460 [PATCH 06/15] qbsp: merge.c statics
Make needlessly global functions/variables static.
Don't compile CheckColinear unless doing parnoid checks.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:58 +09:30
Tyrann 950b163181 [PATCH 05/15] qbsp: map.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:57 +09:30
Tyrann 525c3ec2fe [PATCH 04/15] qbsp: csg4.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:57 +09:30
Tyrann 5e29db5df0 [PATCH 03/15] qbsp: cmdlib.c statics
Make needlessly global functions/variables static.
Remove unused functions Q_getwd, DefaultPath and StripFilename.
Remove unused CRC functions.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:56 +09:30
Tyrann ed50a94fd6 [PATCH 02/15] qbsp: bspfile.c statics
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:55 +09:30
Tyrann 85b459931a [PATCH 01/15] qbsp: brush.c statics
Make needlessly global functions/variables static.
Remove the unused function PlaneTypeForNormal.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 22:45:55 +09:30
Tyrann dcb6fa7c9b [PATCH] qbsp: Remove unnecessary casts from AllocMem calls
Now that we're compiling as C code, the memory returned by AllocMem no longer
needs to be explicitly cast when assigning to our typed pointers.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 20:29:00 +09:30
Tyrann 50e6c880cc [PATCH 9/9] qbsp: Compile as C code
Now that all the C++isms have been removed, rename the .cpp source files to .c
and remove the special case makefile rules for compiling qbsp object files.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:34 +09:30
Tyrann 1c082ace11 [PATCH 8/9] qbsp: Remove stricmp/strcasecmp workaround
Patch the source files and remove the preprocessor workaround for
stricmp/strcasecmp substitution.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:34 +09:30
Tyrann 099e22f733 [PATCH 7/9] qbsp: Replace C++ consts with defines
Replace three "const" declarations in qbsp.h with #defines to prevent multiple
definitions being compiled in when compiling as C code.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:33 +09:30
Tyrann 8ef5c8bc5d [PATCH 6/9] qbsp: Remove two C++ style casts
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:33 +09:30
Tyrann 2dfd647656 [PATCH 5/9] qbsp: Replace new/delete with malloc/free
There's a couple of usages outside of the AllocMem/FreeMem functions. Flag
these as something to look at later.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:32 +09:30
Tyrann 293efefa26 [PATCH 4/9] qbsp: Remove default arguments from {Alloc,Free}Mem
More C++ removal. Just pass the default arguments explicitly.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:32 +09:30
Tyrann 45c387c7eb [PATCH 3/9] qbsp: Replace parser class with plain C code
Nothing too exciting here, just replacing more C++ code with plain C. The
parser class is gone - we just use a global token now and call ParseToken to
update it.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:31 +09:30
Tyrann 0cae98f22f [PATCH 2/9] qbsp: Replace WAD class
Replace the WAD class with plain C code. Class WAD becomes wad_t and the
member functions are just normal functions taking a wad_t as an argument.

The iWad member was a bit strange. It was used in some member functions for
walking the wadlist array. I've elimanted that from the struct and made the
functions track that state themselves.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:30 +09:30
Tyrann 8bded2dfaf [PATCH 1/9] qbsp: Replace File class with basic stdio functions
Replace the "File" class with basic stdio C functions. The LoadFile is kept
basically intact. All instances of File objects are replaced with FILE*. Calls
to member functions are replaced with inline C code. There is some redundancy
with the error checking, but this can probably be cleaned up a little bit by
using some of the SafeOpen, etc. functions from common/cmdlib.c.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:38:30 +09:30
Tyrann 25f6148fc3 [PATCH] Make qbsp build
Make some bare-minimum changes to get qbsp to build with gcc/g++ and
MinGW/Msys.
o Added makefile rules
o Work around windows specific calls to e.g. _getcwd
o Use noecho() / echo() calls around getch() in Linux
o Substitute stricmp -> strcasecmp (in Makefile for now)
o Fix non-portable (incorrect?) of inline
o Fix misuse of delete where delete [] is required...

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-10 17:35:05 +09:30
Tyrann a2c8785d81 [PATCH 3/3] qbsp: run indent over the source files
More source mangling; run indent over the source files to make it more
consistent with the rest of my utils code. Remove any trailing whitespace
while we're at it.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-05 20:57:33 +09:30
Tyrann 689790cbdb [PATCH 2/3] qbsp: consistently use newline at EOF
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-05 20:57:21 +09:30
Tyrann 950c8ab0de [PATCH 1/3] qbsp: add copyright notices and license info
Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-09-05 20:56:57 +09:30
Tyrann d0a0c3c15c [PATCH] Import QBSP sources
Import QBSP sources from Greg Lewis' TreeQBSP version 1.62.
- http://www.yossman.net/~tree/

Thanks to Greg for allowing me to use his modified source code:

On Fri, Aug 25, 2006 at 04:28:24PM -0400, Tree wrote:
> I imagine you've already gone ahead with your plans, but feel free to do
> whatever you wish with the source for TreeQBSP; I have no interest in
> restricting anyone's access to it (and of course I was just modifying id's
> code anyway).  I'm just glad to see that it was of some use to you. :)
>
> Greg

The files are unmodified from the originals, apart from lower-casing the
filenames and removing ASCII CR characters from end of lines.

Signed-off-by: Tyrann <tyrann@disenchant.net>
2006-08-29 00:03:53 +09:30