ModelDiffer: use Equal-method to compare vectors.

pull/1005/head
Kim Kulling 2016-09-20 19:48:03 +02:00
parent 2e943e5443
commit ce2532e93b
3 changed files with 7 additions and 10 deletions

View File

@ -98,7 +98,6 @@ public:
operator aiVector3t<TOther> () const; operator aiVector3t<TOther> () const;
public: public:
/** @brief Set the components of a vector /** @brief Set the components of a vector
* @param pX X component * @param pX X component
* @param pY Y component * @param pY Y component
@ -109,7 +108,6 @@ public:
* @return Square length */ * @return Square length */
TReal SquareLength() const; TReal SquareLength() const;
/** @brief Get the length of the vector /** @brief Get the length of the vector
* @return length */ * @return length */
TReal Length() const; TReal Length() const;

View File

@ -54,7 +54,7 @@ ModelDiffer::~ModelDiffer() {
// empty // empty
} }
bool ModelDiffer::isEqual( aiScene *expected, aiScene *toCompare ) { bool ModelDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
if ( expected == toCompare ) { if ( expected == toCompare ) {
return true; return true;
} }
@ -172,7 +172,7 @@ bool ModelDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expVert( expected->mVertices[ i ] ); aiVector3D &expVert( expected->mVertices[ i ] );
aiVector3D &toCompVert( toCompare->mVertices[ i ] ); aiVector3D &toCompVert( toCompare->mVertices[ i ] );
if ( expVert != toCompVert ) { if ( expVert.Equal( toCompVert ) ) {
std::stringstream stream; std::stringstream stream;
stream << "Vertex not equal ( expected: " << dumpVector3( expVert ) << ", found: " << dumpVector3( toCompVert ) << "\n"; stream << "Vertex not equal ( expected: " << dumpVector3( expVert ) << ", found: " << dumpVector3( toCompVert ) << "\n";
addDiff( stream.str() ); addDiff( stream.str() );
@ -193,7 +193,7 @@ bool ModelDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expNormal( expected->mNormals[ i ] ); aiVector3D &expNormal( expected->mNormals[ i ] );
aiVector3D &toCompNormal( toCompare->mNormals[ i ] ); aiVector3D &toCompNormal( toCompare->mNormals[ i ] );
if ( expNormal != toCompNormal ) { if ( expNormal.Equal( toCompNormal ) ) {
std::stringstream stream; std::stringstream stream;
stream << "Normal not equal ( expected: " << dumpVector3( expNormal ) << ", found: " << dumpVector3( toCompNormal ) << "\n"; stream << "Normal not equal ( expected: " << dumpVector3( expNormal ) << ", found: " << dumpVector3( toCompNormal ) << "\n";
addDiff( stream.str() ); addDiff( stream.str() );
@ -236,7 +236,7 @@ bool ModelDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expTexCoord( expected->mTextureCoords[ a ][ i ] ); aiVector3D &expTexCoord( expected->mTextureCoords[ a ][ i ] );
aiVector3D &toCompTexCoord( toCompare->mTextureCoords[ a ][ i ] ); aiVector3D &toCompTexCoord( toCompare->mTextureCoords[ a ][ i ] );
if ( expTexCoord != toCompTexCoord ) { if ( expTexCoord.Equal( toCompTexCoord ) ) {
std::stringstream stream; std::stringstream stream;
stream << "Texture coords not equal ( expected: " << dumpVector3( expTexCoord ) << ", found: " << dumpVector3( toCompTexCoord ) << "\n"; stream << "Texture coords not equal ( expected: " << dumpVector3( expTexCoord ) << ", found: " << dumpVector3( toCompTexCoord ) << "\n";
addDiff( stream.str() ); addDiff( stream.str() );
@ -257,7 +257,7 @@ bool ModelDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) { for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expTangents( expected->mTangents[ i ] ); aiVector3D &expTangents( expected->mTangents[ i ] );
aiVector3D &toCompTangents( toCompare->mTangents[ i ] ); aiVector3D &toCompTangents( toCompare->mTangents[ i ] );
if ( expTangents != toCompTangents ) { if ( expTangents.Equal( toCompTangents ) ) {
std::stringstream stream; std::stringstream stream;
stream << "Tangents not equal ( expected: " << dumpVector3( expTangents ) << ", found: " << dumpVector3( toCompTangents ) << "\n"; stream << "Tangents not equal ( expected: " << dumpVector3( expTangents ) << ", found: " << dumpVector3( toCompTangents ) << "\n";
addDiff( stream.str() ); addDiff( stream.str() );
@ -266,7 +266,7 @@ bool ModelDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
aiVector3D &expBiTangents( expected->mBitangents[ i ] ); aiVector3D &expBiTangents( expected->mBitangents[ i ] );
aiVector3D &toCompBiTangents( toCompare->mBitangents[ i ] ); aiVector3D &toCompBiTangents( toCompare->mBitangents[ i ] );
if ( expBiTangents != toCompBiTangents ) { if ( expBiTangents.Equal( toCompBiTangents ) ) {
std::stringstream stream; std::stringstream stream;
stream << "Tangents not equal ( expected: " << dumpVector3( expBiTangents ) << ", found: " << dumpVector3( toCompBiTangents ) << " )\n"; stream << "Tangents not equal ( expected: " << dumpVector3( expBiTangents ) << ", found: " << dumpVector3( toCompBiTangents ) << " )\n";
addDiff( stream.str() ); addDiff( stream.str() );
@ -336,5 +336,4 @@ bool ModelDiffer::compareMaterial( aiMaterial *expected, aiMaterial *toCompare )
// todo! // todo!
return true; return true;
} }

View File

@ -54,7 +54,7 @@ class ModelDiffer {
public: public:
ModelDiffer(); ModelDiffer();
~ModelDiffer(); ~ModelDiffer();
bool isEqual( aiScene *expected, aiScene *toCompare ); bool isEqual( const aiScene *expected, const aiScene *toCompare );
void showReport(); void showReport();
void reset(); void reset();