[Bf-blender-cvs] [c2fb85282d9] master: OBJ: extend importer tests to test imported material expectations
Aras Pranckevicius
noreply at git.blender.org
Sun Oct 9 19:52:30 CEST 2022
Commit: c2fb85282d94eb7231b54b2b9d6bbd33f32c7a2a
Author: Aras Pranckevicius
Date: Sun Oct 9 20:52:23 2022 +0300
Branches: master
https://developer.blender.org/rBc2fb85282d94eb7231b54b2b9d6bbd33f32c7a2a
OBJ: extend importer tests to test imported material expectations
Previously "which material got assigned to an object in the end"
was not covered by tests. This is preparation for fixing T101685.
===================================================================
M source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
===================================================================
diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
index 8d1171097b8..1657bf81dc7 100644
--- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
@@ -8,6 +8,7 @@
#include "BKE_curve.h"
#include "BKE_customdata.h"
#include "BKE_main.h"
+#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_scene.h"
@@ -22,6 +23,7 @@
#include "DEG_depsgraph_query.h"
#include "DNA_curve_types.h"
+#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
@@ -41,6 +43,7 @@ struct Expectation {
float3 normal_first;
float2 uv_first;
float4 color_first = {-1, -1, -1, -1};
+ std::string first_mat;
};
class obj_importer_test : public BlendfileLoadingBaseTest {
@@ -132,6 +135,10 @@ class obj_importer_test : public BlendfileLoadingBaseTest {
// int cyclic = (nurb->flagu & CU_NURB_CYCLIC) ? 1 : 0;
// EXPECT_EQ(cyclic, exp.mesh_totloop_or_curve_cyclic);
}
+ if (!exp.first_mat.empty()) {
+ Material *mat = BKE_object_material_get(object, 1);
+ ASSERT_STREQ(mat ? mat->id.name : "<null>", exp.first_mat.c_str());
+ }
++object_index;
}
DEG_OBJECT_ITER_END;
@@ -309,7 +316,42 @@ TEST_F(obj_importer_test, import_materials)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBmaterials", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)},
+ {"OBmaterials",
+ OB_MESH,
+ 8,
+ 12,
+ 6,
+ 24,
+ float3(-1, -1, 1),
+ float3(1, -1, -1),
+ float3(0),
+ float2(0),
+ float4(-1),
+ "MAno_textures_red"},
+ {"OBObjMtlAfter",
+ OB_MESH,
+ 3,
+ 3,
+ 1,
+ 3,
+ float3(3, 0, 0),
+ float3(5, 0, 0),
+ float3(0),
+ float2(0),
+ float4(-1),
+ "MAno_textures_red"},
+ {"OBObjMtlBefore",
+ OB_MESH,
+ 3,
+ 3,
+ 1,
+ 3,
+ float3(6, 0, 0),
+ float3(8, 0, 0),
+ float3(0),
+ float2(0),
+ float4(-1),
+ "MAClay"},
};
import_and_check("materials.obj", expect, std::size(expect), 4, 8);
}
@@ -327,7 +369,9 @@ TEST_F(obj_importer_test, import_cubes_with_textures_rel)
float3(1, 1, -1),
float3(-1, -1, 1),
float3(0, 1, 0),
- float2(0.9935f, 0.0020f)},
+ float2(0.9935f, 0.0020f),
+ float4(-1),
+ "MAMat_BaseRoughEmissNormal10"},
{"OBCubeTexMul",
OB_MESH,
8,
@@ -337,7 +381,9 @@ TEST_F(obj_importer_test, import_cubes_with_textures_rel)
float3(4, -2, -1),
float3(2, -4, 1),
float3(0, 1, 0),
- float2(0.9935f, 0.0020f)},
+ float2(0.9935f, 0.0020f),
+ float4(-1),
+ "MAMat_BaseMul"},
{"OBCubeTiledTex",
OB_MESH,
8,
@@ -347,7 +393,9 @@ TEST_F(obj_importer_test, import_cubes_with_textures_rel)
float3(4, 1, -1),
float3(2, -1, 1),
float3(0, 1, 0),
- float2(0.9935f, 0.0020f)},
+ float2(0.9935f, 0.0020f),
+ float4(-1),
+ "MAMat_BaseTiled"},
{"OBCubeTiledTexFromAnotherFolder",
OB_MESH,
8,
@@ -357,7 +405,9 @@ TEST_F(obj_importer_test, import_cubes_with_textures_rel)
float3(7, 1, -1),
float3(5, -1, 1),
float3(0, 1, 0),
- float2(0.9935f, 0.0020f)},
+ float2(0.9935f, 0.0020f),
+ float4(-1),
+ "MAMat_EmissTiledAnotherFolder"},
};
import_and_check("cubes_with_textures_rel.obj", expect, std::size(expect), 4, 4);
}
@@ -455,7 +505,10 @@ TEST_F(obj_importer_test, import_all_objects)
26,
float3(28, 1, -1),
float3(26, 1, 1),
- float3(-1, 0, 0)},
+ float3(-1, 0, 0),
+ float2(0),
+ float4(-1),
+ "MARed"},
{"OBNurbsCircle",
OB_MESH,
96,
@@ -491,7 +544,10 @@ TEST_F(obj_importer_test, import_all_objects)
26,
float3(4, 1, -1),
float3(2, 1, 1),
- float3(0.5774f, 0.5773f, 0.5774f)},
+ float3(0.5774f, 0.5773f, 0.5774f),
+ float2(0),
+ float4(-1),
+ "MAMaterial"},
{"OBSurface",
OB_MESH,
256,
More information about the Bf-blender-cvs
mailing list