Commit Graph

720 Commits

Author SHA1 Message Date
Kevin Shanahan 51419621ec common: add the bsp2/bsp29 data types
Rename the default bsp29 data types and add the bsp2 data types to
the common bspfile.h.  Propogate the bsp29 names into the other tools as
simple renames for now.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 13:25:16 +09:30
Kevin Shanahan 0092347789 common: use stdint types in the common bspfile.h
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 12:25:51 +09:30
Kevin Shanahan 69c86e59b8 common: move AMBIENT and MAXLIGHTMAP definitions
Keep the ambient sound definitions near the leaf and lightmaps limit near
the face definition.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 12:20:57 +09:30
Kevin Shanahan 42bcf2da7c common: rename HEADER_LUMPS -> BSP_LUMPS
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 09:30:26 +09:30
Kevin Shanahan 9a2cd81b8c common: add the bsp version defines to bspfile.h
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-20 09:18:26 +09:30
Kevin Shanahan 58c6335434 qbsp: don't bail out on 65535 verticies for bsp2 output
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 17:09:23 +09:30
Kevin Shanahan 85581b6c0c qbsp: output leafs, nodes and marksurfaces in bsp2 format
This completes the basic BSP2 support.

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

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

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

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

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 10:25:17 +09:30
Kevin Shanahan 32973e6779 qbsp: re-format the memsize global array
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 10:13:11 +09:30
Kevin Shanahan 330d5270dd qbsp: separate out bspfile.h from qbsp.h
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-19 09:46:23 +09:30
Kevin Shanahan b403b6bd5e doc: note the vertex limit bug fix in changelog
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 17:19:10 +09:30
Kevin Shanahan d7d6c4939c qbsp: minor cleanup in FindFaceEdges
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 17:14:36 +09:30
Kevin Shanahan 876ac97cbe qbsp: small cleanups in GetVertex
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 17:01:24 +09:30
Kevin Shanahan 0269ad8edb qbsp: show the error margin when non-convex faces are found
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:57:40 +09:30
Kevin Shanahan 1612d60a5f light: keep debug helper for dumping face info
Used this to help with debugging, but may as well keep it around for
future debugging rather than implement it all over again next time.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:52:19 +09:30
Kevin Shanahan aa4f577a6d qbsp: constify some more arguments to GetEdge
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:41:44 +09:30
Kevin Shanahan 33eff1ded9 bsputil: Check that face verticies lie on the face plane
Yet another consistency check.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:34:27 +09:30
Kevin Shanahan c2fbde6af7 bsputil: add --modelinfo option
Dump some info about the faces of internal bsp models.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-18 16:32:52 +09:30
Kevin Shanahan ad25768498 qbsp: exit with error if vertices exceed 65535
Unable to represent this in the bsp29 format, so let the user know instead
of silently corrupting the bsp.

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

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

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-13 16:27:05 +09:30
Kevin Shanahan 7a2f4383ff build: use single call to wildcard for depfiles
Provides a modest speedup on Windows, where this operation is ridiculously
slow.  Not a huge number of files on this project, but the speedup is
measurable.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-06 16:29:21 +09:30
Kevin Shanahan 272816d24f qbsp: increase MAXTOKEN to 1024 to cope with long "wad" keys
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-05 10:08:49 +09:30
Kevin Shanahan 23591535b4 light: show face area for bad texture axis error
Often these errors are caused by super small faces on brushes, show the
area of the offending face to make it more obvious if that is the case.
Kind of lost in the diff, but moved the TriArea, etc. functions up and
added FaceArea() and then augmented the error message.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-08-03 16:47:15 +09:30
Kevin Shanahan c94414f288 light: allocate one extra lightmap to simplify handling overflow
Rather than allocating the overflow map within each function and
having to handle it as a special case in each, we always allocate the
extra lightmap in the base LightFace function and use common helper
functions to handle allocation and warning on overflow.

We lose a tiny bit of debugging info here about the specific light
that made the surface overflow MAXLIGHTSTYLES, but that never gave us
all the sources, only the last one encountered.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-10 13:47:58 +09:30
Kevin Shanahan 35bf3f4232 light: factor out adding and clamping of light samples
Simple functions, but just helps to tidy up the bodies of the other
LightFace functions and makes sure we're handling light & colours
consistently across each (we weren't in the case of coloured local
minlights, previously).

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-08 15:42:50 +09:30
Kevin Shanahan e09c1f8e2a light: rename FixMinLight -> LightFace_Min
Move away from the "Fix" naming ~ it's not a fix, we're applying the
minimum lighting values as requested.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-08 13:30:38 +09:30
Kevin Shanahan 23f8f1a35e light: unify allocation of new face light styles
Factor out the allocation of new light styles - slightly increases the
code size, but we get two benefits; first is that we now don't
allocate the style 0 lightmap unless we actually need it; second, we
get warnings if sunlight or minlight is unable to be applied due to
lack of a style 0 lightmap.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-04 14:29:47 +09:30
Kevin Shanahan f498ed5ec3 light: pass the sun direction vector into LightFace_Sky
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 16:32:03 +09:30
Kevin Shanahan ca78568cae light: rename SkyLightFace -> LightFace_Sky
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 14:55:56 +09:30
Kevin Shanahan 7abfeb35da light: rename SingleLightFace -> LightFace_Entity
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 14:54:21 +09:30
Kevin Shanahan 12e24085c1 light: always calculate color values for light samples
Simplify the code by removing the if (colored) conditionals from the
code path.  CPU cost is insignificant compared to tracing the rays.
As before, only write the lit file if colored lights are detected or
the use explicity requests it.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 13:03:27 +09:30
Kevin Shanahan a0fc4cab3e light: remove (now) unused MAXLIGHTS define
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-07-03 11:49:07 +09:30
Kevin Shanahan e3a5b57ba4 qbsp: add "-forcegoodtree" command line option
Normally we build a fast, unoptimized bsp tree for the world before
culling outside surfaces.  This command line switch forces the use of
the more expensive algorithm for this processing stage.  Seems to have
a positive effect on the final BSP in terms of reduced marksurfaces
and smaller file size, at the expense of longer processing time.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
2013-06-23 11:35:28 +09:30