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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>