Add the ability to extract texture information from a BSP file and write it
out as a WAD file. Not very robust in the face of errors or corrupt BSP files,
but it does the job for now.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Save some memory in CSGFaces by not splitting faces outside the brush being
processed. Normally these faces will be split by the planes of the brush, even
if the brush doesn't intersect with it at all. This also saves some time in
MergeFaces, since we don't need to re-assemble these faces again.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Each of ClipWinding, DivideWinding and SplitFace need to calculate on which
side of the split plane each winding point lies. Split this operation out into
a shared function.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Rather than using it's own type of winding, make face_t use the existing
winding_t struct to define it's edges. I tried dynamically allocating the
winding as needed, but it was a net performance loss (though much better for
memory usage). For now we'll just embed a winding_t struct inside face_t
instead.
Signed-off-by: Tyrann <tyrann@disenchant.net>
The number reported for peak memory usage by winding_t structs was not
accurate, due to just using the sizeof(winding_t) for accounting. Track the
_bytes_ used by each type in a separate array. This is pretty much redundant
for everything except windings, but it's the simplest way to implement it for
now.
Also tidied up the verbose memory output a bit - the total column is pretty
useless, so just don't print it. Re-align the other columns and special case
the "Total" line, as only the "Peak Bytes" value is really interesting.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Make all WADList functions take a pointer to the first wad_t, rather than
embedding it inside the struct wadlist. wadlist_t is no longer needed.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Begin breaking down the wadlist_t structure by having the Init function return
the number of wads loaded to the caller, rather than relying on just setting
it internally.
Signed-off-by: Tyrann <tyrann@disenchant.net>
If the map has no wad key, or none of the wad files found in the key can be
loaded, then try loading mapname.wad as a default.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Add back the warning message about invalid wads. Don't bother to differentiate
between filesystem errors and bad magic, etc. The file is already open, so if
we can't read it's either too small or there might be some hardware problem
(not worth dealing with separately).
Signed-off-by: Tyrann <tyrann@disenchant.net>
Move the logic from WADList_LoadLumpInfo into WADList_Init. Now the init
function will open all the wad files, testing for validity. Note that I still
need to tidy up the error handling and warnings a little bit to handle the
difference between filesystem/read errors and invalid/corrupt wad files.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Renaming a few variables to keep things nice and clear:
- w -> list ; the wadlist_t
- list -> wadstring ; the string from the map's "wad" key
- wad -> w ; local pointer to a single wad
Signed-off-by: Tyrann <tyrann@disenchant.net>
Rename a couple more structure members to make their purposes clearer;
- wad_t::Wad -> wad_t::file - it's a file handle
- wadlist_t::wadlist -> wadlist_t::wads - yes, we already know it's a list
Also, get rid of fileT from WADList_LoadLumpInfo.
Signed-off-by: Tyrann <tyrann@disenchant.net>
The wad_t struct is actually a list of wads, and the wadlist_t struct
represents the info for a single wad. This is kind of backwards, so reverse
the names. A few function renames went along with this to make things look
saner.
Signed-off-by: Tyrann <tyrann@disenchant.net>
wad_t::name isn't required outside of some temporary usage in WAD_InitWadList
so doesn't really belong in the struct.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Memory stats are reported inaccurately because the memory allocated to
windings is not accounted correctly (when freed, in particular). Use the usual
technique of recording the allocated size in the same block of memory, just
before the portion returned to the caller.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Fix a bug introduced in my class File -> stdio conversion. Don't use the len
variable to save the result of fread, since it's still needed as part of the
loop condition!
Signed-off-by: Tyrann <tyrann@disenchant.net>
QuArK generates floating point values for the brush face plane points and also
has it's own way of defining texture placement. Read in all plane points as
floats (does no harm maps that use integers) and also parse the extra comment
at end of line which indicates that the special texturing rules apply to the
face (two variants).
Signed-off-by: Tyrann <tyrann@disenchant.net>
Move the QuakeEd style texture vector calculations out of the ParseBrush
function. This will keep things tidier when adding other the other types of
texture vector calculation.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Change the boolean argument to parsetoken to a set of optional flags. Calls
that previously had crossline == false now pass PARSE_SAMELINE instead. Add
PARSE_COMMENT flag to parse the next token as a comment. If the token isn't a
comment, then return false.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Specify const where applicable in the VectorXX functions. This fixes a
compiler warning introduced in the last patch.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Since we've already generated a bsp tree at this point, we may as well use our
knowledge about it's properties. If our line is completely on one side of the
decision node, we only need to recurse down one of the child nodes.
Signed-off-by: Tyrann <tyrann@disenchant.net>
We need to allow for floating-point imprecisions when testing a line against
collision with bsp surfaces. This fixes a problem where the simplified leak
line generated would appear to pass through solid surfaces in the bsp.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Set the vec_t type to "double" using the DOUBLEVEC_T preproccessor define. Fix
up hard-coded usages of float in various places throughout the code. Note that
texinfo_t is an on-disk structure, so that needs to stay as float and we work
around incompatibilities with the vector functions using a temporary vec3_t.
Signed-off-by: Tyrann <tyrann@disenchant.net>
Make needlessly global functions/variables static.
Move some checking functions inside an #ifdef PARANOID section.
Signed-off-by: Tyrann <tyrann@disenchant.net>