Bug/evaluate matrix4x4 access (#5936)
* Add test for 3x3 matrices and 4x4 matrix access
This commit is contained in:
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -42,6 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "UnitTestPCH.h"
|
||||
#include "MathTest.h"
|
||||
#include <array>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
@@ -158,3 +157,18 @@ TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromToTest) {
|
||||
aiMatrix3FromTo(&result_c, &from, &to);
|
||||
EXPECT_EQ(result_cpp, result_c);
|
||||
}
|
||||
|
||||
TEST_F(AssimpAPITest_aiMatrix3x3, operatorTest) {
|
||||
std::array<ai_real, 9> value = { 1, 2, 3, 4, 5, 6, 7, 8,9};
|
||||
result_cpp = aiMatrix3x3( value[0], value[1], value[2], value[3],
|
||||
value[4], value[5], value[6], value[7],
|
||||
value[8]);
|
||||
size_t idx=0;
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
for (unsigned int j = 0; j < 3; ++j) {
|
||||
ai_real curValue = result_cpp[i][j];
|
||||
EXPECT_EQ(curValue, value[idx]);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "UnitTestPCH.h"
|
||||
#include "MathTest.h"
|
||||
#include <assimp/MathFunctions.h>
|
||||
#include <array>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
@@ -262,3 +263,20 @@ TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromToTest) {
|
||||
aiMatrix4FromTo(&result_c, &from, &to);
|
||||
EXPECT_EQ(result_cpp, result_c);
|
||||
}
|
||||
|
||||
TEST_F(AssimpAPITest_aiMatrix4x4, operatorTest) {
|
||||
std::array<ai_real, 16> value = { 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
result_cpp = aiMatrix4x4( value[0], value[1], value[2], value[3],
|
||||
value[4], value[5], value[6], value[7],
|
||||
value[8], value[9], value[10], value[11],
|
||||
value[12], value[13], value[14], value[15] );
|
||||
size_t idx=0;
|
||||
for (unsigned int i = 0; i < 4; ++i) {
|
||||
for (unsigned int j = 0; j < 4; ++j) {
|
||||
ai_real curValue = result_cpp[i][j];
|
||||
EXPECT_EQ(curValue, value[idx]);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -49,18 +47,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
class TestModelFacttory {
|
||||
class TestModelFactory {
|
||||
public:
|
||||
TestModelFacttory() {
|
||||
// empty
|
||||
}
|
||||
TestModelFactory() = default;
|
||||
|
||||
~TestModelFacttory() {
|
||||
// empty
|
||||
}
|
||||
~TestModelFactory() = default;
|
||||
|
||||
static aiScene *createDefaultTestModel( float &opacity ) {
|
||||
aiScene *scene( new aiScene );
|
||||
auto *scene = new aiScene;
|
||||
scene->mNumMaterials = 1;
|
||||
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
|
||||
scene->mMaterials[ 0 ] = new aiMaterial;
|
||||
@@ -89,7 +83,7 @@ public:
|
||||
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 1 ] = 1;
|
||||
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 2 ] = 2;
|
||||
|
||||
scene->mRootNode = new aiNode();
|
||||
scene->mRootNode = new aiNode;
|
||||
scene->mRootNode->mNumMeshes = 1;
|
||||
scene->mRootNode->mMeshes = new unsigned int[1]{ 0 };
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_F(utColladaExport, testExportCamera) {
|
||||
|
||||
EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file));
|
||||
const unsigned int origNumCams(pTest->mNumCameras);
|
||||
//std::vector<float> origFOV;
|
||||
|
||||
std::unique_ptr<float[]> origFOV(new float[origNumCams]);
|
||||
std::unique_ptr<float[]> orifClipPlaneNear(new float[origNumCams]);
|
||||
std::unique_ptr<float[]> orifClipPlaneFar(new float[origNumCams]);
|
||||
|
||||
@@ -55,7 +55,7 @@ class utIssues : public ::testing::Test {};
|
||||
|
||||
TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
|
||||
float opacity;
|
||||
aiScene *scene = TestModelFacttory::createDefaultTestModel(opacity);
|
||||
aiScene *scene = TestModelFactory::createDefaultTestModel(opacity);
|
||||
Assimp::Importer importer;
|
||||
Assimp::Exporter exporter;
|
||||
|
||||
@@ -69,11 +69,12 @@ TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
|
||||
const aiScene *newScene( importer.ReadFile( path, aiProcess_ValidateDataStructure ) );
|
||||
ASSERT_NE( nullptr, newScene );
|
||||
float newOpacity;
|
||||
if ( newScene->mNumMaterials > 0 ) {
|
||||
if (newScene->mNumMaterials > 0 ) {
|
||||
EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) );
|
||||
EXPECT_FLOAT_EQ( opacity, newOpacity );
|
||||
}
|
||||
delete scene;
|
||||
|
||||
TestModelFactory::releaseDefaultTestModel(&scene);
|
||||
|
||||
// Cleanup. Delete exported dae.dae file
|
||||
EXPECT_EQ(0, std::remove(path.c_str()));
|
||||
|
||||
Reference in New Issue
Block a user