MidSplit now does two passes (structural/detail), like ChoosePlaneFromList.
Now, the first pass will pick among planes that have at least one structural face, and zero or more detail faces.
The second pass will pick among planes that have no structural faces, and zero or more detail faces.
This fixes the hull 1 leak in telefragged.map introduced when I added txqbsp's maxNodeSize feature,
and also reduces the cluster and portal count in jam6_ericwtronyn.map a bit.
Thanks to rebb for the idea, txqbsp has the workaround in SelectPartition that recomputes the surface bbox; I think this fixes the underlying bug though.
Note: this makes telefragged.map (from the RRP devkit) leak in hull 2.
However, the point file starts at a func_detail staircase that, if turned into func_wall, fixes the leak.
Here's another little tyrutils patch: in qbsp, I believe the
calculation of the "disksize" field of the miptex lumps when using
WAD3 textures is missing the size of the dmiptex_t struct (40 bytes),
causing the resulting bsp file to be slightly truncated.
I noticed this because one of Tronyn's levels (jam2_tronyn.bsp) was
crashing Quakespasm for me; it turned out the engine was trying to
read 40 bytes past the end of the file when loading the last texture
in the bsp. I got him to send over his map source, wads, and compiler;
he was using tyrutils 0.15 and wad3 format textures, and I confirmed
that this patch fixes the engine crash.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The error message was actually displaying the edge vector, which is
always going to be ~(0,0,0). Pass in the edge end points and then we
can display both the length of the edge and the location of one end
point.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
To improve debug messages, save the line number of the faces as we
generate them and in the case of hull generation, save a pointer back
to the source brush.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Enables us to check if there is extra data on the same line, without
advancing the parser past the end of line.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Search the WADs for extra frames on any animated textures used and add
them to the bsp. This restores the old behaviour which was mistakenly
removed, but now we have the assurance that textures are added in
order and all lower numbered animation frames are added a warning is
printed if it is missing from the wad.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Turns out there are two types of "BSP2" format - one that I think was
created by MH and implemented in the RMQ project (this is the one I
implemented previously) and one by LordHavoc which exteneded the
coordinate limits beyond 32k, implemented in Darkplaces. The
Darkplaces version of BSP2 will get the name BSP2 and the RMQ version,
which is more limited, will get the name BSP2rmq.
qbsp will only create the BSP29 or BSP2 formats, but will cope with a
BSP2rmq format file for an -onlyents compile. The rest of the tools
can use any of the three formats.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
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>
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>
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>
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>
Not too intrusive, since the Message() layer still acts as a shim
here. Most of the changes are for the Makefile. Qbsp now links to
the threading code as a result, but no thread support... yet!
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Carry over some correctness fixes from recent changes to vis into the
qbsp versions of ClipWinding and make the implementations more
consistent overall.
Most importantly:
* Ensure we always have allocated one extra dists/sides slot for wrap around
* Check we have space for a new vertex every time we try to add one
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Factor out some of the processing involved with parsing a brush. When
checking for duplicate planes, use the same "PlaneEqual" functions as
used in brush.c.
Replace the enum style errors with the new Error_ function for all of
map.c so the error string is at the call site.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Call it Error_() for now while I work on transitioning away from the
arrays of global strings hidden away by error enums.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
We don't want to terminate the recursion in ClusterContents when we reach
a non-detail separator because we need to know the contents of the leafs!
This was working okay for simple cases but fails when the detail clusters
become more complex.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Don't count skip surface verticies at all in CountData_r because this
count actually gets used as the surfedge count and we need that to be
precise.
Don't try to save memory be allocating less verticies than edges, even
though many will probably be shared. The saving is not that significant
anyway.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
We still end up short if we just discard these counts - still don't
need faces for them, but every edge could be real unless it's shared
with another skip face.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The old assumption about unique verticies is sometimes untrue when
skip faces are included in the map. Be more generous with the vertex
memory allocation. This is not an area of peak memory usage anyway, so
shouldn't be a big deal.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Extend skip support to recognise the liquid skip texturenames the same as
metlslime's "newskip" utility. Add documentation and describe hint
surfaces (briefly) as well.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The old logic did not deal properly with the case where the source entity
did not add any brushes.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Normally the engine won't do collision detection against a bmodel
unless the entity being tested is within the model's bounds. This
means collision doesn't work as expected when a model has clip brushes
that extend beyond the bounds of any visible brushes. This fixes that
case.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
New version returns the list of copied faces. This was the last user of
the inside and outside globals outside of CSGFaces, so they now move onto
the local stack there.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The list onto which to save the faces is now passed in instead of
implicitly using the global outside list.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Only used in two places and not a whole lot of calls, so just allocate the
map while it's needed and free it afterwards. There is no relationship
between the two users, so no need to share a common block of memory.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
We pass in the face list and the plane map to link the faces to. Update
the comments to make it clearer what the function actually does.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
At load time we defaulted to CONTENTS_EMPTY, but if part or all of the
brush lies underwater, then inherit the water contents type.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Check that the hint face would actually get split before we discount the
candidate split plane...
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Similar to the skip texture handling, add miptex flags, handle
appropriately in CSGFaces and SolidBSP, then remove the surfaces before
writing out the bsp.
Lightly tested, but seems to do all the right things.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
FreeInside was a strange name, since depending on the arguments we
actually wanted to keep the faces.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Now consolidate the leak state into a single leakstate_t struct. Rename
the leaks/numleaks/maxleaks members as portals/numportals/maxportals for
improved clarity. What was numportals previously is now numwritten.
Outleafs is now returned from the FillOutside_r function instead of
passing in a struct or int to be incremented by the function.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Finding leaks carries a lot more state which is not needed for the final
outside fill stage, so let's separate the two. Get rid of fillparms_t
since the only thing left was the fillmark.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
It seems clearer now that the numportals parameter is actually used to
check that the number of leak portals we accumulate doesn't exceed the
allocated memory. Update the structs to reflect that.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Move the 'firstone' global into the bspleak state as a flag to indicate
whether the header has been written yet, since that's why the flag exists.
Move numportals and hit_occupied (renamed to "entity") in there as well to
keep leak related data all together.
MarkLeakTrail now directly increments bspleak->numportals so doesn't need
to return a value indicating what was written.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Was showing up as blah.prt.por because we had messed with the filename to
remove the prt file previously.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Previously, leak files would only be written for a leak in hull 2. This is
actually pretty bad because a small leak in hull 0 or 1 might not show up
in hull 2 and you would never get a leak file to chase it down.
Place a flag in the global mapdata to indicate whether we have written a
leak file or not so we only write for the first hull that leaks. Hullnum
is no longer needed as a parameter to RecursiveFillOutside, so remove
that from the fillparms struct.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Remove the (file) global fillmark from outside.c and place into the global
mapadata. Pass the fillmark into RecursiveFillOutside as a read-only
parameter instead.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This is not a yes/no flag it's an integer mark to see if we have visited
the node within the same fill pass.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
Makes it kind of obvious now that there is a bug here - if we have a small
leak in hull 0 or 1 which is sealed in hull 2 (due to brush expansion), then
we won't get a leak trail!
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
The TEX_SKIP flag isn't needed and although it *shouldn't* upset any
engines, better to not write it out at all.
Well, even better to not write anything about the skip texture to the BSP
file, but need to re-organise things a bit more before that can happen.
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>