Add unittest
parent
bbeb9dd640
commit
ae020281e2
|
@ -585,7 +585,7 @@ template <> inline void Structure :: Convert<int> (int& dest,const FileDataba
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> inline void Structure :: Convert<short> (short& dest,const FileDatabase& db) const
|
||||
template<> inline void Structure :: Convert<short> (short& dest,const FileDatabase& db) const
|
||||
{
|
||||
// automatic rescaling from short to float and vice versa (seems to be used by normals)
|
||||
if (name == "float") {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "UnitTestPCH.h"
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/material.h>
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue