diff --git a/.travis.yml b/.travis.yml index ae3a0b983..20b7a058a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,12 @@ env: matrix: - LINUX=1 TRAVIS_NO_EXPORT=YES - LINUX=1 TRAVIS_NO_EXPORT=NO - - LINUX=1 TRAVIS_STATIC_BUILD=ON - - LINUX=1 TRAVIS_STATIC_BUILD=OFF + - LINUX=1 SHARED_BUILD=ON + - LINUX=1 SHARED_BUILD=OFF - WINDOWS=1 TRAVIS_NO_EXPORT=YES - WINDOWS=1 TRAVIS_NO_EXPORT=NO - - WINDOWS=1 TRAVIS_STATIC_BUILD=ON - - WINDOWS=1 TRAVIS_STATIC_BUILD=OFF + - WINDOWS=1 SHARED_BUILD=ON + - WINDOWS=1 SHARED_BUILD=OFF - ANDROID=1 language: cpp @@ -35,10 +35,18 @@ install: script: - if [ $ANDROID ]; then ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni ; + elif [ $WINDOWS -a $CC = "gcc" ]; then + sudo sh -c "wget http://source.winehq.org/git/wine.git/commitdiff_plain/86781a6a524fa336f893ffd0a87373ffd306913c?hp=076edfe9d4b6cd39b6cf41b9f1d3e18688cc8673 -O - | patch -p 1 -d /usr/x86_64-w64-mingw32" ; + sudo sh -c "wget https://www.winehq.org/pipermail/wine-patches/2012-February/111438.html -O - | patch -p 1 -d /usr/x86_64-w64-mingw32" ; + cmake -G "Unix Makefiles" -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD -DCMAKE_TOOLCHAIN_FILE=cmake-modules/MinGW_x86_64.cmake ; + cmake --build . ; + make install ; + elif [ $WINDOWS ]; then + echo "Skip compile with non-gcc setting." ; elif [ $RESERVED ]; then echo "Reserved condition" ; else - cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -STATIC_BUILD=$TRAVIS_STATIC_BUILD ; + cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD ; make ; sudo make install ; sudo ldconfig ; diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a3a325be..b31f2c7f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,12 @@ cmake_minimum_required( VERSION 2.8 ) PROJECT( Assimp ) +option(BUILD_SHARED_LIBS "Build package with shared libraries." ON) +if(NOT BUILD_SHARED_LIBS) + #set(CMAKE_EXE_LINKER_FLAGS "-static") + set(LINK_SEARCH_START_STATIC TRUE) +endif(NOT BUILD_SHARED_LIBS) + # Define here the needed parameters set (ASSIMP_VERSION_MAJOR 3) set (ASSIMP_VERSION_MINOR 1) @@ -88,9 +94,6 @@ SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools") -# Allow the user to build a shared or static library -option ( BUILD_SHARED_LIBS "Build a shared version of the library" ON ) - # Only generate this target if no higher-level project already has IF (NOT TARGET uninstall) # add make uninstall capability diff --git a/cmake-modules/MinGW_x86_64.cmake b/cmake-modules/MinGW_x86_64.cmake new file mode 100644 index 000000000..d5c1f1501 --- /dev/null +++ b/cmake-modules/MinGW_x86_64.cmake @@ -0,0 +1,16 @@ +# this one sets internal to crosscompile (in theory) +SET(CMAKE_SYSTEM_NAME Windows) + +# the minimalistic settings +SET(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc") +SET(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++") +SET(CMAKE_RC_COMPILER "/usr/bin/x86_64-w64-mingw32-windres") + +# where is the target (so called staging) environment +SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +# search for programs in the build host directories (default BOTH) +#SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index a9e8c3e39..8454ae1f2 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -175,6 +175,7 @@ namespace OpenGEX { USE_ODDLPARSER_NS +//------------------------------------------------------------------------------------------------ OpenGEXImporter::VertexContainer::VertexContainer() : m_numVerts( 0 ) , m_vertices() @@ -185,6 +186,7 @@ OpenGEXImporter::VertexContainer::VertexContainer() // empty } +//------------------------------------------------------------------------------------------------ OpenGEXImporter::VertexContainer::~VertexContainer() { delete[] m_vertices; delete[] m_normals; @@ -209,6 +211,8 @@ OpenGEXImporter::RefInfo::~RefInfo() { //------------------------------------------------------------------------------------------------ OpenGEXImporter::OpenGEXImporter() : m_meshCache() +, m_root( NULL ) +, m_nodeChildMap() , m_mesh2refMap() , m_ctx( NULL ) , m_currentNode( NULL ) @@ -259,6 +263,7 @@ void OpenGEXImporter::InternReadFile( const std::string &filename, aiScene *pSce copyMeshes( pScene ); resolveReferences(); + createNodeTree( pScene ); } //------------------------------------------------------------------------------------------------ @@ -536,7 +541,6 @@ void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene m_currentMesh = new aiMesh; const size_t meshidx( m_meshCache.size() ); m_meshCache.push_back( m_currentMesh ); - m_mesh2refMap[ node->getName() ] = meshidx; Property *prop = node->getProperties(); if( NULL != prop ) { @@ -550,6 +554,12 @@ void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene } handleNodes( node, pScene ); + + DDLNode *parent( node->getParent() ); + if( NULL != parent ) { + const std::string &name = parent->getName(); + m_mesh2refMap[ name ] = meshidx; + } } //------------------------------------------------------------------------------------------------ @@ -717,6 +727,16 @@ void OpenGEXImporter::handleMaterialNode( ODDLParser::DDLNode *node, aiScene *pS } +//------------------------------------------------------------------------------------------------ +void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScene ) { + +} + +//------------------------------------------------------------------------------------------------ +void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pScene ) { + +} + //------------------------------------------------------------------------------------------------ void OpenGEXImporter::copyMeshes( aiScene *pScene ) { if( m_meshCache.empty() ) { @@ -745,8 +765,12 @@ void OpenGEXImporter::resolveReferences() { if( RefInfo::MeshRef == currentRefInfo->m_type ) { for( size_t i = 0; i < currentRefInfo->m_Names.size(); i++ ) { const std::string &name(currentRefInfo->m_Names[ i ] ); - unsigned int meshIdx = m_mesh2refMap[ name ]; - node->mMeshes[ i ] = meshIdx; + ReferenceMap::const_iterator it( m_mesh2refMap.find( name ) ); + if( m_mesh2refMap.end() != it ) { + unsigned int meshIdx = m_mesh2refMap[ name ]; + node->mMeshes[ i ] = meshIdx; + //node->mNumMeshes++; + } } } else if( RefInfo::MaterialRef == currentRefInfo->m_type ) { // ToDo! @@ -758,13 +782,21 @@ void OpenGEXImporter::resolveReferences() { } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScene ) { - -} - -//------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::createNodeTree( aiScene *pScene ) { + if( NULL == m_root ) { + return; + } + if( m_root->m_children.empty() ) { + return; + } + size_t i( 0 ); + pScene->mRootNode->mNumChildren = m_root->m_children.size(); + pScene->mRootNode->mChildren = new C_STRUCT aiNode*[ pScene->mRootNode->mNumChildren ]; + for( ChildInfo::NodeList::iterator it = m_root->m_children.begin(); it != m_root->m_children.end(); it++ ) { + pScene->mRootNode->mChildren[ i ] = *it; + i++; + } } //------------------------------------------------------------------------------------------------ @@ -772,12 +804,30 @@ void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) { ai_assert( NULL != pScene ); if( NULL != node ) { + ChildInfo *info( NULL ); if( m_nodeStack.empty() ) { node->mParent = pScene->mRootNode; + NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) ); + if( m_nodeChildMap.end() == it ) { + info = new ChildInfo; + m_root = info; + m_nodeChildMap[ node->mParent ] = info; + } else { + info = it->second; + } + info->m_children.push_back( node ); } else { aiNode *parent( m_nodeStack.back() ); ai_assert( NULL != parent ); node->mParent = parent; + NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) ); + if( m_nodeChildMap.end() == it ) { + info = new ChildInfo; + m_nodeChildMap[ node->mParent ] = info; + } else { + info = it->second; + } + info->m_children.push_back( node ); } m_nodeStack.push_back( node ); } diff --git a/code/OpenGEXImporter.h b/code/OpenGEXImporter.h index a9cdde1db..f5c328ff7 100644 --- a/code/OpenGEXImporter.h +++ b/code/OpenGEXImporter.h @@ -120,6 +120,7 @@ protected: aiNode *popNode(); aiNode *top() const; void clearNodeStack(); + void createNodeTree( aiScene *pScene ); private: struct VertexContainer { @@ -156,7 +157,16 @@ private: RefInfo &operator = ( const RefInfo & ); }; + struct ChildInfo { + typedef std::list NodeList; + std::list m_children; + }; + ChildInfo *m_root; + typedef std::map NodeChildMap; + NodeChildMap m_nodeChildMap; + std::vector m_meshCache; + typedef std::map ReferenceMap; std::map m_mesh2refMap; ODDLParser::Context *m_ctx; diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index f9face9b1..26ed94712 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -1023,7 +1023,9 @@ void SceneCombiner::CopyScene(aiScene** _dest,const aiScene* src,bool allocate) dest->mFlags = src->mFlags; // source private data might be NULL if the scene is user-allocated (i.e. for use with the export API) - ScenePriv(dest)->mPPStepsApplied = ScenePriv(src) ? ScenePriv(src)->mPPStepsApplied : 0; + if (dest->mPrivate != NULL) { + ScenePriv(dest)->mPPStepsApplied = ScenePriv(src) ? ScenePriv(src)->mPPStepsApplied : 0; + } } // ------------------------------------------------------------------------------------------------