Browse Source

Merge pull request #3014 from iamAdrianIusca/master

small changes
Kim Kulling 5 years ago
parent
commit
848922feae

+ 0 - 4
CMakeLists.txt

@@ -437,10 +437,6 @@ ELSE(HUNTER_ENABLED)
     DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
 ENDIF(HUNTER_ENABLED)
 
-if (ASSIMP_BUILD_SAMPLES OR ASSIMP_BUILD_SAMPLES)
-  FIND_PACKAGE(DirectX)
-endif(ASSIMP_BUILD_SAMPLES OR ASSIMP_BUILD_SAMPLES)
-
 IF( BUILD_DOCS )
   ADD_SUBDIRECTORY(doc)
 ENDIF( BUILD_DOCS )

+ 3 - 4
code/Common/BaseImporter.cpp

@@ -191,7 +191,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
     }
 
     std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
-    if (pStream.get() ) {
+    if (pStream) {
         // read 200 characters from the file
         std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
         char *buffer( _buffer.get() );
@@ -283,7 +283,6 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
         return "";
     }
 
-
     // thanks to Andy Maloney for the hint
     std::string ret = file.substr( pos + 1 );
     std::transform( ret.begin(), ret.end(), ret.begin(), ToLower<char>);
@@ -309,7 +308,7 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
     };
     magic = reinterpret_cast<const char*>(_magic);
     std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
-    if (pStream.get() ) {
+    if (pStream) {
 
         // skip to offset
         pStream->Seek(offset,aiOrigin_SET);
@@ -603,7 +602,7 @@ unsigned int BatchLoader::AddLoadRequest(const std::string& file,
     }
 
     // no, we don't have it. So add it to the queue ...
-    m_data->requests.push_back(LoadRequest(file,steps,map, m_data->next_id));
+    m_data->requests.emplace_back(file, steps, map, m_data->next_id);
     return m_data->next_id++;
 }
 

+ 4 - 4
code/Common/Importer.cpp

@@ -1071,7 +1071,7 @@ ai_real Importer::GetPropertyFloat(const char* szName, ai_real iErrorReturn /*=
 
 // ------------------------------------------------------------------------------------------------
 // Get a configuration property
-const std::string Importer::GetPropertyString(const char* szName, const std::string& iErrorReturn /*= ""*/) const {
+std::string Importer::GetPropertyString(const char* szName, const std::string& iErrorReturn /*= ""*/) const {
     ai_assert(nullptr != pimpl);
     
     return GetGenericProperty<std::string>(pimpl->mStringProperties,szName,iErrorReturn);
@@ -1079,7 +1079,7 @@ const std::string Importer::GetPropertyString(const char* szName, const std::str
 
 // ------------------------------------------------------------------------------------------------
 // Get a configuration property
-const aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const {
+aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const {
     ai_assert(nullptr != pimpl);
     
     return GetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties,szName,iErrorReturn);
@@ -1110,10 +1110,9 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
     aiScene* mScene = pimpl->mScene;
 
     // return if we have no scene loaded
-    if (!pimpl->mScene)
+    if (!mScene)
         return;
 
-
     in.total = sizeof(aiScene);
 
     // add all meshes
@@ -1202,5 +1201,6 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
             in.materials += pc->mProperties[a]->mDataLength;
         }
     }
+
     in.total += in.materials;
 }

+ 0 - 2
code/Common/ZipArchiveIOSystem.cpp

@@ -343,8 +343,6 @@ namespace Assimp {
     }
 
     ZipArchiveIOSystem::Implement::~Implement() {
-        m_ArchiveMap.clear();
-
         if (m_ZipFileHandle != nullptr) {
             unzClose(m_ZipFileHandle);
             m_ZipFileHandle = nullptr;

+ 4 - 11
code/Obj/ObjFileData.h

@@ -110,10 +110,7 @@ struct Object {
     std::vector<unsigned int> m_Meshes;
 
     //! \brief  Default constructor
-    Object() 
-    : m_strObjName("") {
-        // empty
-    }
+    Object() = default;
 
     //! \brief  Destructor
     ~Object() {
@@ -191,16 +188,12 @@ struct Material {
     ,   illumination_model (1)
     ,   ior     ( ai_real( 1.0 ) )
     ,   transparent( ai_real( 1.0), ai_real (1.0), ai_real(1.0)) {
-        // empty
-        for (size_t i = 0; i < TextureTypeCount; ++i) {
-            clamp[ i ] = false;
-        }
+
+	    std::fill_n(clamp, static_cast<unsigned int>(TextureTypeCount), false);
     }
 
     // Destructor
-    ~Material() {
-        // empty
-    }
+    ~Material() = default;
 };
 
 // ------------------------------------------------------------------------------------------------

+ 9 - 6
code/Obj/ObjFileParser.cpp

@@ -53,6 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assimp/material.h>
 #include <assimp/Importer.hpp>
 #include <cstdlib>
+#include <memory>
+#include <utility>
 
 namespace Assimp {
 
@@ -71,16 +73,16 @@ ObjFileParser::ObjFileParser()
 
 ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName,
                               IOSystem *io, ProgressHandler* progress,
-                              const std::string &originalObjFileName) :
+                              std::string originalObjFileName) :
     m_DataIt(),
     m_DataItEnd(),
     m_pModel(nullptr),
     m_uiLine(0),
-    m_pIO( io ),
+    m_pIO(io),
     m_progress(progress),
-    m_originalObjFileName(originalObjFileName)
+    m_originalObjFileName(std::move(originalObjFileName))
 {
-    std::fill_n(m_buffer,Buffersize,0);
+    std::fill_n(m_buffer, Buffersize,0);
 
     // Create the model instance to store all the data
     m_pModel.reset(new ObjFile::Model());
@@ -96,7 +98,8 @@ ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::str
     parseFile( streamBuffer );
 }
 
-ObjFileParser::~ObjFileParser() {
+ObjFileParser::~ObjFileParser()
+{
 }
 
 void ObjFileParser::setBuffer( std::vector<char> &buffer ) {
@@ -128,7 +131,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
             processed = static_cast<unsigned int>(filePos);
             lastFilePos = filePos;
             progressCounter++;
-            m_progress->UpdateFileRead( processed, progressTotal );
+            m_progress->UpdateFileRead(processed, progressTotal);
         }
 
         // parse line

+ 1 - 1
code/Obj/ObjFileParser.h

@@ -78,7 +78,7 @@ public:
     /// @brief  The default constructor.
     ObjFileParser();
     /// @brief  Constructor with data array.
-    ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, const std::string &originalObjFileName);
+    ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, std::string originalObjFileName);
     /// @brief  Destructor
     ~ObjFileParser();
     /// @brief  If you want to load in-core data.

+ 3 - 5
code/PostProcessing/TextureTransform.cpp

@@ -92,9 +92,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
      *  are applied is - as always - scaling, rotation, translation.
      */
 
-    char szTemp[512];
-    int rounded = 0;
-
+	int rounded;
+	char szTemp[512];
 
     /* Optimize the rotation angle. That's slightly difficult as
      * we have an inprecise floating-point number (when comparing
@@ -185,7 +184,6 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
             info.mTranslation.y = out;
         }
     }
-    return;
 }
 
 // ------------------------------------------------------------------------------------------------
@@ -428,7 +426,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
         // at the end of the list
         bool ref[AI_MAX_NUMBER_OF_TEXTURECOORDS];
         for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
-            ref[n] = (!mesh->mTextureCoords[n] ? true : false);
+            ref[n] = !mesh->mTextureCoords[n];
 
         for (it = trafo.begin();it != trafo.end(); ++it)
             ref[(*it).uvIndex] = true;

+ 2 - 2
include/assimp/Importer.hpp

@@ -285,7 +285,7 @@ public:
      *  The return value remains valid until the property is modified.
      * @see GetPropertyInteger()
      */
-    const std::string GetPropertyString(const char* szName,
+    std::string GetPropertyString(const char* szName,
         const std::string& sErrorReturn = "") const;
 
     // -------------------------------------------------------------------
@@ -294,7 +294,7 @@ public:
      *  The return value remains valid until the property is modified.
      * @see GetPropertyInteger()
      */
-    const aiMatrix4x4 GetPropertyMatrix(const char* szName,
+    aiMatrix4x4 GetPropertyMatrix(const char* szName,
         const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
 
     // -------------------------------------------------------------------