SceneDiffer: add face tester.

pull/1015/head
Kim Kulling 2016-09-26 20:53:42 +02:00
parent 38b9ae2c6c
commit 3aa1bdfd12
2 changed files with 65 additions and 5 deletions

View File

@ -150,6 +150,19 @@ static std::string dumpColor4D( const aiColor4D &toDump ) {
return stream.str();
}
static std::string dumpFace( const aiFace &face ) {
std::stringstream stream;
for ( unsigned int i = 0; i < face.mNumIndices; i++ ) {
stream << face.mIndices[ i ];
if ( i < face.mNumIndices - 1 ) {
stream << ", ";
} else {
stream << "\n";
}
}
return stream.str();
}
bool SceneDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
if ( expected == toCompare ) {
return true;
@ -200,11 +213,11 @@ bool SceneDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
return false;
}
return true;
// return true;
//ToDo!
bool normalEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
/* for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expNormal( expected->mNormals[ i ] );
aiVector3D &toCompNormal( toCompare->mNormals[ i ] );
if ( expNormal.Equal( toCompNormal ) ) {
@ -289,7 +302,7 @@ bool SceneDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
}
if ( !tangentsEqual ) {
return false;
}
}*/
// faces
if ( expected->mNumFaces != toCompare->mNumFaces ) {
@ -301,8 +314,11 @@ bool SceneDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
bool facesEqual( true );
for ( unsigned int i = 0; i < expected->mNumFaces; i++ ) {
aiFace &expFace( expected->mFaces[ i ] );
aiFace &toCompareFace( expected->mFaces[ i ] );
aiFace &toCompareFace( toCompare->mFaces[ i ] );
if ( !compareFace( &expFace, &toCompareFace ) ) {
addDiff( "Faces are not equal\n" );
addDiff( dumpFace( expFace ) );
addDiff( dumpFace( toCompareFace ) );
facesEqual = false;
}
}

View File

@ -120,7 +120,51 @@ protected:
mesh->mNumVertices = 24;
mesh->mVertices = new aiVector3D[ 24 ];
::memcpy( &mesh->mVertices->x, &VertComponents[ 0 ], sizeof( float ) * 24 * 3 );
mesh->mNumFaces = 12;
mesh->mNumFaces = 6;
mesh->mFaces = new aiFace[ mesh->mNumFaces ];
mesh->mFaces[ 0 ].mNumIndices = 4;
mesh->mFaces[ 0 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 0 ].mIndices[ 0 ] = 0;
mesh->mFaces[ 0 ].mIndices[ 1 ] = 1;
mesh->mFaces[ 0 ].mIndices[ 2 ] = 2;
mesh->mFaces[ 0 ].mIndices[ 3 ] = 3;
mesh->mFaces[ 1 ].mNumIndices = 4;
mesh->mFaces[ 1 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 1 ].mIndices[ 0 ] = 4;
mesh->mFaces[ 1 ].mIndices[ 1 ] = 5;
mesh->mFaces[ 1 ].mIndices[ 2 ] = 6;
mesh->mFaces[ 1 ].mIndices[ 3 ] = 7;
mesh->mFaces[ 2 ].mNumIndices = 4;
mesh->mFaces[ 2 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 2 ].mIndices[ 0 ] = 8;
mesh->mFaces[ 2 ].mIndices[ 1 ] = 9;
mesh->mFaces[ 2 ].mIndices[ 2 ] = 10;
mesh->mFaces[ 2 ].mIndices[ 3 ] = 11;
mesh->mFaces[ 3 ].mNumIndices = 4;
mesh->mFaces[ 3 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 3 ].mIndices[ 0 ] = 12;
mesh->mFaces[ 3 ].mIndices[ 1 ] = 13;
mesh->mFaces[ 3 ].mIndices[ 2 ] = 14;
mesh->mFaces[ 3 ].mIndices[ 3 ] = 15;
mesh->mFaces[ 4 ].mNumIndices = 4;
mesh->mFaces[ 4 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 4 ].mIndices[ 0 ] = 16;
mesh->mFaces[ 4 ].mIndices[ 1 ] = 17;
mesh->mFaces[ 4 ].mIndices[ 2 ] = 18;
mesh->mFaces[ 4 ].mIndices[ 3 ] = 19;
mesh->mFaces[ 5 ].mNumIndices = 4;
mesh->mFaces[ 5 ].mIndices = new unsigned int[ mesh->mFaces[ 0 ].mNumIndices ];
mesh->mFaces[ 5 ].mIndices[ 0 ] = 20;
mesh->mFaces[ 5 ].mIndices[ 1 ] = 21;
mesh->mFaces[ 5 ].mIndices[ 2 ] = 22;
mesh->mFaces[ 5 ].mIndices[ 3 ] = 23;
expScene->mMeshes[ 0 ] = mesh;
expScene->mNumMaterials = 1;