Commit Graph

4217 Commits

Author SHA1 Message Date
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 5c0826168a vis: fix memory leaks in state load/save paths
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-12 09:33:31 +10:30
Kevin Shanahan 9580847712 build: fix pthread build warning on darwin
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-12 08:58:56 +10:30
Kevin Shanahan 87e9c04205 build: detect darwin as a supported platform
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-12 08:58:27 +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 5df0b0c27a build: add -Wwrite-strings to build arguments()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 20:11:16 +10:30
Kevin Shanahan ea836f6b0b light: constify light's version of ValueForKey()
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 20:10:47 +10:30
Kevin Shanahan 5bb5c576f4 common: constify init_log filename argument
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 20:10:17 +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 dacba3ca2e build: make build skip the strip step if STRIP is empty
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-02-11 18:47:47 +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