diff --git a/.travis.yml b/.travis.yml index 661de2279..ffebab3cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,15 @@ language: cpp before_install: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq && sudo apt-get install cmake && sudo apt-get install cmake python3 && sudo apt-get install -qq freeglut3-dev libxmu-dev libxi-dev ; echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- ; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install cmake python3 homebrew/x11/freeglut; fi + - 'if [ "$TRAVIS_OS_NAME" = "osx" ]; then + if brew ls --versions cmake > /dev/null; then + echo cmake already installed.; + else + brew install cmake; + fi; + brew install python3; + brew install homebrew/x11/freeglut; + fi' - echo -e "#ifndef A_R_H_INC\n#define A_R_H_INC\n#define GitVersion ${TRAVIS_JOB_ID}\n#define GitBranch \"${TRAVIS_BRANCH}\"\n#endif // A_R_H_INC" > revision.h # install latest LCOV (1.9 was failing) - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ${TRAVIS_BUILD_DIR} && wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz && tar xf lcov_1.11.orig.tar.gz && sudo make -C lcov-1.11/ install && gem install coveralls-lcov && lcov --version && g++ --version ; fi diff --git a/code/FBXAnimation.cpp b/code/FBXAnimation.cpp index 6b2c1eff6..e905b5bfc 100644 --- a/code/FBXAnimation.cpp +++ b/code/FBXAnimation.cpp @@ -50,12 +50,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "FBXDocument.h" #include "FBXImporter.h" #include "FBXDocumentUtil.h" -#include "FBXProperties.h" namespace Assimp { namespace FBX { - using namespace Util; +using namespace Util; // ------------------------------------------------------------------------------------------------ AnimationCurve::AnimationCurve(uint64_t id, const Element& element, const std::string& name, const Document& /*doc*/) diff --git a/code/OptimizeMeshes.cpp b/code/OptimizeMeshes.cpp index 65a3cadce..f8183fc75 100644 --- a/code/OptimizeMeshes.cpp +++ b/code/OptimizeMeshes.cpp @@ -181,11 +181,8 @@ void OptimizeMeshesProcess::ProcessNode( aiNode* pNode) verts += mScene->mMeshes[am]->mNumVertices; faces += mScene->mMeshes[am]->mNumFaces; + pNode->mMeshes[a] = pNode->mMeshes[pNode->mNumMeshes - 1]; --pNode->mNumMeshes; - for( unsigned int n = a; n < pNode->mNumMeshes; ++n ) { - pNode->mMeshes[ n ] = pNode->mMeshes[ n + 1 ]; - } - --a; } } diff --git a/code/Profiler.h b/code/Profiler.h index 40d436b52..1c9ca60b5 100644 --- a/code/Profiler.h +++ b/code/Profiler.h @@ -52,21 +52,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include namespace Assimp { - namespace Profiling { - - using namespace Formatter; +namespace Profiling { +using namespace Formatter; // ------------------------------------------------------------------------------------------------ /** Simple wrapper around boost::timer to simplify reporting. Timings are automatically * dumped to the log file. */ -class Profiler -{ - +class Profiler { public: - - Profiler() {} + Profiler() { + // empty + } public: @@ -84,17 +82,17 @@ public: return; } - auto elapsedSeconds = std::chrono::system_clock::now() - regions[region]; + std::chrono::duration elapsedSeconds = std::chrono::system_clock::now() - regions[region]; DefaultLogger::get()->debug((format("END `"),region,"`, dt= ", elapsedSeconds.count()," s")); } private: - typedef std::map> RegionMap; RegionMap regions; }; - } +} } #endif + diff --git a/include/assimp/LogStream.hpp b/include/assimp/LogStream.hpp index 049640ec0..1052f1fda 100644 --- a/include/assimp/LogStream.hpp +++ b/include/assimp/LogStream.hpp @@ -64,12 +64,11 @@ class ASSIMP_API LogStream { protected: /** @brief Default constructor */ - LogStream() { - } + LogStream(); + public: /** @brief Virtual destructor */ - virtual ~LogStream() { - } + virtual ~LogStream(); // ------------------------------------------------------------------- /** @brief Overwrite this for your own output methods @@ -94,6 +93,17 @@ public: IOSystem* io = NULL); }; // !class LogStream + +inline +LogStream::LogStream() { + // empty +} + +inline +LogStream::~LogStream() { + // empty +} + // ------------------------------------------------------------------------------------ } // Namespace Assimp diff --git a/include/assimp/cimport.h b/include/assimp/cimport.h index 98be269d3..8aa125c67 100644 --- a/include/assimp/cimport.h +++ b/include/assimp/cimport.h @@ -417,7 +417,7 @@ ASSIMP_API void aiSetImportPropertyInteger( ASSIMP_API void aiSetImportPropertyFloat( C_STRUCT aiPropertyStore* store, const char* szName, - float value); + ai_real value); // -------------------------------------------------------------------------------- /** Set a string property. diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index ac3df9290..573ce27b1 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -119,7 +119,10 @@ def _init(self, target = None, parent = None): if m == 'mName': obj = self.mName - uni = unicode(obj.data, errors='ignore') + try: + uni = unicode(obj.data, errors='ignore') + except: + uni = str(obj.data, errors='ignore') target.name = str( uni ) target.__class__.__repr__ = lambda x: str(x.__class__) + "(" + x.name + ")" target.__class__.__str__ = lambda x: x.name @@ -440,7 +443,10 @@ def _get_properties(properties, length): for p in [properties[i] for i in range(length)]: #the name p = p.contents - uni = unicode(p.mKey.data, errors='ignore') + try: + uni = unicode(p.mKey.data, errors='ignore') + except: + uni = str(p.mKey.data, errors='ignore') key = (str(uni).split('.')[1], p.mSemantic) #the data @@ -449,7 +455,10 @@ def _get_properties(properties, length): arr = cast(p.mData, POINTER(c_float * int(p.mDataLength/sizeof(c_float)) )).contents value = [x for x in arr] elif p.mType == 3: #string can't be an array - uni = unicode(cast(p.mData, POINTER(structs.MaterialPropertyString)).contents.data, errors='ignore') + try: + uni = unicode(cast(p.mData, POINTER(structs.MaterialPropertyString)).contents.data, errors='ignore') + except: + uni = str(cast(p.mData, POINTER(structs.MaterialPropertyString)).contents.data, errors='ignore') value = uni elif p.mType == 4: @@ -476,3 +485,4 @@ def decompose_matrix(matrix): from ctypes import byref, pointer _assimp_lib.dll.aiDecomposeMatrix(pointer(matrix), byref(scaling), byref(rotation), byref(position)) return scaling._init(), rotation._init(), position._init() + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b0be474d8..2d065e3be 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -57,6 +57,7 @@ SOURCE_GROUP( unit FILES ) SET( TEST_SRCS + unit/UTLogStream.h unit/AbstractImportExportBase.cpp unit/TestIOSystem.h unit/TestModelFactory.h @@ -129,6 +130,7 @@ SET( TEST_SRCS unit/utVector3.cpp unit/utXImporterExporter.cpp unit/utD3MFImportExport.cpp + unit/utProfiler.cpp ) SOURCE_GROUP( tests FILES ${TEST_SRCS} ) diff --git a/test/unit/UTLogStream.h b/test/unit/UTLogStream.h new file mode 100644 index 000000000..87ebea91d --- /dev/null +++ b/test/unit/UTLogStream.h @@ -0,0 +1,63 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2017, assimp team + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ +#pragma once + +#include + +class UTLogStream : public Assimp::LogStream { +public: + UTLogStream() + : LogStream() { + // empty + } + + virtual ~UTLogStream() { + // empty + } + + virtual void write(const char* message) { + if ( nullptr != message ) { + m_messages.push_back( std::string( message ) ); + } + } + + std::vector m_messages; +}; diff --git a/test/unit/UnitTestPCH.h b/test/unit/UnitTestPCH.h index 890bedd0c..0d5f08992 100644 --- a/test/unit/UnitTestPCH.h +++ b/test/unit/UnitTestPCH.h @@ -1,8 +1,44 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- +Copyright (c) 2006-2017, assimp team -// #ifndef ASSIMP_BUILD_SINGLETHREADED -// # include -// #endif +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ +#pragma once // We need to be sure to have the same STL settings as Assimp @@ -10,6 +46,7 @@ #include #include #include +#include "UTLogStream.h" #undef min #undef max diff --git a/test/unit/utProfiler.cpp b/test/unit/utProfiler.cpp new file mode 100644 index 000000000..ea71dd688 --- /dev/null +++ b/test/unit/utProfiler.cpp @@ -0,0 +1,76 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2017, assimp team + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ +#include "UnitTestPCH.h" +#include "UTLogStream.h" +#include "code/Profiler.h" +#include + +using namespace ::Assimp; +using namespace ::Assimp::Profiling; + +class utProfiler : public ::testing::Test { +public: + LogStream *m_stream; + + /*virtual void SetUp() { + m_stream = new UTLogStream; + DefaultLogger::create(); + DefaultLogger::get()->attachStream( m_stream ); + } + + virtual void TearDown() { + DefaultLogger::get()->detatchStream( m_stream ); + m_stream = nullptr; + }*/ +}; + +TEST_F( utProfiler, addRegion_success ) { + Profiler myProfiler; + myProfiler.BeginRegion( "t1" ); + for ( int i=0; i<10; i++ ) { + volatile int j=0; + j++; + } + myProfiler.EndRegion( "t1" ); + //UTLogStream *stream( (UTLogStream*) m_stream ); + //EXPECT_FALSE( stream->m_messages.empty() ); +}