diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index 8b669180c..c65ea81bc 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -585,7 +585,7 @@ template <> inline void Structure :: Convert (int& dest,const FileDataba } // ------------------------------------------------------------------------------------------------ -template <> inline void Structure :: Convert (short& dest,const FileDatabase& db) const +template<> inline void Structure :: Convert (short& dest,const FileDatabase& db) const { // automatic rescaling from short to float and vice versa (seems to be used by normals) if (name == "float") { diff --git a/code/RemoveVCProcess.h b/code/RemoveVCProcess.h index 5735bf419..d7d45e73e 100644 --- a/code/RemoveVCProcess.h +++ b/code/RemoveVCProcess.h @@ -54,8 +54,7 @@ namespace Assimp { /** RemoveVCProcess: Class to exclude specific parts of the data structure * from further processing by removing them, */ -class ASSIMP_API RemoveVCProcess : public BaseProcess -{ +class ASSIMP_API RemoveVCProcess : public BaseProcess { public: /// The default class constructor. RemoveVCProcess(); @@ -63,7 +62,6 @@ public: /// The class destructor. ~RemoveVCProcess(); -public: // ------------------------------------------------------------------- /** Returns whether the processing step is present in the given flag field. * @param pFlags The processing flags the importer was called with. A bitwise diff --git a/code/ScaleProcess.cpp b/code/ScaleProcess.cpp index 4c786d7d1..a0158d220 100644 --- a/code/ScaleProcess.cpp +++ b/code/ScaleProcess.cpp @@ -80,10 +80,15 @@ void ScaleProcess::Execute( aiScene* pScene ) { return; } - for ( unsigned int i = 0; i < pScene->mRootNode->mNumChildren; ++i ) { - aiNode *currentNode = pScene->mRootNode->mChildren[ i ]; + traverseNodes( pScene->mRootNode ); +} + +void ScaleProcess::traverseNodes( aiNode *node ) { + applyScaling( node ); + for ( unsigned int i = 0; i < node->mNumChildren; ++i ) { + aiNode *currentNode = currentNode->mChildren[ i ]; if ( nullptr != currentNode ) { - applyScaling( currentNode ); + traverseNodes( currentNode ); } } } diff --git a/code/ScaleProcess.h b/code/ScaleProcess.h index 6a99c97fe..7eb91fd5c 100644 --- a/code/ScaleProcess.h +++ b/code/ScaleProcess.h @@ -50,17 +50,34 @@ struct aiNode; namespace Assimp { -class ScaleProcess : public BaseProcess { +// --------------------------------------------------------------------------- +/** ScaleProcess: Class to rescale the whole model. +*/ +class ASSIMP_API ScaleProcess : public BaseProcess { public: + /// The default class constructor. ScaleProcess(); + + /// The class destructor. virtual ~ScaleProcess(); + + /// Will set the scale manually. void setScale( ai_real scale ); + + /// Returns the current scaling value. ai_real getScale() const; + + /// Overwritten, @see BaseProcess virtual bool IsActive( unsigned int pFlags ) const; + + /// Overwritten, @see BaseProcess virtual void SetupProperties( const Importer* pImp ); + + /// Overwritten, @see BaseProcess virtual void Execute( aiScene* pScene ); private: + void traverseNodes( aiNode *currentNode ); void applyScaling( aiNode *currentNode ); private: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3520f9782..62270b935 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -114,8 +114,6 @@ SET( TEST_SRCS unit/utPMXImporter.cpp unit/utRemoveComments.cpp unit/utRemoveComponent.cpp - unit/utRemoveRedundantMaterials.cpp - unit/utRemoveVCProcess.cpp unit/utScenePreprocessor.cpp unit/utSceneCombiner.cpp unit/utSharedPPData.cpp @@ -135,8 +133,15 @@ SET( TEST_SRCS unit/utQ3DImportExport.cpp unit/utProfiler.cpp ) +SET( POST_PROCESSES + unit/utRemoveRedundantMaterials.cpp + unit/utRemoveVCProcess.cpp + unit/utScaleProcess.cpp + unit/utJoinVertices.cpp +) -SOURCE_GROUP( tests FILES ${TEST_SRCS} ) +SOURCE_GROUP( tests FILES ${TEST_SRCS} ) +SOURCE_GROUP( tests/PostProcess FILES ${POST_PROCESSES}) add_executable( unit ../contrib/gtest/src/gtest-all.cc @@ -144,6 +149,7 @@ add_executable( unit unit/Main.cpp ../code/Version.cpp ${TEST_SRCS} + ${POST_PROCESSES} ) add_definitions(-DASSIMP_TEST_MODELS_DIR="${CMAKE_CURRENT_LIST_DIR}/models") diff --git a/test/unit/TestModelFactory.h b/test/unit/TestModelFactory.h index ca070890d..950374112 100644 --- a/test/unit/TestModelFactory.h +++ b/test/unit/TestModelFactory.h @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "UnitTestPCH.h" #include +#include #include namespace Assimp { @@ -57,7 +58,7 @@ public: // empty } - static aiScene *createDefaultTestModel( float &opacity ) { + static aiScene *createDefaultTestModel( float &opacity ) { aiScene *scene( new aiScene ); scene->mNumMaterials = 1; scene->mMaterials = new aiMaterial*[scene->mNumMaterials]; @@ -93,6 +94,11 @@ public: return scene; } + + static void releaseDefaultTestModel( aiScene **scene ) { + delete *scene; + *scene = nullptr; + } }; }