From f47479aba4797fc9c9b119cd21ab427748a9f839 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 8 Sep 2021 23:18:13 +0200 Subject: [PATCH 1/5] Rework format + introdule missing C++11 features --- code/Common/Bitmap.cpp | 57 ++++++++++++------------ include/assimp/Bitmap.h | 14 ++++-- include/assimp/BlobIOSystem.h | 75 +++++++++++++++++--------------- include/assimp/ByteSwapper.h | 4 +- include/assimp/ColladaMetaData.h | 1 - include/assimp/CreateAnimMesh.h | 1 - include/assimp/DefaultIOStream.h | 37 +++++++--------- include/assimp/DefaultIOSystem.h | 11 +++-- include/assimp/DefaultLogger.hpp | 34 ++++++++------- include/assimp/Exceptional.h | 30 +++++++++++-- include/assimp/IOSystem.hpp | 54 ++++++++++------------- include/assimp/Importer.hpp | 2 +- include/assimp/LineSplitter.h | 56 +++++++++--------------- include/assimp/LogStream.hpp | 9 ++-- include/assimp/Logger.hpp | 27 ++++-------- include/assimp/NullLogger.hpp | 5 +++ include/assimp/aabb.h | 24 +++++----- include/assimp/ai_assert.h | 26 +++++++---- include/assimp/camera.h | 34 +++++++-------- include/assimp/cfileio.h | 5 +-- include/assimp/color4.inl | 2 - include/assimp/commonMetaData.h | 2 - 22 files changed, 258 insertions(+), 252 deletions(-) diff --git a/code/Common/Bitmap.cpp b/code/Common/Bitmap.cpp index 23b96d42d..51f31625e 100644 --- a/code/Common/Bitmap.cpp +++ b/code/Common/Bitmap.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -54,33 +52,36 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -void Bitmap::Save(aiTexture *texture, IOStream *file) { - if (file != nullptr) { - Header header; - DIB dib; - - dib.size = DIB::dib_size; - dib.width = texture->mWidth; - dib.height = texture->mHeight; - dib.planes = 1; - dib.bits_per_pixel = 8 * mBytesPerPixel; - dib.compression = 0; - dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; - dib.x_resolution = 0; - dib.y_resolution = 0; - dib.nb_colors = 0; - dib.nb_important_colors = 0; - - header.type = 0x4D42; // 'BM' - header.offset = Header::header_size + DIB::dib_size; - header.size = header.offset + dib.image_size; - header.reserved1 = 0; - header.reserved2 = 0; - - WriteHeader(header, file); - WriteDIB(dib, file); - WriteData(texture, file); +bool Bitmap::Save(aiTexture *texture, IOStream *file) { + if (file == nullptr) { + return false; } + + Header header; + DIB dib; + dib.size = DIB::dib_size; + dib.width = texture->mWidth; + dib.height = texture->mHeight; + dib.planes = 1; + dib.bits_per_pixel = 8 * mBytesPerPixel; + dib.compression = 0; + dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; + dib.x_resolution = 0; + dib.y_resolution = 0; + dib.nb_colors = 0; + dib.nb_important_colors = 0; + + header.type = 0x4D42; // 'BM' + header.offset = Header::header_size + DIB::dib_size; + header.size = header.offset + dib.image_size; + header.reserved1 = 0; + header.reserved2 = 0; + + WriteHeader(header, file); + WriteDIB(dib, file); + WriteData(texture, file); + + return true; } template diff --git a/include/assimp/Bitmap.h b/include/assimp/Bitmap.h index e4ce194d9..228f6e9ba 100644 --- a/include/assimp/Bitmap.h +++ b/include/assimp/Bitmap.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -55,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #include "defs.h" -#include +#include #include struct aiTexture; @@ -64,6 +62,10 @@ namespace Assimp { class IOStream; +// --------------------------------------------------------------------------- +/** + * This class is used to store and write bitmap information. + */ class ASSIMP_API Bitmap { protected: @@ -114,7 +116,11 @@ protected: static constexpr std::size_t mBytesPerPixel = 4; public: - static void Save(aiTexture* texture, IOStream* file); + /// @brief Will save an aiTexture instance as a bitmap. + /// @param texture The pointer to the texture instance + /// @param file The filename to save into. + /// @return true if successfully saved, false if not. + static bool Save(aiTexture* texture, IOStream* file); protected: static void WriteHeader(Header& header, IOStream* file); diff --git a/include/assimp/BlobIOSystem.h b/include/assimp/BlobIOSystem.h index 0abf166bc..90e806431 100644 --- a/include/assimp/BlobIOSystem.h +++ b/include/assimp/BlobIOSystem.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -44,14 +42,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Provides cheat implementations for IOSystem and IOStream to * redirect exporter output to a blob chain.*/ +#pragma once #ifndef AI_BLOBIOSYSTEM_H_INCLUDED #define AI_BLOBIOSYSTEM_H_INCLUDED #include -#include #include #include #include +#include #include #include @@ -63,6 +62,10 @@ class BlobIOSystem; // -------------------------------------------------------------------------------------------- class BlobIOStream : public IOStream { public: + /// @brief The class constructor with all needed parameters + /// @param creator Pointer to the creator instance + /// @param file The filename + /// @param initial The initial size BlobIOStream(BlobIOSystem *creator, const std::string &file, size_t initial = 4096) : buffer(), cur_size(), @@ -74,7 +77,8 @@ public: // empty } - virtual ~BlobIOStream(); + /// @brief The class destructor. + ~BlobIOStream() override; public: // ------------------------------------------------------------------- @@ -89,16 +93,12 @@ public: } // ------------------------------------------------------------------- - virtual size_t Read(void *, - size_t, - size_t) { + size_t Read(void *, size_t, size_t) override { return 0; } // ------------------------------------------------------------------- - virtual size_t Write(const void *pvBuffer, - size_t pSize, - size_t pCount) { + size_t Write(const void *pvBuffer, size_t pSize, size_t pCount) override { pSize *= pCount; if (cursor + pSize > cur_size) { Grow(cursor + pSize); @@ -112,23 +112,22 @@ public: } // ------------------------------------------------------------------- - virtual aiReturn Seek(size_t pOffset, - aiOrigin pOrigin) { + aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override { switch (pOrigin) { - case aiOrigin_CUR: - cursor += pOffset; - break; + case aiOrigin_CUR: + cursor += pOffset; + break; - case aiOrigin_END: - cursor = file_size - pOffset; - break; + case aiOrigin_END: + cursor = file_size - pOffset; + break; - case aiOrigin_SET: - cursor = pOffset; - break; + case aiOrigin_SET: + cursor = pOffset; + break; - default: - return AI_FAILURE; + default: + return AI_FAILURE; } if (cursor > file_size) { @@ -136,21 +135,22 @@ public: } file_size = std::max(cursor, file_size); + return AI_SUCCESS; } // ------------------------------------------------------------------- - virtual size_t Tell() const { + size_t Tell() const override { return cursor; } // ------------------------------------------------------------------- - virtual size_t FileSize() const { + size_t FileSize() const override { return file_size; } // ------------------------------------------------------------------- - virtual void Flush() { + void Flush() override { // ignore } @@ -196,15 +196,19 @@ class BlobIOSystem : public IOSystem { public: + /// @brief The default class constructor. BlobIOSystem() : baseName{AI_BLOBIO_MAGIC} { } + /// @brief The class constructor with the base name. + /// @param baseName The base name. BlobIOSystem(const std::string &baseName) : baseName(baseName) { + // empty } - virtual ~BlobIOSystem() { + ~BlobIOSystem() override { for (BlobEntry &blobby : blobs) { delete blobby.second; } @@ -263,18 +267,17 @@ public: public: // ------------------------------------------------------------------- - virtual bool Exists(const char *pFile) const { + bool Exists(const char *pFile) const override { return created.find(std::string(pFile)) != created.end(); } // ------------------------------------------------------------------- - virtual char getOsSeparator() const { + char getOsSeparator() const override { return '/'; } // ------------------------------------------------------------------- - virtual IOStream *Open(const char *pFile, - const char *pMode) { + IOStream *Open(const char *pFile, const char *pMode) override { if (pMode[0] != 'w') { return nullptr; } @@ -284,7 +287,7 @@ public: } // ------------------------------------------------------------------- - virtual void Close(IOStream *pFile) { + void Close(IOStream *pFile) override { delete pFile; } @@ -294,7 +297,7 @@ private: // we don't know in which the files are closed, so we // can't reliably say that the first must be the master // file ... - blobs.push_back(BlobEntry(filename, child->GetBlob())); + blobs.emplace_back(filename, child->GetBlob()); } private: @@ -304,8 +307,10 @@ private: }; // -------------------------------------------------------------------------------------------- -BlobIOStream ::~BlobIOStream() { - creator->OnDestruct(file, this); +BlobIOStream::~BlobIOStream() { + if (nullptr != creator) { + creator->OnDestruct(file, this); + } delete[] buffer; } diff --git a/include/assimp/ByteSwapper.h b/include/assimp/ByteSwapper.h index 98fdafc98..9e1eea10f 100644 --- a/include/assimp/ByteSwapper.h +++ b/include/assimp/ByteSwapper.h @@ -52,10 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include #if _MSC_VER >= 1400 -#include +#include #endif namespace Assimp { diff --git a/include/assimp/ColladaMetaData.h b/include/assimp/ColladaMetaData.h index 602f342f9..f8fd5e6b4 100644 --- a/include/assimp/ColladaMetaData.h +++ b/include/assimp/ColladaMetaData.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/CreateAnimMesh.h b/include/assimp/CreateAnimMesh.h index dda4dc63a..868a1f399 100644 --- a/include/assimp/CreateAnimMesh.h +++ b/include/assimp/CreateAnimMesh.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/DefaultIOStream.h b/include/assimp/DefaultIOStream.h index 6d0e13149..aae80a2a4 100644 --- a/include/assimp/DefaultIOStream.h +++ b/include/assimp/DefaultIOStream.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -82,32 +81,27 @@ public: // ------------------------------------------------------------------- /// Read from stream - size_t Read(void* pvBuffer, - size_t pSize, - size_t pCount); + size_t Read(void* pvBuffer, size_t pSize, size_t pCount) override; // ------------------------------------------------------------------- /// Write to stream - size_t Write(const void* pvBuffer, - size_t pSize, - size_t pCount); + size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) override; // ------------------------------------------------------------------- /// Seek specific position - aiReturn Seek(size_t pOffset, - aiOrigin pOrigin); + aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override; // ------------------------------------------------------------------- /// Get current seek position - size_t Tell() const; + size_t Tell() const override; // ------------------------------------------------------------------- /// Get size of file - size_t FileSize() const; + size_t FileSize() const override; // ------------------------------------------------------------------- /// Flush file contents - void Flush(); + void Flush() override; private: FILE* mFile; @@ -116,22 +110,21 @@ private: }; // ---------------------------------------------------------------------------------- -AI_FORCE_INLINE -DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT -: mFile(nullptr) -, mFilename() -, mCachedSize(SIZE_MAX) { +AI_FORCE_INLINE DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT : + mFile(nullptr), + mFilename(), + mCachedSize(SIZE_MAX) { // empty } // ---------------------------------------------------------------------------------- -AI_FORCE_INLINE -DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename) -: mFile(pFile) -, mFilename(strFilename) -, mCachedSize(SIZE_MAX) { +AI_FORCE_INLINE DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename) : + mFile(pFile), + mFilename(strFilename), + mCachedSize(SIZE_MAX) { // empty } + // ---------------------------------------------------------------------------------- } // ns assimp diff --git a/include/assimp/DefaultIOSystem.h b/include/assimp/DefaultIOSystem.h index 3f7235f5b..c2f1aac61 100644 --- a/include/assimp/DefaultIOSystem.h +++ b/include/assimp/DefaultIOSystem.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -59,23 +58,23 @@ class ASSIMP_API DefaultIOSystem : public IOSystem { public: // ------------------------------------------------------------------- /** Tests for the existence of a file at the given path. */ - bool Exists( const char* pFile) const; + bool Exists( const char* pFile) const override; // ------------------------------------------------------------------- /** Returns the directory separator. */ - char getOsSeparator() const; + char getOsSeparator() const override; // ------------------------------------------------------------------- /** Open a new file with a given path. */ - IOStream* Open( const char* pFile, const char* pMode = "rb"); + IOStream* Open( const char* pFile, const char* pMode = "rb") override; // ------------------------------------------------------------------- /** Closes the given file and releases all resources associated with it. */ - void Close( IOStream* pFile); + void Close( IOStream* pFile) override; // ------------------------------------------------------------------- /** Compare two paths */ - bool ComparePaths (const char* one, const char* second) const; + bool ComparePaths (const char* one, const char* second) const override; /** @brief get the file name of a full filepath * example: /tmp/archive.tar.gz -> archive.tar.gz diff --git a/include/assimp/DefaultLogger.hpp b/include/assimp/DefaultLogger.hpp index f71bb07aa..e06c94f31 100644 --- a/include/assimp/DefaultLogger.hpp +++ b/include/assimp/DefaultLogger.hpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -42,9 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file DefaultLogger.hpp */ +#pragma once #ifndef INCLUDED_AI_DEFAULTLOGGER #define INCLUDED_AI_DEFAULTLOGGER +#ifdef __GNUC__ +#pragma GCC system_header +#endif + #include "LogStream.hpp" #include "Logger.hpp" #include "NullLogger.hpp" @@ -55,7 +59,7 @@ namespace Assimp { class IOStream; struct LogStreamInfo; -/** default name of logfile */ +/** default name of log-file */ #define ASSIMP_DEFAULT_LOG_NAME "AssimpLog.txt" // ------------------------------------------------------------------------------------ @@ -72,7 +76,6 @@ struct LogStreamInfo; * implementation of #Logger to #set(). * @note The whole logging stuff causes a small extra overhead for all imports. */ class ASSIMP_API DefaultLogger : public Logger { - public: // ---------------------------------------------------------------------- /** @brief Creates a logging instance. @@ -121,13 +124,11 @@ public: // ---------------------------------------------------------------------- /** @copydoc Logger::attachStream */ - bool attachStream(LogStream *pStream, - unsigned int severity); + bool attachStream(LogStream *pStream, unsigned int severity) override; // ---------------------------------------------------------------------- /** @copydoc Logger::detachStream */ - bool detachStream(LogStream *pStream, - unsigned int severity); + bool detachStream(LogStream *pStream, unsigned int severity) override; private: // ---------------------------------------------------------------------- @@ -137,22 +138,22 @@ private: // ---------------------------------------------------------------------- /** @briefDestructor */ - ~DefaultLogger(); + ~DefaultLogger() override; /** @brief Logs debug infos, only been written when severity level DEBUG or higher is set */ - void OnDebug(const char *message); + void OnDebug(const char *message) override; /** @brief Logs debug infos, only been written when severity level VERBOSE is set */ - void OnVerboseDebug(const char *message); + void OnVerboseDebug(const char *message) override; /** @brief Logs an info message */ - void OnInfo(const char *message); + void OnInfo(const char *message) override; /** @brief Logs a warning message */ - void OnWarn(const char *message); + void OnWarn(const char *message) override; /** @brief Logs an error message */ - void OnError(const char *message); + void OnError(const char *message) override; // ---------------------------------------------------------------------- /** @brief Writes a message to all streams */ @@ -167,9 +168,9 @@ private: private: // Aliases for stream container - typedef std::vector StreamArray; - typedef std::vector::iterator StreamIt; - typedef std::vector::const_iterator ConstStreamIt; + using StreamArray = std::vector; + using StreamIt = std::vector::iterator; + using ConstStreamIt = std::vector::const_iterator; //! only logging instance static Logger *m_pLogger; @@ -182,6 +183,7 @@ private: char lastMsg[MAX_LOG_MESSAGE_LENGTH * 2]; size_t lastLen; }; + // ------------------------------------------------------------------------------------ } // Namespace Assimp diff --git a/include/assimp/Exceptional.h b/include/assimp/Exceptional.h index 1bf399cbc..3078de9f4 100644 --- a/include/assimp/Exceptional.h +++ b/include/assimp/Exceptional.h @@ -56,10 +56,22 @@ using std::runtime_error; #pragma warning(disable : 4275) #endif +// --------------------------------------------------------------------------- +/** + * The base-class for all other exceptions + */ class ASSIMP_API DeadlyErrorBase : public runtime_error { protected: + /// @brief The class constructor with the formatter. + /// @param f The formatter. DeadlyErrorBase(Assimp::Formatter::format f); + /// @brief The class constructor with the parameter ellipse. + /// @tparam ...T The type for the ellipse + /// @tparam U The other type + /// @param f The formatter + /// @param u One parameter + /// @param ...args The rest template DeadlyErrorBase(Assimp::Formatter::format f, U&& u, T&&... args) : DeadlyErrorBase(std::move(f << std::forward(u)), std::forward(args)...) {} @@ -71,19 +83,31 @@ protected: * nullptr instead of a valid aiScene then. */ class ASSIMP_API DeadlyImportError : public DeadlyErrorBase { public: + /// @brief The class constructor with the message. + /// @param message The message DeadlyImportError(const char *message) : - DeadlyErrorBase(Assimp::Formatter::format(), std::forward(message)) {} + DeadlyErrorBase(Assimp::Formatter::format(), std::forward(message)) { + // empty + } - /** Constructor with arguments */ + /// @brief The class constructor with the parameter ellipse. + /// @tparam ...T The type for the ellipse + /// @param ...args The args template explicit DeadlyImportError(T&&... args) : - DeadlyErrorBase(Assimp::Formatter::format(), std::forward(args)...) {} + DeadlyErrorBase(Assimp::Formatter::format(), std::forward(args)...) { + // empty + } #if defined(_MSC_VER) && defined(__clang__) DeadlyImportError(DeadlyImportError& other) = delete; #endif }; +// --------------------------------------------------------------------------- +/** FOR EXPORTER PLUGINS ONLY: Simple exception class to be thrown if an + * unrecoverable error occurs while exporting. Exporting APIs return + * nullptr instead of a valid aiScene then. */ class ASSIMP_API DeadlyExportError : public DeadlyErrorBase { public: /** Constructor with arguments */ diff --git a/include/assimp/IOSystem.hpp b/include/assimp/IOSystem.hpp index 7be373cf1..dda0718e6 100644 --- a/include/assimp/IOSystem.hpp +++ b/include/assimp/IOSystem.hpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -63,8 +61,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef _WIN32 # include -# include -# include +# include +# include #else # include # include @@ -75,7 +73,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { - class IOStream; +class IOStream; // --------------------------------------------------------------------------- /** @brief CPP-API: Interface to the file system. @@ -226,22 +224,26 @@ public: */ virtual bool ChangeDirectory( const std::string &path ); - virtual bool DeleteFile( const std::string &file ); + // ------------------------------------------------------------------- + /** + * @brief Will delete the given file. + * @param file [in] The filename + * @return true, if the file wase deleted, false if not. + */ + virtual bool DeleteFile(const std::string &file); private: std::vector m_pathStack; }; // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -IOSystem::IOSystem() AI_NO_EXCEPT -: m_pathStack() { +AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT : + m_pathStack() { // empty } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -IOSystem::~IOSystem() { +AI_FORCE_INLINE IOSystem::~IOSystem() { // empty } @@ -252,8 +254,7 @@ IOSystem::~IOSystem() { // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) { +AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) { // NOTE: // For compatibility, interface was changed to const char* to // avoid crashes between binary incompatible STL versions @@ -261,8 +262,7 @@ IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::Exists( const std::string& pFile) const { +AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const { // NOTE: // For compatibility, interface was changed to const char* to // avoid crashes between binary incompatible STL versions @@ -270,8 +270,7 @@ bool IOSystem::Exists( const std::string& pFile) const { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::ComparePaths (const std::string& one, const std::string& second) const { +AI_FORCE_INLINE bool IOSystem::ComparePaths(const std::string& one, const std::string& second) const { // NOTE: // For compatibility, interface was changed to const char* to // avoid crashes between binary incompatible STL versions @@ -279,8 +278,7 @@ bool IOSystem::ComparePaths (const std::string& one, const std::string& second) } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::PushDirectory( const std::string &path ) { +AI_FORCE_INLINE bool IOSystem::PushDirectory( const std::string &path ) { if ( path.empty() ) { return false; } @@ -291,8 +289,7 @@ bool IOSystem::PushDirectory( const std::string &path ) { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -const std::string &IOSystem::CurrentDirectory() const { +AI_FORCE_INLINE const std::string &IOSystem::CurrentDirectory() const { if ( m_pathStack.empty() ) { static const std::string Dummy; return Dummy; @@ -301,14 +298,12 @@ const std::string &IOSystem::CurrentDirectory() const { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -size_t IOSystem::StackSize() const { +AI_FORCE_INLINE size_t IOSystem::StackSize() const { return m_pathStack.size(); } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::PopDirectory() { +AI_FORCE_INLINE bool IOSystem::PopDirectory() { if ( m_pathStack.empty() ) { return false; } @@ -319,8 +314,7 @@ bool IOSystem::PopDirectory() { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::CreateDirectory( const std::string &path ) { +AI_FORCE_INLINE bool IOSystem::CreateDirectory( const std::string &path ) { if ( path.empty() ) { return false; } @@ -333,8 +327,7 @@ bool IOSystem::CreateDirectory( const std::string &path ) { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::ChangeDirectory( const std::string &path ) { +AI_FORCE_INLINE bool IOSystem::ChangeDirectory( const std::string &path ) { if ( path.empty() ) { return false; } @@ -348,8 +341,7 @@ bool IOSystem::ChangeDirectory( const std::string &path ) { // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::DeleteFile( const std::string &file ) { +AI_FORCE_INLINE bool IOSystem::DeleteFile( const std::string &file ) { if ( file.empty() ) { return false; } diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index 09b5b6883..97f34090e 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Public ASSIMP data structures #include -#include +//#include namespace Assimp { // ======================================================================= diff --git a/include/assimp/LineSplitter.h b/include/assimp/LineSplitter.h index 44e6f0f1e..0a9d24437 100644 --- a/include/assimp/LineSplitter.h +++ b/include/assimp/LineSplitter.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -144,26 +143,23 @@ private: bool mSwallow, mSkip_empty_lines, mTrim; }; -AI_FORCE_INLINE -LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) -: mIdx(0) -, mCur() -, mStream(stream) -, mSwallow() -, mSkip_empty_lines(skip_empty_lines) -, mTrim(trim) { +AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) : + mIdx(0), + mCur(), + mStream(stream), + mSwallow(), + mSkip_empty_lines(skip_empty_lines), + mTrim(trim) { mCur.reserve(1024); operator++(); mIdx = 0; } -AI_FORCE_INLINE -LineSplitter::~LineSplitter() { +AI_FORCE_INLINE LineSplitter::~LineSplitter() { // empty } -AI_FORCE_INLINE -LineSplitter& LineSplitter::operator++() { +AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() { if (mSwallow) { mSwallow = false; return *this; @@ -203,18 +199,15 @@ LineSplitter& LineSplitter::operator++() { return *this; } -AI_FORCE_INLINE -LineSplitter &LineSplitter::operator++(int) { +AI_FORCE_INLINE LineSplitter &LineSplitter::operator++(int) { return ++(*this); } -AI_FORCE_INLINE -const char *LineSplitter::operator[] (size_t idx) const { +AI_FORCE_INLINE const char *LineSplitter::operator[] (size_t idx) const { const char* s = operator->()->c_str(); SkipSpaces(&s); for (size_t i = 0; i < idx; ++i) { - for (; !IsSpace(*s); ++s) { if (IsLineEnd(*s)) { throw std::range_error("Token index out of range, EOL reached"); @@ -226,8 +219,7 @@ const char *LineSplitter::operator[] (size_t idx) const { } template -AI_FORCE_INLINE -void LineSplitter::get_tokens(const char* (&tokens)[N]) const { +AI_FORCE_INLINE void LineSplitter::get_tokens(const char* (&tokens)[N]) const { const char* s = operator->()->c_str(); SkipSpaces(&s); @@ -242,45 +234,37 @@ void LineSplitter::get_tokens(const char* (&tokens)[N]) const { } } -AI_FORCE_INLINE -const std::string* LineSplitter::operator -> () const { +AI_FORCE_INLINE const std::string* LineSplitter::operator -> () const { return &mCur; } -AI_FORCE_INLINE -std::string LineSplitter::operator* () const { +AI_FORCE_INLINE std::string LineSplitter::operator* () const { return mCur; } -AI_FORCE_INLINE -LineSplitter::operator bool() const { +AI_FORCE_INLINE LineSplitter::operator bool() const { return mStream.GetRemainingSize() > 0; } -AI_FORCE_INLINE -LineSplitter::operator line_idx() const { +AI_FORCE_INLINE LineSplitter::operator line_idx() const { return mIdx; } -AI_FORCE_INLINE -LineSplitter::line_idx LineSplitter::get_index() const { +AI_FORCE_INLINE LineSplitter::line_idx LineSplitter::get_index() const { return mIdx; } -AI_FORCE_INLINE -StreamReaderLE &LineSplitter::get_stream() { +AI_FORCE_INLINE StreamReaderLE &LineSplitter::get_stream() { return mStream; } -AI_FORCE_INLINE -bool LineSplitter::match_start(const char* check) { +AI_FORCE_INLINE bool LineSplitter::match_start(const char* check) { const size_t len = ::strlen(check); return len <= mCur.length() && std::equal(check, check + len, mCur.begin()); } -AI_FORCE_INLINE -void LineSplitter::swallow_next_increment() { +AI_FORCE_INLINE void LineSplitter::swallow_next_increment() { mSwallow = true; } diff --git a/include/assimp/LogStream.hpp b/include/assimp/LogStream.hpp index 3c2a587a2..64a7955fd 100644 --- a/include/assimp/LogStream.hpp +++ b/include/assimp/LogStream.hpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,9 +42,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file LogStream.hpp * @brief Abstract base class 'LogStream', representing an output log stream. */ +#pragma once #ifndef INCLUDED_AI_LOGSTREAM_H #define INCLUDED_AI_LOGSTREAM_H +#ifdef __GNUC__ +#pragma GCC system_header +#endif + #include "types.h" namespace Assimp { @@ -103,7 +107,6 @@ inline LogStream::~LogStream() { // empty } -// ------------------------------------------------------------------------------------ } // Namespace Assimp -#endif +#endif // INCLUDED_AI_LOGSTREAM_H diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp index aa7ffba7c..549b0fbc2 100644 --- a/include/assimp/Logger.hpp +++ b/include/assimp/Logger.hpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Logger.hpp * @brief Abstract base class 'Logger', base of the logging system. */ +#pragma once #ifndef INCLUDED_AI_LOGGER_H #define INCLUDED_AI_LOGGER_H @@ -93,8 +93,6 @@ public: Err = 8 //!< Error log message }; -public: - /** @brief Virtual destructor */ virtual ~Logger(); @@ -259,39 +257,30 @@ protected: }; // ---------------------------------------------------------------------------------- -// Default constructor -inline -Logger::Logger() AI_NO_EXCEPT -: m_Severity(NORMAL) { +inline Logger::Logger() AI_NO_EXCEPT : + m_Severity(NORMAL) { // empty } // ---------------------------------------------------------------------------------- -// Virtual destructor -inline -Logger::~Logger() { +inline Logger::~Logger() { // empty } // ---------------------------------------------------------------------------------- -// Construction with given logging severity -inline -Logger::Logger(LogSeverity severity) -: m_Severity(severity) { +inline Logger::Logger(LogSeverity severity) : + m_Severity(severity) { // empty } // ---------------------------------------------------------------------------------- -// Log severity setter -inline -void Logger::setLogSeverity(LogSeverity log_severity){ +inline void Logger::setLogSeverity(LogSeverity log_severity){ m_Severity = log_severity; } // ---------------------------------------------------------------------------------- // Log severity getter -inline -Logger::LogSeverity Logger::getLogSeverity() const { +inline Logger::LogSeverity Logger::getLogSeverity() const { return m_Severity; } diff --git a/include/assimp/NullLogger.hpp b/include/assimp/NullLogger.hpp index 8281da4f7..8277b014a 100644 --- a/include/assimp/NullLogger.hpp +++ b/include/assimp/NullLogger.hpp @@ -44,9 +44,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Dummy logger */ +#pragma once #ifndef INCLUDED_AI_NULLLOGGER_H #define INCLUDED_AI_NULLLOGGER_H +#ifdef __GNUC__ +#pragma GCC system_header +#endif + #include "Logger.hpp" namespace Assimp { diff --git a/include/assimp/aabb.h b/include/assimp/aabb.h index cbf6193cb..a6ccdd452 100644 --- a/include/assimp/aabb.h +++ b/include/assimp/aabb.h @@ -44,36 +44,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_AABB_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #include +// --------------------------------------------------------------------------- +/** + * An axis-aligned bounding box. + */ struct aiAABB { C_STRUCT aiVector3D mMin; C_STRUCT aiVector3D mMax; #ifdef __cplusplus - - aiAABB() - : mMin() - , mMax() { + /// @brief The default class constructor. + aiAABB() : + mMin(), mMax() { // empty } - aiAABB(const aiVector3D &min, const aiVector3D &max ) - : mMin(min) - , mMax(max) { + /// @brief The class constructor with the minimum and maximum. + /// @param min The minimum dimension. + /// @param max The maximum dimension. + aiAABB(const aiVector3D &min, const aiVector3D &max) : + mMin(min), mMax(max) { // empty } + /// @brief The class destructor. ~aiAABB() { // empty } #endif // __cplusplus - }; - #endif // AI_AABB_H_INC diff --git a/include/assimp/ai_assert.h b/include/assimp/ai_assert.h index b377b6e8b..b4f1ef8b2 100644 --- a/include/assimp/ai_assert.h +++ b/include/assimp/ai_assert.h @@ -38,6 +38,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ + +/** @file ai_assert.h + * @brief Declares the assimp-specific assertion handler. + */ + #pragma once #ifndef AI_ASSERT_H_INC #define AI_ASSERT_H_INC @@ -46,19 +51,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(ASSIMP_BUILD_DEBUG) -namespace Assimp -{ - // Assert violation behavior can be customized: see AssertHandler.h. - ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); +namespace Assimp { + +/// @brief Assert violation behavior can be customized: see AssertHandler.h. +/// @param failedExpression The expression to validate. +/// @param file The file location +/// @param line The line number +ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); + } +#endif -# define ai_assert(expression) (void)((!!(expression)) || (Assimp::aiAssertViolation(#expression, __FILE__, __LINE__), 0)) -# define ai_assert_entry() ai_assert(false) - +// Define assertion resolinig +#if defined(ASSIMP_BUILD_DEBUG) +# define ai_assert(expression) (void)((!!(expression)) || (Assimp::aiAssertViolation(#expression, __FILE__, __LINE__), 0)) +# define ai_assert_entry() ai_assert(false) #else # define ai_assert(expression) # define ai_assert_entry() #endif // ASSIMP_BUILD_DEBUG #endif // AI_ASSERT_H_INC - diff --git a/include/assimp/camera.h b/include/assimp/camera.h index 6a7acadbb..56c4dbe3f 100644 --- a/include/assimp/camera.h +++ b/include/assimp/camera.h @@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CAMERA_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #include "types.h" @@ -100,8 +100,7 @@ extern "C" { * camera already look in the right direction. * */ -struct aiCamera -{ +struct aiCamera { /** The name of the camera. * * There must be a node in the scenegraph with the same name. @@ -127,7 +126,6 @@ struct aiCamera */ C_STRUCT aiVector3D mUp; - /** 'LookAt' - vector of the camera coordinate system relative to * the coordinate space defined by the corresponding node. * @@ -184,26 +182,27 @@ struct aiCamera #ifdef __cplusplus aiCamera() AI_NO_EXCEPT - : mUp (0.f,1.f,0.f) - , mLookAt (0.f,0.f,1.f) - , mHorizontalFOV (0.25f * (float)AI_MATH_PI) - , mClipPlaneNear (0.1f) - , mClipPlaneFar (1000.f) - , mAspect (0.f) - , mOrthographicWidth (0.f) - {} + : mUp(0.f, 1.f, 0.f), + mLookAt(0.f, 0.f, 1.f), + mHorizontalFOV(0.25f * (float)AI_MATH_PI), + mClipPlaneNear(0.1f), + mClipPlaneFar(1000.f), + mAspect(0.f), + mOrthographicWidth(0.f) {} /** @brief Get a *right-handed* camera matrix from me * @param out Camera matrix to be filled */ - void GetCameraMatrix (aiMatrix4x4& out) const - { + void GetCameraMatrix(aiMatrix4x4 &out) const { /** todo: test ... should work, but i'm not absolutely sure */ /** We don't know whether these vectors are already normalized ...*/ - aiVector3D zaxis = mLookAt; zaxis.Normalize(); - aiVector3D yaxis = mUp; yaxis.Normalize(); - aiVector3D xaxis = mUp^mLookAt; xaxis.Normalize(); + aiVector3D zaxis = mLookAt; + zaxis.Normalize(); + aiVector3D yaxis = mUp; + yaxis.Normalize(); + aiVector3D xaxis = mUp ^ mLookAt; + xaxis.Normalize(); out.a4 = -(xaxis * mPosition); out.b4 = -(yaxis * mPosition); @@ -228,7 +227,6 @@ struct aiCamera #endif }; - #ifdef __cplusplus } #endif diff --git a/include/assimp/cfileio.h b/include/assimp/cfileio.h index c1f8625b9..48a728a2a 100644 --- a/include/assimp/cfileio.h +++ b/include/assimp/cfileio.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -106,8 +104,7 @@ struct aiFileIO * the CRT. However, you can supply a custom implementation to Assimp by * delivering a custom aiFileIO. Use this to enable reading from other sources, * such as ZIP archives or memory locations. */ -struct aiFile -{ +struct aiFile { /** Callback to read from a file */ aiFileReadProc ReadProc; diff --git a/include/assimp/color4.inl b/include/assimp/color4.inl index fb31afa27..e5bfdf356 100644 --- a/include/assimp/color4.inl +++ b/include/assimp/color4.inl @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/commonMetaData.h b/include/assimp/commonMetaData.h index 128281bfb..34a375bf3 100644 --- a/include/assimp/commonMetaData.h +++ b/include/assimp/commonMetaData.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, From 18531e3677e8c8f78d6f7c56bfd642e748c08e3a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 13 Sep 2021 22:38:20 +0200 Subject: [PATCH 2/5] Next iteration for c++11 features. --- code/AssetLib/3DS/3DSExporter.cpp | 2 +- code/AssetLib/3DS/3DSHelper.h | 2 +- code/AssetLib/3DS/3DSLoader.h | 10 +- code/AssetLib/3MF/D3MFExporter.h | 5 +- code/AssetLib/3MF/D3MFImporter.h | 4 + code/AssetLib/3MF/D3MFOpcPackage.cpp | 2 +- code/AssetLib/3MF/D3MFOpcPackage.h | 2 +- code/AssetLib/AC/ACLoader.h | 10 +- code/AssetLib/AMF/AMFImporter.hpp | 8 +- code/AssetLib/AMF/AMFImporter_Node.hpp | 9 +- code/AssetLib/ASE/ASELoader.cpp | 2 - code/AssetLib/ASE/ASELoader.h | 25 +- code/AssetLib/ASE/ASEParser.cpp | 2 - code/AssetLib/Assbin/AssbinExporter.h | 2 +- code/AssetLib/Assbin/AssbinLoader.h | 17 +- code/AssetLib/Assjson/mesh_splitter.cpp | 13 +- code/AssetLib/Assjson/mesh_splitter.h | 35 +- code/AssetLib/Assxml/AssxmlExporter.h | 1 + code/AssetLib/Assxml/AssxmlFileWriter.h | 3 +- code/AssetLib/B3D/B3DImporter.h | 18 +- code/AssetLib/Blender/BlenderLoader.h | 186 ++++--- code/AssetLib/COB/COBLoader.h | 106 ++-- code/AssetLib/COB/COBScene.h | 9 +- code/AssetLib/CSM/CSMLoader.h | 28 +- code/AssetLib/Collada/ColladaLoader.cpp | 1 - code/AssetLib/Collada/ColladaParser.h | 1 + code/AssetLib/DXF/DXFLoader.h | 15 +- code/AssetLib/FBX/FBXImporter.h | 11 +- code/AssetLib/HMP/HMPLoader.h | 53 +- code/AssetLib/IFC/IFCBoolean.cpp | 1 - code/AssetLib/IFC/IFCLoader.h | 92 ++-- code/AssetLib/IFC/IFCUtil.cpp | 1 - code/AssetLib/Irr/IRRLoader.h | 11 +- code/AssetLib/Irr/IRRMeshLoader.h | 8 +- code/AssetLib/Irr/IRRShared.h | 2 +- code/AssetLib/LWO/LWOLoader.h | 208 ++++---- code/AssetLib/LWS/LWSLoader.h | 14 +- code/AssetLib/M3D/M3DImporter.h | 22 +- code/AssetLib/MD2/MD2Loader.h | 38 +- code/AssetLib/MD3/MD3Loader.h | 108 ++-- code/AssetLib/MD5/MD5Loader.h | 12 +- code/AssetLib/MDC/MDCLoader.h | 34 +- code/AssetLib/MDL/MDLLoader.h | 14 +- code/AssetLib/MDL/MDLMaterialLoader.cpp | 3 +- code/AssetLib/MMD/MMDImporter.h | 4 +- code/AssetLib/MS3D/MS3DLoader.h | 64 +-- code/AssetLib/NDO/NDOLoader.h | 50 +- code/AssetLib/NFF/NFFLoader.h | 118 ++--- code/AssetLib/OFF/OFFLoader.cpp | 2 - code/AssetLib/OFF/OFFLoader.h | 26 +- code/AssetLib/Obj/ObjFileData.h | 39 +- code/AssetLib/Obj/ObjFileImporter.h | 12 +- code/AssetLib/Obj/ObjFileMtlImporter.h | 6 +- code/AssetLib/Obj/ObjFileParser.h | 1 - code/AssetLib/Ogre/OgreImporter.cpp | 37 +- code/AssetLib/Ogre/OgreImporter.h | 42 +- code/AssetLib/OpenGEX/OpenGEXExporter.h | 2 +- code/AssetLib/OpenGEX/OpenGEXImporter.cpp | 3 - code/AssetLib/OpenGEX/OpenGEXImporter.h | 29 +- code/AssetLib/Ply/PlyLoader.h | 9 +- code/AssetLib/Ply/PlyParser.h | 3 +- code/AssetLib/Q3BSP/Q3BSPFileImporter.h | 15 +- code/AssetLib/Q3BSP/Q3BSPFileParser.cpp | 1 - code/AssetLib/Q3BSP/Q3BSPFileParser.h | 5 +- code/AssetLib/Q3D/Q3DLoader.h | 48 +- code/AssetLib/Raw/RawLoader.h | 33 +- code/AssetLib/SIB/SIBImporter.h | 31 +- code/AssetLib/SMD/SMDLoader.h | 57 +- code/AssetLib/STL/STLExporter.h | 19 +- code/AssetLib/STL/STLLoader.cpp | 5 +- code/AssetLib/STL/STLLoader.h | 9 +- code/AssetLib/Terragen/TerragenLoader.cpp | 8 +- code/AssetLib/Terragen/TerragenLoader.h | 13 +- code/AssetLib/Unreal/UnrealLoader.cpp | 2 +- code/AssetLib/Unreal/UnrealLoader.h | 16 +- code/AssetLib/X/XFileHelper.h | 115 ++--- code/AssetLib/X/XFileImporter.cpp | 1 - code/AssetLib/X/XFileImporter.h | 13 +- code/AssetLib/XGL/XGLLoader.cpp | 18 +- code/AssetLib/XGL/XGLLoader.h | 8 +- code/AssetLib/glTF/glTFAsset.h | 30 +- code/AssetLib/glTF/glTFImporter.h | 39 +- code/AssetLib/glTF2/glTF2Exporter.cpp | 603 +++++++++++----------- code/AssetLib/glTF2/glTF2Importer.cpp | 107 ++-- code/AssetLib/glTF2/glTF2Importer.h | 41 +- code/CMakeLists.txt | 1 - code/Common/StandardShapes.cpp | 1 - include/assimp/BlobIOSystem.h | 4 + include/assimp/ColladaMetaData.h | 4 + include/assimp/DefaultIOStream.h | 13 +- include/assimp/DefaultIOSystem.h | 4 +- include/assimp/DefaultLogger.hpp | 8 +- include/assimp/Defines.h | 58 --- include/assimp/IOStream.hpp | 2 - include/assimp/IOStreamBuffer.h | 183 +++---- include/assimp/LogAux.h | 7 +- include/assimp/SceneCombiner.h | 5 +- include/assimp/StreamReader.h | 3 +- include/assimp/commonMetaData.h | 4 + include/assimp/defs.h | 39 +- include/assimp/light.h | 12 +- include/assimp/matrix3x3.h | 2 - include/assimp/mesh.h | 11 +- 103 files changed, 1410 insertions(+), 1785 deletions(-) delete mode 100644 include/assimp/Defines.h diff --git a/code/AssetLib/3DS/3DSExporter.cpp b/code/AssetLib/3DS/3DSExporter.cpp index 0beecd563..d1059ae43 100644 --- a/code/AssetLib/3DS/3DSExporter.cpp +++ b/code/AssetLib/3DS/3DSExporter.cpp @@ -56,8 +56,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -using namespace Assimp; namespace Assimp { + using namespace D3DS; namespace { diff --git a/code/AssetLib/3DS/3DSHelper.h b/code/AssetLib/3DS/3DSHelper.h index e8efbf949..933795f65 100644 --- a/code/AssetLib/3DS/3DSHelper.h +++ b/code/AssetLib/3DS/3DSHelper.h @@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include //sprintf +#include //sprintf namespace Assimp { namespace D3DS { diff --git a/code/AssetLib/3DS/3DSLoader.h b/code/AssetLib/3DS/3DSLoader.h index 04dcac237..bd167872f 100644 --- a/code/AssetLib/3DS/3DSLoader.h +++ b/code/AssetLib/3DS/3DSLoader.h @@ -46,11 +46,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef AI_3DSIMPORTER_H_INC #define AI_3DSIMPORTER_H_INC +#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER #include #include -#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER #include "3DSHelper.h" #include @@ -75,14 +75,14 @@ public: * See BaseImporter::CanRead() for details. */ bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; + bool checkSig) const override; // ------------------------------------------------------------------- /** Called prior to ReadFile(). * The function is a request to the importer to update its configuration * basing on the Importer's configuration property list. */ - void SetupProperties(const Importer* pImp); + void SetupProperties(const Importer* pImp) override; protected: @@ -90,14 +90,14 @@ protected: /** Return importer meta information. * See #BaseImporter::GetInfo for the details */ - const aiImporterDesc* GetInfo () const; + const aiImporterDesc* GetInfo () const override; // ------------------------------------------------------------------- /** Imports the given file into the given scene structure. * See BaseImporter::InternReadFile() for details */ void InternReadFile( const std::string& pFile, aiScene* pScene, - IOSystem* pIOHandler); + IOSystem* pIOHandler) override; // ------------------------------------------------------------------- /** Converts a temporary material to the outer representation diff --git a/code/AssetLib/3MF/D3MFExporter.h b/code/AssetLib/3MF/D3MFExporter.h index d2fc82483..3da74fb37 100644 --- a/code/AssetLib/3MF/D3MFExporter.h +++ b/code/AssetLib/3MF/D3MFExporter.h @@ -40,6 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once +#ifndef ASSIMP_BUILD_NO_EXPORT +#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER + #include #include #include @@ -58,8 +61,6 @@ class IOStream; namespace D3MF { -#ifndef ASSIMP_BUILD_NO_EXPORT -#ifndef ASSIMP_BUILD_NO_3MF_EXPORTER struct OpcPackageRelationship; diff --git a/code/AssetLib/3MF/D3MFImporter.h b/code/AssetLib/3MF/D3MFImporter.h index 2b37010d9..7219fa39d 100644 --- a/code/AssetLib/3MF/D3MFImporter.h +++ b/code/AssetLib/3MF/D3MFImporter.h @@ -42,6 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_D3MFLOADER_H_INCLUDED #define AI_D3MFLOADER_H_INCLUDED +#ifndef ASSIMP_BUILD_NO_3MF_IMPORTER + #include namespace Assimp { @@ -84,4 +86,6 @@ protected: } // Namespace Assimp +#endif // #ifndef ASSIMP_BUILD_NO_3MF_IMPORTER + #endif // AI_D3MFLOADER_H_INCLUDED diff --git a/code/AssetLib/3MF/D3MFOpcPackage.cpp b/code/AssetLib/3MF/D3MFOpcPackage.cpp index c29cec368..33428b124 100644 --- a/code/AssetLib/3MF/D3MFOpcPackage.cpp +++ b/code/AssetLib/3MF/D3MFOpcPackage.cpp @@ -51,11 +51,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include "3MFXmlTags.h" + #include #include #include #include -#include #include namespace Assimp { diff --git a/code/AssetLib/3MF/D3MFOpcPackage.h b/code/AssetLib/3MF/D3MFOpcPackage.h index fda74a879..27bf44ff2 100644 --- a/code/AssetLib/3MF/D3MFOpcPackage.h +++ b/code/AssetLib/3MF/D3MFOpcPackage.h @@ -42,9 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef D3MFOPCPACKAGE_H #define D3MFOPCPACKAGE_H +#include #include #include -#include struct aiTexture; diff --git a/code/AssetLib/AC/ACLoader.h b/code/AssetLib/AC/ACLoader.h index 5ae2e80bb..5b706a4a0 100644 --- a/code/AssetLib/AC/ACLoader.h +++ b/code/AssetLib/AC/ACLoader.h @@ -63,7 +63,7 @@ namespace Assimp { class AC3DImporter : public BaseImporter { public: AC3DImporter(); - ~AC3DImporter(); + ~AC3DImporter() override; // Represents an AC3D material struct Material { @@ -185,25 +185,25 @@ public: * See BaseImporter::CanRead() for details. */ bool CanRead(const std::string &pFile, IOSystem *pIOHandler, - bool checkSig) const; + bool checkSig) const override; protected: // ------------------------------------------------------------------- /** Return importer meta information. * See #BaseImporter::GetInfo for the details */ - const aiImporterDesc *GetInfo() const; + const aiImporterDesc *GetInfo() const override; // ------------------------------------------------------------------- /** Imports the given file into the given scene structure. * See BaseImporter::InternReadFile() for details*/ void InternReadFile(const std::string &pFile, aiScene *pScene, - IOSystem *pIOHandler); + IOSystem *pIOHandler) override; // ------------------------------------------------------------------- /** Called prior to ReadFile(). * The function is a request to the importer to update its configuration * basing on the Importer's configuration property list.*/ - void SetupProperties(const Importer *pImp); + void SetupProperties(const Importer *pImp) override; private: // ------------------------------------------------------------------- diff --git a/code/AssetLib/AMF/AMFImporter.hpp b/code/AssetLib/AMF/AMFImporter.hpp index 18ef83c24..a71b6671e 100644 --- a/code/AssetLib/AMF/AMFImporter.hpp +++ b/code/AssetLib/AMF/AMFImporter.hpp @@ -267,7 +267,7 @@ public: AMFImporter() AI_NO_EXCEPT; /// Default destructor. - ~AMFImporter(); + ~AMFImporter() override; /// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph. /// Also exception can be thrown if trouble will found. @@ -276,9 +276,9 @@ public: void ParseFile(const std::string &pFile, IOSystem *pIOHandler); void ParseHelper_Node_Enter(AMFNodeElementBase *child); void ParseHelper_Node_Exit(); - bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const; - void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler); - const aiImporterDesc *GetInfo() const; + bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const override; + void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override; + const aiImporterDesc *GetInfo() const override; bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const; bool Find_ConvertedNode(const std::string &pID, NodeArray &nodeArray, aiNode **pNode) const; bool Find_ConvertedMaterial(const std::string &pID, const SPP_Material **pConvertedMaterial) const; diff --git a/code/AssetLib/AMF/AMFImporter_Node.hpp b/code/AssetLib/AMF/AMFImporter_Node.hpp index 9051b2871..b466e339b 100644 --- a/code/AssetLib/AMF/AMFImporter_Node.hpp +++ b/code/AssetLib/AMF/AMFImporter_Node.hpp @@ -48,15 +48,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INCLUDED_AI_AMF_IMPORTER_NODE_H #define INCLUDED_AI_AMF_IMPORTER_NODE_H -// Header files, stdlib. +// Header files, Assimp. +#include +#include + #include #include #include -// Header files, Assimp. -#include "assimp/scene.h" -#include "assimp/types.h" - /// \class CAMFImporter_NodeElement /// Base class for elements of nodes. class AMFNodeElementBase { diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index 1a42c2f52..a9c7314c1 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/code/AssetLib/ASE/ASELoader.h b/code/AssetLib/ASE/ASELoader.h index 1f30d28e7..9ec9d439f 100644 --- a/code/AssetLib/ASE/ASELoader.h +++ b/code/AssetLib/ASE/ASELoader.h @@ -62,42 +62,37 @@ namespace Assimp { class ASEImporter : public BaseImporter { public: ASEImporter(); - ~ASEImporter(); + ~ASEImporter() override; // ------------------------------------------------------------------- /** Returns whether the class can handle the format of the given file. * See BaseImporter::CanRead() for details. */ bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; + bool checkSig) const override; protected: - // ------------------------------------------------------------------- /** Return importer meta information. * See #BaseImporter::GetInfo for the details */ - const aiImporterDesc* GetInfo () const; - + const aiImporterDesc* GetInfo () const override; // ------------------------------------------------------------------- /** Imports the given file into the given scene structure. * See BaseImporter::InternReadFile() for details */ void InternReadFile( const std::string& pFile, aiScene* pScene, - IOSystem* pIOHandler); - + IOSystem* pIOHandler) override; // ------------------------------------------------------------------- /** Called prior to ReadFile(). * The function is a request to the importer to update its configuration * basing on the Importer's configuration property list. */ - void SetupProperties(const Importer* pImp); - + void SetupProperties(const Importer* pImp) override; private: - // ------------------------------------------------------------------- /** Generate normal vectors basing on smoothing groups * (in some cases the normal are already contained in the file) @@ -106,7 +101,6 @@ private: */ bool GenerateNormals(ASE::Mesh& mesh); - // ------------------------------------------------------------------- /** Create valid vertex/normal/UV/color/face lists. * All elements are unique, faces have only one set of indices @@ -115,51 +109,43 @@ private: */ void BuildUniqueRepresentation(ASE::Mesh& mesh); - /** Create one-material-per-mesh meshes ;-) * \param mesh Mesh to work with * \param Receives the list of all created meshes */ void ConvertMeshes(ASE::Mesh& mesh, std::vector& avOut); - // ------------------------------------------------------------------- /** Convert a material to a aiMaterial object * \param mat Input material */ void ConvertMaterial(ASE::Material& mat); - // ------------------------------------------------------------------- /** Setup the final material indices for each mesh */ void BuildMaterialIndices(); - // ------------------------------------------------------------------- /** Build the node graph */ void BuildNodes(std::vector& nodes); - // ------------------------------------------------------------------- /** Build output cameras */ void BuildCameras(); - // ------------------------------------------------------------------- /** Build output lights */ void BuildLights(); - // ------------------------------------------------------------------- /** Build output animations */ void BuildAnimations(const std::vector& nodes); - // ------------------------------------------------------------------- /** Add sub nodes to a node * \param pcParent parent node to be filled @@ -183,7 +169,6 @@ private: void GenerateDefaultMaterial(); protected: - /** Parser instance */ ASE::Parser* mParser; diff --git a/code/AssetLib/ASE/ASEParser.cpp b/code/AssetLib/ASE/ASEParser.cpp index 1f7018b11..a2884b8dd 100644 --- a/code/AssetLib/ASE/ASEParser.cpp +++ b/code/AssetLib/ASE/ASEParser.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/code/AssetLib/Assbin/AssbinExporter.h b/code/AssetLib/Assbin/AssbinExporter.h index 96dfdd1c2..4871b5021 100644 --- a/code/AssetLib/Assbin/AssbinExporter.h +++ b/code/AssetLib/Assbin/AssbinExporter.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file AssbinExporter.h * ASSBIN Exporter Main Header */ +#pragma once #ifndef AI_ASSBINEXPORTER_H_INC #define AI_ASSBINEXPORTER_H_INC diff --git a/code/AssetLib/Assbin/AssbinLoader.h b/code/AssetLib/Assbin/AssbinLoader.h index 59d799a3d..47f38db2a 100644 --- a/code/AssetLib/Assbin/AssbinLoader.h +++ b/code/AssetLib/Assbin/AssbinLoader.h @@ -5,7 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -74,17 +73,11 @@ private: bool compressed; public: - virtual bool CanRead( - const std::string& pFile, - IOSystem* pIOHandler, - bool checkSig - ) const; - virtual const aiImporterDesc* GetInfo() const; - virtual void InternReadFile( - const std::string& pFile, - aiScene* pScene, - IOSystem* pIOHandler - ); + bool CanRead(const std::string& pFile, + IOSystem* pIOHandler, bool checkSig) const override; + const aiImporterDesc* GetInfo() const override; + void InternReadFile( + const std::string& pFile,aiScene* pScene,IOSystem* pIOHandler) override; void ReadHeader(); void ReadBinaryScene( IOStream * stream, aiScene* pScene ); void ReadBinaryNode( IOStream * stream, aiNode** mRootNode, aiNode* parent ); diff --git a/code/AssetLib/Assjson/mesh_splitter.cpp b/code/AssetLib/Assjson/mesh_splitter.cpp index 9301cc27e..978437c41 100644 --- a/code/AssetLib/Assjson/mesh_splitter.cpp +++ b/code/AssetLib/Assjson/mesh_splitter.cpp @@ -69,13 +69,12 @@ void MeshSplitter::UpdateNode(aiNode* pcNode, const std::vectormNumChildren; i < end;++i) { UpdateNode ( pcNode->mChildren[i], source_mesh_map ); } - return; } -#define WAS_NOT_COPIED 0xffffffff +static const unsigned int WAS_NOT_COPIED = 0xffffffff; -typedef std::pair PerVertexWeight; -typedef std::vector VertexWeightTable; +using PerVertexWeight = std::pair ; +using VertexWeightTable = std::vector ; // ------------------------------------------------------------------------------------------------ VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh) { @@ -89,7 +88,7 @@ VertexWeightTable* ComputeVertexBoneWeightTable(const aiMesh* pMesh) { aiBone* bone = pMesh->mBones[i]; for (unsigned int a = 0; a < bone->mNumWeights;++a) { const aiVertexWeight& weight = bone->mWeights[a]; - avPerVertexWeights[weight.mVertexId].push_back( std::make_pair(i,weight.mWeight) ); + avPerVertexWeights[weight.mVertexId].emplace_back(i,weight.mWeight); } } return avPerVertexWeights; @@ -100,7 +99,7 @@ void MeshSplitter :: SplitMesh(unsigned int a, aiMesh* in_mesh, std::vectormNumVertices <= LIMIT) { - source_mesh_map.push_back(std::make_pair(in_mesh,a)); + source_mesh_map.emplace_back(in_mesh,a); return; } @@ -187,7 +186,7 @@ void MeshSplitter :: SplitMesh(unsigned int a, aiMesh* in_mesh, std::vector> &source_mesh_map); + void SplitMesh(unsigned int index, aiMesh *mesh, std::vector> &source_mesh_map); - void UpdateNode(aiNode* pcNode, const std::vector >& source_mesh_map); - void SplitMesh (unsigned int index, aiMesh* mesh, std::vector >& source_mesh_map); - -public: - - unsigned int LIMIT; }; #endif // INCLUDED_MESH_SPLITTER - diff --git a/code/AssetLib/Assxml/AssxmlExporter.h b/code/AssetLib/Assxml/AssxmlExporter.h index 5c7f155d1..9a3d1f9d5 100644 --- a/code/AssetLib/Assxml/AssxmlExporter.h +++ b/code/AssetLib/Assxml/AssxmlExporter.h @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file AssxmlExporter.h * ASSXML Exporter Main Header */ +#pragma once #ifndef AI_ASSXMLEXPORTER_H_INC #define AI_ASSXMLEXPORTER_H_INC diff --git a/code/AssetLib/Assxml/AssxmlFileWriter.h b/code/AssetLib/Assxml/AssxmlFileWriter.h index e5f27095e..125869d1a 100644 --- a/code/AssetLib/Assxml/AssxmlFileWriter.h +++ b/code/AssetLib/Assxml/AssxmlFileWriter.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file AssxmlFileWriter.h * @brief Declaration of Assxml file writer. */ - +#pragma once #ifndef AI_ASSXMLFILEWRITER_H_INC #define AI_ASSXMLFILEWRITER_H_INC diff --git a/code/AssetLib/B3D/B3DImporter.h b/code/AssetLib/B3D/B3DImporter.h index a7ed65c3b..bb535afd1 100644 --- a/code/AssetLib/B3D/B3DImporter.h +++ b/code/AssetLib/B3D/B3DImporter.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -40,8 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ -/** @file Definition of the .b3d importer class. */ - +/** + * @file Definition of the .b3d importer class. + */ +#pragma once #ifndef AI_B3DIMPORTER_H_INC #define AI_B3DIMPORTER_H_INC @@ -62,14 +63,12 @@ namespace Assimp{ class B3DImporter : public BaseImporter{ public: B3DImporter() = default; - virtual ~B3DImporter(); - - virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const; + ~B3DImporter() override; + bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override; protected: - - virtual const aiImporterDesc* GetInfo () const; - virtual void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler); + const aiImporterDesc* GetInfo () const override; + void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override; private: @@ -113,7 +112,6 @@ private: void ReadBB3D( aiScene *scene ); size_t _pos; -// unsigned _size; std::vector _buf; std::vector _stack; diff --git a/code/AssetLib/Blender/BlenderLoader.h b/code/AssetLib/Blender/BlenderLoader.h index 42da76514..1df0fcf90 100644 --- a/code/AssetLib/Blender/BlenderLoader.h +++ b/code/AssetLib/Blender/BlenderLoader.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file BlenderLoader.h * @brief Declaration of the Blender 3D (*.blend) importer class. */ +#pragma once #ifndef INCLUDED_AI_BLEND_LOADER_H #define INCLUDED_AI_BLEND_LOADER_H @@ -56,149 +56,139 @@ struct aiLight; struct aiCamera; struct aiMaterial; -namespace Assimp { +namespace Assimp { - // TinyFormatter.h - namespace Formatter { - template class basic_formatter; - typedef class basic_formatter< char, std::char_traits, std::allocator > format; - } +// TinyFormatter.h +namespace Formatter { - // BlenderDNA.h - namespace Blender { - class FileDatabase; - struct ElemBase; - } +template +class basic_formatter; - // BlenderScene.h - namespace Blender { - struct Scene; - struct Object; - struct Mesh; - struct Camera; - struct Lamp; - struct MTex; - struct Image; - struct Material; - } +typedef class basic_formatter, std::allocator> format; - // BlenderIntermediate.h - namespace Blender { - struct ConversionData; - template