Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/io/wavefront_obj/tests/obj_importer_tests.cc')
-rw-r--r--source/blender/io/wavefront_obj/tests/obj_importer_tests.cc367
1 files changed, 210 insertions, 157 deletions
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 eeb81f5e23e..c59269f5a7d 100644
--- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
@@ -158,6 +158,36 @@ TEST_F(obj_importer_test, import_cube)
import_and_check("cube.obj", expect, std::size(expect), 1);
}
+TEST_F(obj_importer_test, import_cube_o_after_verts)
+{
+ Expectation expect[] = {
+ {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
+ {
+ "OBActualCube",
+ OB_MESH,
+ 8,
+ 12,
+ 6,
+ 24,
+ float3(-1, -1, 1),
+ float3(1, -1, -1),
+ float3(0, 0, 1),
+ },
+ {
+ "OBSparseTri",
+ OB_MESH,
+ 6,
+ 3,
+ 1,
+ 3,
+ float3(1, -1, 1),
+ float3(-2, -2, 2),
+ float3(-0.2357f, 0.9428f, 0.2357f),
+ },
+ };
+ import_and_check("cube_o_after_verts.obj", expect, std::size(expect), 2);
+}
+
TEST_F(obj_importer_test, import_suzanne_all_data)
{
Expectation expect[] = {
@@ -196,7 +226,9 @@ TEST_F(obj_importer_test, import_nurbs_curves)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
+ {"OBCurveDeg3", OB_CURVES_LEGACY, 4, 0, 3, 0, float3(10, -2, 0), float3(6, -2, 0)},
{"OBnurbs_curves", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)},
+ {"OBNurbsCurveCyclic", OB_CURVES_LEGACY, 7, 0, 4, 1, float3(-2, -2, 0), float3(-6, 2, 0)},
{"OBNurbsCurveDiffWeights",
OB_CURVES_LEGACY,
4,
@@ -205,7 +237,6 @@ TEST_F(obj_importer_test, import_nurbs_curves)
0,
float3(6, -2, 0),
float3(2, -2, 0)},
- {"OBNurbsCurveCyclic", OB_CURVES_LEGACY, 7, 0, 4, 1, float3(-2, -2, 0), float3(-6, 2, 0)},
{"OBNurbsCurveEndpoint",
OB_CURVES_LEGACY,
4,
@@ -214,7 +245,6 @@ TEST_F(obj_importer_test, import_nurbs_curves)
0,
float3(-6, -2, 0),
float3(-10, -2, 0)},
- {"OBCurveDeg3", OB_CURVES_LEGACY, 4, 0, 3, 0, float3(10, -2, 0), float3(6, -2, 0)},
};
import_and_check("nurbs_curves.obj", expect, std::size(expect), 0);
}
@@ -239,7 +269,8 @@ TEST_F(obj_importer_test, import_nurbs_manual)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBCurve_Uniform_Parm", OB_CURVES_LEGACY, 5, 0, 4, 0, float3(-2, 0, 2), float3(-2, 0, 2)},
+ {"OBCurve_Cyclic", OB_CURVES_LEGACY, 7, 0, 4, 1, float3(-2, 0, 2), float3(2, 0, -2)},
+ {"OBCurve_Endpoints", OB_CURVES_LEGACY, 5, 1, 4, 0, float3(-2, 0, 2), float3(-2, 0, 2)},
{"OBCurve_NonUniform_Parm",
OB_CURVES_LEGACY,
5,
@@ -248,8 +279,7 @@ TEST_F(obj_importer_test, import_nurbs_manual)
0,
float3(-2, 0, 2),
float3(-2, 0, 2)},
- {"OBCurve_Endpoints", OB_CURVES_LEGACY, 5, 1, 4, 0, float3(-2, 0, 2), float3(-2, 0, 2)},
- {"OBCurve_Cyclic", OB_CURVES_LEGACY, 7, 0, 4, 1, float3(-2, 0, 2), float3(2, 0, -2)},
+ {"OBCurve_Uniform_Parm", OB_CURVES_LEGACY, 5, 0, 4, 0, float3(-2, 0, 2), float3(-2, 0, 2)},
};
import_and_check("nurbs_manual.obj", expect, std::size(expect), 0);
}
@@ -283,23 +313,14 @@ TEST_F(obj_importer_test, import_faces_invalid_or_with_holes)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBFaceWithHole_BecomesTwoFacesFormingAHole",
+ {"OBFaceAllVerts_BecomesOneOverlappingFaceUsingAllVerts",
OB_MESH,
8,
- 10,
- 2,
- 12,
- float3(-2, 0, -2),
- float3(1, 0, -1)},
- {"OBFaceQuadDupSomeVerts_BecomesOneQuadUsing4Verts",
- OB_MESH,
8,
- 4,
1,
- 4,
- float3(3, 0, -2),
- float3(6, 0, -1)},
- {"OBFaceTriDupVert_Becomes1Tri", OB_MESH, 8, 3, 1, 3, float3(-2, 0, 3), float3(1, 0, 4)},
+ 8,
+ float3(8, 0, -2),
+ float3(11, 0, -1)},
{"OBFaceAllVertsDup_BecomesOneOverlappingFaceUsingAllVerts",
OB_MESH,
8,
@@ -308,15 +329,24 @@ TEST_F(obj_importer_test, import_faces_invalid_or_with_holes)
8,
float3(3, 0, 3),
float3(6, 0, 4)},
- {"OBFaceAllVerts_BecomesOneOverlappingFaceUsingAllVerts",
+ {"OBFaceJustTwoVerts_IsSkipped", OB_MESH, 2, 0, 0, 0, float3(8, 0, 3), float3(8, 0, 7)},
+ {"OBFaceQuadDupSomeVerts_BecomesOneQuadUsing4Verts",
OB_MESH,
- 8,
- 8,
+ 4,
+ 4,
1,
+ 4,
+ float3(3, 0, -2),
+ float3(7, 0, -2)},
+ {"OBFaceTriDupVert_Becomes1Tri", OB_MESH, 3, 3, 1, 3, float3(-2, 0, 3), float3(2, 0, 7)},
+ {"OBFaceWithHole_BecomesTwoFacesFormingAHole",
+ OB_MESH,
8,
- float3(8, 0, -2),
- float3(11, 0, -1)},
- {"OBFaceJustTwoVerts_IsSkipped", OB_MESH, 8, 0, 0, 0, float3(8, 0, 3), float3(11, 0, 4)},
+ 10,
+ 2,
+ 12,
+ float3(-2, 0, -2),
+ float3(1, 0, -1)},
};
import_and_check("faces_invalid_or_with_holes.obj", expect, std::size(expect), 0);
}
@@ -327,12 +357,12 @@ TEST_F(obj_importer_test, import_invalid_indices)
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
{"OBQuad",
OB_MESH,
- 4,
+ 3,
3,
1,
3,
float3(-2, 0, -2),
- float3(2, 0, -2),
+ float3(2, 0, 2),
float3(0, 1, 0),
float2(0.5f, 0.25f)},
};
@@ -345,12 +375,12 @@ TEST_F(obj_importer_test, import_invalid_syntax)
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
{"OBObjectWithAReallyLongNameToCheckHowImportHandlesNamesThatAreLon",
OB_MESH,
- 10, /* NOTE: right now parses some invalid obj syntax as valid vertices. */
+ 3,
3,
1,
3,
float3(1, 2, 3),
- float3(10, 11, 12),
+ float3(7, 8, 9),
float3(0, 1, 0),
float2(0.5f, 0.25f)},
};
@@ -362,6 +392,63 @@ TEST_F(obj_importer_test, import_all_objects)
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
/* .obj file has empty EmptyText and EmptyMesh objects; these are ignored and skipped */
+ {"OBBezierCurve", OB_MESH, 13, 12, 0, 0, float3(-1, -2, 0), float3(1, -2, 0)},
+ {"OBBlankCube", OB_MESH, 8, 13, 7, 26, float3(1, 1, -1), float3(-1, 1, 1), float3(0, 0, 1)},
+ {"OBMaterialCube",
+ OB_MESH,
+ 8,
+ 13,
+ 7,
+ 26,
+ float3(28, 1, -1),
+ float3(26, 1, 1),
+ float3(-1, 0, 0)},
+ {"OBNurbsCircle",
+ OB_MESH,
+ 96,
+ 96,
+ 0,
+ 0,
+ float3(3.292893f, -2.707107f, 0),
+ float3(3.369084f, -2.77607f, 0)},
+ {"OBNurbsCircle.001", OB_MESH, 4, 4, 0, 0, float3(2, -3, 0), float3(3, -2, 0)},
+ {"OBParticleCube",
+ OB_MESH,
+ 8,
+ 13,
+ 7,
+ 26,
+ float3(22, 1, -1),
+ float3(20, 1, 1),
+ float3(0, 0, 1)},
+ {"OBShapeKeyCube",
+ OB_MESH,
+ 8,
+ 13,
+ 7,
+ 26,
+ float3(19, 1, -1),
+ float3(17, 1, 1),
+ float3(-0.4082f, -0.4082f, 0.8165f)},
+ {"OBSmoothCube",
+ OB_MESH,
+ 8,
+ 13,
+ 7,
+ 26,
+ float3(4, 1, -1),
+ float3(2, 1, 1),
+ float3(0.5774f, 0.5773f, 0.5774f)},
+ {"OBSurface",
+ OB_MESH,
+ 256,
+ 480,
+ 224,
+ 896,
+ float3(7.292893f, -2.707107f, -1),
+ float3(7.525872f, -2.883338f, 1),
+ float3(-0.7071f, -0.7071f, 0),
+ float2(0, 0.142857f)},
{"OBSurfPatch",
OB_MESH,
256,
@@ -382,24 +469,16 @@ TEST_F(obj_importer_test, import_all_objects)
float3(11, -2, 1),
float3(-0.0541f, -0.0541f, -0.9971f),
float2(0, 1)},
- {"OBSmoothCube",
- OB_MESH,
- 8,
- 13,
- 7,
- 26,
- float3(4, 1, -1),
- float3(2, 1, 1),
- float3(0.5774f, 0.5773f, 0.5774f)},
- {"OBMaterialCube",
+ {"OBSurfTorus.001",
OB_MESH,
- 8,
- 13,
- 7,
- 26,
- float3(28, 1, -1),
- float3(26, 1, 1),
- float3(-1, 0, 0)},
+ 1024,
+ 2048,
+ 1024,
+ 4096,
+ float3(5.34467f, -2.65533f, -0.176777f),
+ float3(5.232792f, -2.411795f, -0.220835f),
+ float3(-0.5042f, -0.5042f, -0.7011f),
+ float2(0, 1)},
{"OBTaperCube",
OB_MESH,
106,
@@ -409,24 +488,26 @@ TEST_F(obj_importer_test, import_all_objects)
float3(24.444445f, 0.502543f, -0.753814f),
float3(23.790743f, 0.460522f, -0.766546f),
float3(-0.0546f, 0.1716f, 0.9837f)},
- {"OBParticleCube",
+ {"OBText",
OB_MESH,
- 8,
- 13,
- 7,
- 26,
- float3(22, 1, -1),
- float3(20, 1, 1),
- float3(0, 0, 1)},
- {"OBShapeKeyCube",
+ 177,
+ 345,
+ 171,
+ 513,
+ float3(1.75f, -9.458f, 0),
+ float3(0.587f, -9.406f, 0),
+ float3(0, 0, 1),
+ float2(0.017544f, 0)},
+ {"OBUVCube",
OB_MESH,
8,
13,
7,
26,
- float3(19, 1, -1),
- float3(17, 1, 1),
- float3(-0.4082f, -0.4082f, 0.8165f)},
+ float3(7, 1, -1),
+ float3(5, 1, 1),
+ float3(0, 0, 1),
+ float2(0.654526f, 0.579873f)},
{"OBUVImageCube",
OB_MESH,
8,
@@ -437,15 +518,6 @@ TEST_F(obj_importer_test, import_all_objects)
float3(8, 1, 1),
float3(0, 0, 1),
float2(0.654526f, 0.579873f)},
- {"OBVGroupCube",
- OB_MESH,
- 8,
- 13,
- 7,
- 26,
- float3(16, 1, -1),
- float3(14, 1, 1),
- float3(0, 0, 1)},
{"OBVColCube",
OB_MESH,
8,
@@ -457,57 +529,15 @@ TEST_F(obj_importer_test, import_all_objects)
float3(0, 0, 1),
float2(0, 0),
float4(0.0f, 0.002125f, 1.0f, 1.0f)},
- {"OBUVCube",
+ {"OBVGroupCube",
OB_MESH,
8,
13,
7,
26,
- float3(7, 1, -1),
- float3(5, 1, 1),
- float3(0, 0, 1),
- float2(0.654526f, 0.579873f)},
- {"OBNurbsCircle.001", OB_MESH, 4, 4, 0, 0, float3(2, -3, 0), float3(3, -2, 0)},
- {"OBSurface",
- OB_MESH,
- 256,
- 480,
- 224,
- 896,
- float3(7.292893f, -2.707107f, -1),
- float3(7.525872f, -2.883338f, 1),
- float3(-0.7071f, -0.7071f, 0),
- float2(0, 0.142857f)},
- {"OBText",
- OB_MESH,
- 177,
- 345,
- 171,
- 513,
- float3(1.75f, -9.458f, 0),
- float3(0.587f, -9.406f, 0),
- float3(0, 0, 1),
- float2(0.017544f, 0)},
- {"OBSurfTorus.001",
- OB_MESH,
- 1024,
- 2048,
- 1024,
- 4096,
- float3(5.34467f, -2.65533f, -0.176777f),
- float3(5.232792f, -2.411795f, -0.220835f),
- float3(-0.5042f, -0.5042f, -0.7011f),
- float2(0, 1)},
- {"OBNurbsCircle",
- OB_MESH,
- 96,
- 96,
- 0,
- 0,
- float3(3.292893f, -2.707107f, 0),
- float3(3.369084f, -2.77607f, 0)},
- {"OBBezierCurve", OB_MESH, 13, 12, 0, 0, float3(-1, -2, 0), float3(1, -2, 0)},
- {"OBBlankCube", OB_MESH, 8, 13, 7, 26, float3(1, 1, -1), float3(-1, 1, 1), float3(0, 0, 1)},
+ float3(16, 1, -1),
+ float3(14, 1, 1),
+ float3(0, 0, 1)},
};
import_and_check("all_objects.obj", expect, std::size(expect), 7);
}
@@ -516,28 +546,6 @@ TEST_F(obj_importer_test, import_cubes_vertex_colors)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBCubeVertexByte",
- OB_MESH,
- 8,
- 12,
- 6,
- 24,
- float3(1.0f, 1.0f, -1.0f),
- float3(-1.0f, -1.0f, 1.0f),
- float3(0, 0, 0),
- float2(0, 0),
- float4(0.846873f, 0.027321f, 0.982123f, 1.0f)},
- {"OBCubeVertexFloat",
- OB_MESH,
- 8,
- 12,
- 6,
- 24,
- float3(3.392028f, 1.0f, -1.0f),
- float3(1.392028f, -1.0f, 1.0f),
- float3(0, 0, 0),
- float2(0, 0),
- float4(49.99467f, 0.027321f, 0.982123f, 1.0f)},
{"OBCubeCornerByte",
OB_MESH,
8,
@@ -579,35 +587,80 @@ TEST_F(obj_importer_test, import_cubes_vertex_colors)
24,
float3(-4.550208f, -1.0f, -1.918042f),
float3(-2.550208f, 1.0f, -3.918042f)},
+ {"OBCubeVertexByte",
+ OB_MESH,
+ 8,
+ 12,
+ 6,
+ 24,
+ float3(1.0f, 1.0f, -1.0f),
+ float3(-1.0f, -1.0f, 1.0f),
+ float3(0, 0, 0),
+ float2(0, 0),
+ float4(0.846873f, 0.027321f, 0.982123f, 1.0f)},
+ {"OBCubeVertexFloat",
+ OB_MESH,
+ 8,
+ 12,
+ 6,
+ 24,
+ float3(3.392028f, 1.0f, -1.0f),
+ float3(1.392028f, -1.0f, 1.0f),
+ float3(0, 0, 0),
+ float2(0, 0),
+ float4(49.99467f, 0.027321f, 0.982123f, 1.0f)},
};
import_and_check("cubes_vertex_colors.obj", expect, std::size(expect), 0);
}
TEST_F(obj_importer_test, import_cubes_vertex_colors_mrgb)
{
- Expectation expect[] = {{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBCubeXYZRGB",
- OB_MESH,
- 8,
- 12,
- 6,
- 24,
- float3(1, 1, -1),
- float3(-1, -1, 1),
- float3(0, 0, 0),
- float2(0, 0),
- float4(0.6038f, 0.3185f, 0.1329f, 1.0f)},
- {"OBCubeMRGB",
- OB_MESH,
- 8,
- 12,
- 6,
- 24,
- float3(4, 1, -1),
- float3(2, -1, 1),
- float3(0, 0, 0),
- float2(0, 0),
- float4(0.8714f, 0.6308f, 0.5271f, 1.0f)}};
+ Expectation expect[] = {
+ {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
+ {"OBCubeMRGB",
+ OB_MESH,
+ 8,
+ 12,
+ 6,
+ 24,
+ float3(4, 1, -1),
+ float3(2, -1, 1),
+ float3(0, 0, 0),
+ float2(0, 0),
+ float4(0.8714f, 0.6308f, 0.5271f, 1.0f)},
+ {"OBCubeXYZRGB",
+ OB_MESH,
+ 8,
+ 12,
+ 6,
+ 24,
+ float3(1, 1, -1),
+ float3(-1, -1, 1),
+ float3(0, 0, 0),
+ float2(0, 0),
+ float4(0.6038f, 0.3185f, 0.1329f, 1.0f)},
+ {"OBTriMRGB",
+ OB_MESH,
+ 3,
+ 3,
+ 1,
+ 3,
+ float3(12, 1, -1),
+ float3(10, 0, -1),
+ float3(0, 0, 0),
+ float2(0, 0),
+ float4(1.0f, 0.0f, 0.0f, 1.0f)},
+ {
+ "OBTriNoColors",
+ OB_MESH,
+ 3,
+ 3,
+ 1,
+ 3,
+ float3(8, 1, -1),
+ float3(6, 0, -1),
+ },
+ };
import_and_check("cubes_vertex_colors_mrgb.obj", expect, std::size(expect), 0);
}