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>
Make CheckStack return an error code if we have recursed and print
some information about the offending leaf/portals before continuing.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
If brushes in the map are textured with alt-animations, and the second
character (i.e. the 'a' in +abutton) is lower case then we have the
lowercase texture name in the miptex list, but when we add alt textures we
use the uppercase, so it gets duplicated. Duplicated animating textures
cause most engines to exit with an error.
Since the map file could use uppercase texture names as well, really we
should either be normalizing texture names to upper or lower case, or we
need to do case-insensitive matching - so I just changed to
case-insensitive matching.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Also do a quick sweep of the source and consistently use %d instead of
%i (no real difference, but just pick one).
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>