From e4c77aa4fa6ab002873f65064ed698804a82ba96 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 16 Sep 2022 21:55:14 +0200 Subject: [PATCH 1/2] Fix: Use ASCII treeview in assimp-cmd. --- code/AssetLib/X/XFileImporter.cpp | 7 +------ code/AssetLib/X/XFileImporter.h | 2 +- code/Common/Compression.h | 4 ++-- tools/assimp_cmd/Info.cpp | 8 ++++++-- tools/assimp_cmd/Main.cpp | 15 ++++++--------- tools/assimp_cmd/Main.h | 6 +++--- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index 83e9a74f2..b96b041aa 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -75,15 +75,10 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -XFileImporter::XFileImporter() -: mBuffer() { +XFileImporter::XFileImporter() : mBuffer() { // empty } -// ------------------------------------------------------------------------------------------------ -// Destructor, private as well -XFileImporter::~XFileImporter() = default; - // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. bool XFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const { diff --git a/code/AssetLib/X/XFileImporter.h b/code/AssetLib/X/XFileImporter.h index 648139002..28c283d37 100644 --- a/code/AssetLib/X/XFileImporter.h +++ b/code/AssetLib/X/XFileImporter.h @@ -69,7 +69,7 @@ namespace XFile { class XFileImporter : public BaseImporter { public: XFileImporter(); - ~XFileImporter() override; + ~XFileImporter() override = default; // ------------------------------------------------------------------- /** Returns whether the class can handle the format of the given file. diff --git a/code/Common/Compression.h b/code/Common/Compression.h index edf1d232f..13a79af3f 100644 --- a/code/Common/Compression.h +++ b/code/Common/Compression.h @@ -42,9 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #ifdef ASSIMP_BUILD_NO_OWN_ZLIB -#include +# include #else -#include "../contrib/zlib/zlib.h" +# include "../contrib/zlib/zlib.h" #endif #include diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index ef6554619..45cd1bc1f 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2022, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -68,9 +66,15 @@ const char *TREE_CONTINUE_UTF8 = "\xe2\x94\x82 "; // this is well supported on pretty much any linux terminal. // if this causes problems on some platform, // put an #ifdef to use the ascii version for that platform. +#ifdef _WIN32 +const char *TREE_BRANCH = TREE_BRANCH_ASCII; +const char *TREE_STOP = TREE_STOP_ASCII; +const char *TREE_CONTINUE = TREE_CONTINUE_ASCII; +#else const char *TREE_BRANCH = TREE_BRANCH_UTF8; const char *TREE_STOP = TREE_STOP_UTF8; const char *TREE_CONTINUE = TREE_CONTINUE_UTF8; +#endif // ----------------------------------------------------------------------------------- unsigned int CountNodes(const aiNode *root) { diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index a795a5472..96825b3fd 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -58,11 +58,12 @@ public: ~ConsoleProgressHandler() override = default; bool Update(float percentage) override { - std::cout << percentage * 100.0f << " %\n"; + std::cout << "\r" << percentage * 100.0f << " %"; return true; } }; -const char* AICMD_MSG_ABOUT = + +constexpr char AICMD_MSG_ABOUT[] = "------------------------------------------------------ \n" "Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n" " -- Commandline toolchain --\n" @@ -70,7 +71,7 @@ const char* AICMD_MSG_ABOUT = "Version %i.%i %s%s%s%s%s(GIT commit %x)\n\n"; -const char* AICMD_MSG_HELP = +constexpr char AICMD_MSG_HELP[] = "assimp \n\n" " verbs:\n" " \tinfo - Quick file stats\n" @@ -96,8 +97,7 @@ const char* AICMD_MSG_HELP = // ------------------------------------------------------------------------------ // Application entry point -int main (int argc, char* argv[]) -{ +int main (int argc, char* argv[]) { if (argc <= 1) { printf("assimp: No command specified. Use \'assimp help\' for a detailed command list\n"); return AssimpCmdError::Success; @@ -550,10 +550,7 @@ int ProcessStandardArguments( } // ------------------------------------------------------------------------------ -int Assimp_TestBatchLoad ( - const char* const* params, - unsigned int num) -{ +int Assimp_TestBatchLoad(const char* const* params, unsigned int num) { for(unsigned int i = 0; i < num; ++i) { globalImporter->ReadFile(params[i],aiProcessPreset_TargetRealtime_MaxQuality); // we're totally silent. scene destructs automatically. diff --git a/tools/assimp_cmd/Main.h b/tools/assimp_cmd/Main.h index 1d3dd8fb2..3cce09b03 100644 --- a/tools/assimp_cmd/Main.h +++ b/tools/assimp_cmd/Main.h @@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AICMD_MAIN_INCLUDED #ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS #endif #include @@ -66,9 +66,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #ifdef ASSIMP_BUILD_NO_OWN_ZLIB -#include +# include #else -#include <../contrib/zlib/zlib.h> +# include <../contrib/zlib/zlib.h> #endif From 7ebe21958d5d4e0dc1ea73bf4cab2459b8ae9cd9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 16 Sep 2022 22:13:58 +0200 Subject: [PATCH 2/2] FIX: Fix review findings --- tools/assimp_cmd/Info.cpp | 14 +++++++------- tools/assimp_cmd/Main.h | 29 ++++++++++------------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index 45cd1bc1f..f4dca6c9f 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -48,19 +48,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -const char *AICMD_MSG_INFO_HELP_E = +constexpr char AICMD_MSG_INFO_HELP_E[] = "assimp info [-r] [-v]\n" "\tPrint basic structure of a 3D model\n" "\t-r,--raw: No postprocessing, do a raw import\n" "\t-v,--verbose: Print verbose info such as node transform data\n" "\t-s, --silent: Print only minimal info\n"; -const char *TREE_BRANCH_ASCII = "|-"; -const char *TREE_BRANCH_UTF8 = "\xe2\x94\x9c\xe2\x95\xb4"; -const char *TREE_STOP_ASCII = "'-"; -const char *TREE_STOP_UTF8 = "\xe2\x94\x94\xe2\x95\xb4"; -const char *TREE_CONTINUE_ASCII = "| "; -const char *TREE_CONTINUE_UTF8 = "\xe2\x94\x82 "; +constexpr char TREE_BRANCH_ASCII[] = "|-"; +constexpr char TREE_BRANCH_UTF8[] = "\xe2\x94\x9c\xe2\x95\xb4"; +constexpr char TREE_STOP_ASCII[] = "'-"; +constexpr char TREE_STOP_UTF8[] = "\xe2\x94\x94\xe2\x95\xb4"; +constexpr char TREE_CONTINUE_ASCII[] = "| "; +constexpr char TREE_CONTINUE_UTF8[] = "\xe2\x94\x82 "; // note: by default this is using utf-8 text. // this is well supported on pretty much any linux terminal. diff --git a/tools/assimp_cmd/Main.h b/tools/assimp_cmd/Main.h index 3cce09b03..a95bc96f6 100644 --- a/tools/assimp_cmd/Main.h +++ b/tools/assimp_cmd/Main.h @@ -60,26 +60,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include "../code/Common/Compression.h" #ifndef ASSIMP_BUILD_NO_EXPORT # include #endif -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -#else -# include <../contrib/zlib/zlib.h> -#endif - - #ifndef SIZE_MAX # define SIZE_MAX (std::numeric_limits::max()) #endif - using namespace Assimp; - // Global assimp importer instance extern Assimp::Importer* globalImporter; @@ -118,8 +110,8 @@ struct ImportData { aiVector3D rot; }; -/// \enum AssimpCmdError -/// \brief General error codes used among assimp_cmd's utilities. +// ------------------------------------------------------------------------------ +/// @brief General error codes used among assimp_cmd's utilities. enum AssimpCmdError { Success = 0, InvalidNumberOfArguments, @@ -179,8 +171,8 @@ int Assimp_Dump ( const char* const* params, unsigned int num); -/// \enum AssimpCmdExportError -/// \brief Error codes used by the 'Export' utility. +// ------------------------------------------------------------------------------ +/// @brief Error codes used by the 'Export' utility. enum AssimpCmdExportError { FailedToImportModel = AssimpCmdError::LastAssimpCmdError, FailedToExportModel, @@ -199,8 +191,8 @@ int Assimp_Export ( const char* const* params, unsigned int num); -/// \enum AssimpCmdExtractError -/// \brief Error codes used by the 'Image Extractor' utility. +// ------------------------------------------------------------------------------ +/// @brief Error codes used by the 'Image Extractor' utility. enum AssimpCmdExtractError { TextureIndexIsOutOfRange = AssimpCmdError::LastAssimpCmdError, NoAvailableTextureEncoderFound, @@ -220,8 +212,8 @@ int Assimp_Extract ( const char* const* params, unsigned int num); -/// \enum AssimpCmdCompareDumpError -/// \brief Error codes used by the 'Compare Dump' utility. +// ------------------------------------------------------------------------------ +/// @brief Error codes used by the 'Compare Dump' utility. enum AssimpCmdCompareDumpError { FailedToLoadExpectedInputFile = AssimpCmdError::LastAssimpCmdError, FileComparaisonFailure, @@ -241,8 +233,7 @@ int Assimp_CompareDump ( const char* const* params, unsigned int num); -/// \enum AssimpCmdInfoError -/// \brief Error codes used by the 'Info' utility. +/// @brief Error codes used by the 'Info' utility. enum AssimpCmdInfoError { InvalidCombinaisonOfArguments = AssimpCmdError::LastAssimpCmdError,