From ecf390d51f2cdadd1c8ff2b03bf9481866a733e6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 6 Apr 2015 14:56:12 +0200 Subject: [PATCH 01/10] set the correct reference to meshes. Signed-off-by: Kim Kulling --- code/OpenGEXImporter.cpp | 17 ++++++++++++++--- code/OpenGEXImporter.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index a9e8c3e39..2b8fd207f 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; @@ -536,7 +538,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 +551,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; + } } //------------------------------------------------------------------------------------------------ @@ -745,8 +752,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! diff --git a/code/OpenGEXImporter.h b/code/OpenGEXImporter.h index a9cdde1db..f1b608a4b 100644 --- a/code/OpenGEXImporter.h +++ b/code/OpenGEXImporter.h @@ -157,6 +157,7 @@ private: }; std::vector m_meshCache; + typedef std::map ReferenceMap; std::map m_mesh2refMap; ODDLParser::Context *m_ctx; From fb7661c43033fa2c7eb19c5461ee2dcc2878ed3f Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Tue, 7 Apr 2015 08:20:27 +0200 Subject: [PATCH 02/10] add static flag for exe build if no shared build is requested --- .travis.yml | 10 +++++----- CMakeLists.txt | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae3a0b983..0630cc268 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 @@ -38,7 +38,7 @@ script: 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..226ab911f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required( VERSION 2.8 ) PROJECT( Assimp ) +if(NOT BUILD_SHARED_LIBS) + set(CMAKE_EXE_LINKER_FLAGS "-static") +endif(NOT BUILD_SHARED_LIBS) + # Define here the needed parameters set (ASSIMP_VERSION_MAJOR 3) set (ASSIMP_VERSION_MINOR 1) From 297e1d21171d0e7c3a87c0d036a4a40589c8f3fa Mon Sep 17 00:00:00 2001 From: arris69 Date: Tue, 7 Apr 2015 16:07:29 +0200 Subject: [PATCH 03/10] it's a difference if it's set to OFF or it's undefined... --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 226ab911f..011f66864 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required( VERSION 2.8 ) PROJECT( Assimp ) +option(BUILD_SHARED_LIBS "Build package with shared libraries." OFF) if(NOT BUILD_SHARED_LIBS) set(CMAKE_EXE_LINKER_FLAGS "-static") endif(NOT BUILD_SHARED_LIBS) From 7a6c00ca11e2766331e210a09b54b71b2fbc5e31 Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Wed, 8 Apr 2015 12:34:54 +0200 Subject: [PATCH 04/10] looks like cmake is per design not for building static executables, clang too. =%-| --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 011f66864..aa4d35124 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,8 @@ PROJECT( Assimp ) option(BUILD_SHARED_LIBS "Build package with shared libraries." OFF) if(NOT BUILD_SHARED_LIBS) - set(CMAKE_EXE_LINKER_FLAGS "-static") + #set(CMAKE_EXE_LINKER_FLAGS "-static") + set(LINK_SEARCH_START_STATIC 1) endif(NOT BUILD_SHARED_LIBS) # Define here the needed parameters From ed57fac879a980fb6c71ceffd57b59d7b61d88ff Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 8 Apr 2015 20:43:55 +0200 Subject: [PATCH 05/10] create node tree Signed-off-by: Kim Kulling --- code/OpenGEXImporter.cpp | 53 ++++++++++++++++++++++++++++++++++------ code/OpenGEXImporter.h | 9 +++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 2b8fd207f..8454ae1f2 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -211,6 +211,8 @@ OpenGEXImporter::RefInfo::~RefInfo() { //------------------------------------------------------------------------------------------------ OpenGEXImporter::OpenGEXImporter() : m_meshCache() +, m_root( NULL ) +, m_nodeChildMap() , m_mesh2refMap() , m_ctx( NULL ) , m_currentNode( NULL ) @@ -261,6 +263,7 @@ void OpenGEXImporter::InternReadFile( const std::string &filename, aiScene *pSce copyMeshes( pScene ); resolveReferences(); + createNodeTree( pScene ); } //------------------------------------------------------------------------------------------------ @@ -724,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() ) { @@ -756,7 +769,7 @@ void OpenGEXImporter::resolveReferences() { if( m_mesh2refMap.end() != it ) { unsigned int meshIdx = m_mesh2refMap[ name ]; node->mMeshes[ i ] = meshIdx; - node->mNumMeshes++; + //node->mNumMeshes++; } } } else if( RefInfo::MaterialRef == currentRefInfo->m_type ) { @@ -769,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++; + } } //------------------------------------------------------------------------------------------------ @@ -783,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 f1b608a4b..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,6 +157,14 @@ 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; From cdeb95611d03495b5b2f59958009904543df01cd Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Sun, 12 Apr 2015 18:16:49 +0200 Subject: [PATCH 06/10] double definition, should better open my eyes... --- CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4d35124..b31f2c7f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required( VERSION 2.8 ) PROJECT( Assimp ) -option(BUILD_SHARED_LIBS "Build package with shared libraries." OFF) +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 1) + set(LINK_SEARCH_START_STATIC TRUE) endif(NOT BUILD_SHARED_LIBS) # Define here the needed parameters @@ -94,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 From 2f372c0ac5ad93e128087b565ce3d7d6b3832e9c Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Sun, 12 Apr 2015 19:05:27 +0200 Subject: [PATCH 07/10] add the mingw compile step --- .travis.yml | 4 ++++ cmake-modules/MinGW_x86_64.cmake | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 cmake-modules/MinGW_x86_64.cmake diff --git a/.travis.yml b/.travis.yml index 0630cc268..eb89ddf92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,10 @@ install: script: - if [ $ANDROID ]; then ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni ; + elif [ $WINDOWS ]; then + 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 [ $RESERVED ]; then echo "Reserved condition" ; else 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) From 20e23fbd0a8f62383e904ee2ac037e56fd31f025 Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Sun, 12 Apr 2015 19:10:10 +0200 Subject: [PATCH 08/10] i see no reason to check it with clang too. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eb89ddf92..2480c4633 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,10 +35,12 @@ install: script: - if [ $ANDROID ]; then ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni ; - elif [ $WINDOWS ]; then + elif [ $WINDOWS -a $CC = "gcc" ]; then 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 From 5f58188de51bb8d17a25fd3f2e275866d36b13c8 Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Sun, 12 Apr 2015 19:12:48 +0200 Subject: [PATCH 09/10] mingwin headers are a bit 'outdated' --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2480c4633..20b7a058a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,8 @@ 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 ; From e2f234707a18cb72530970288ef570a7dafcccac Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sun, 12 Apr 2015 19:53:24 +0200 Subject: [PATCH 10/10] Fix possible crash in SceneCombiner when the destinations scene has mPrivate==null. Fixes #401. --- code/SceneCombiner.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; + } } // ------------------------------------------------------------------------------------------------