From 44e1bcd3e145d18eb29d2915581ad4c61bb65cc7 Mon Sep 17 00:00:00 2001 From: Richard Geldreich Date: Fri, 11 Feb 2022 21:28:52 -0500 Subject: [PATCH] Fixing some bugs related to changing the default from -tex_array to -individual: - If -output_file is specified and there's more than 1 input, it errors out as this would overwrite the output file multiple times - Tex types cubemap/3D default to tex_array mode --- basisu_tool.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/basisu_tool.cpp b/basisu_tool.cpp index 29f21890..7b2873cc 100644 --- a/basisu_tool.cpp +++ b/basisu_tool.cpp @@ -706,9 +706,15 @@ class command_line_params m_individual = false; } else if (strcasecmp(pType, "3d") == 0) + { m_comp_params.m_tex_type = basist::cBASISTexTypeVolume; + m_individual = false; + } else if (strcasecmp(pType, "cubemap") == 0) + { m_comp_params.m_tex_type = basist::cBASISTexTypeCubemapArray; + m_individual = false; + } else if (strcasecmp(pType, "video") == 0) { m_comp_params.m_tex_type = basist::cBASISTexTypeVideoFrames; @@ -1074,6 +1080,16 @@ static bool compress_mode(command_line_params &opts) const size_t total_files = (opts.m_individual ? opts.m_input_filenames.size() : 1U); bool result = true; + if ((opts.m_individual) && (opts.m_output_filename.size())) + { + if (total_files > 1) + { + error_printf("-output_file specified in individual mode, but multiple input files have been specified which would cause the output file to be written multiple times.\n"); + delete pGlobal_codebook_data; pGlobal_codebook_data = nullptr; + return false; + } + } + for (size_t file_index = 0; file_index < total_files; file_index++) { if (opts.m_individual) @@ -1102,8 +1118,8 @@ static bool compress_mode(command_line_params &opts) params.m_source_filenames = opts.m_input_filenames; params.m_source_alpha_filenames = opts.m_input_alpha_filenames; } - - if ((opts.m_output_filename.size()) && (!opts.m_individual)) + + if (opts.m_output_filename.size()) params.m_out_filename = opts.m_output_filename; else {