Fix unreliable PLY regression test
At a random the bf_io_ply_tests would fail in one of the fixtures. The root of the issue was that the exporter parameters were used uninitialized, causing the mesh to be triangulated in some of the runs and not be triangulated in other runs. This change makes it so PLYExportParams is always zero-initialized, so that this solves this issue, and that adding fields to it in the future will not re-introduce the issue. Pull Request: https://projects.blender.org/blender/blender/pulls/105537
This commit is contained in:
committed by
Brecht Van Lommel
parent
d11874bf21
commit
78e8c6649d
@@ -64,7 +64,7 @@ static int wm_ply_export_exec(bContext *C, wmOperator *op)
|
||||
BKE_report(op->reports, RPT_ERROR, "No filename given");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
struct PLYExportParams export_params;
|
||||
struct PLYExportParams export_params = {"\0"};
|
||||
export_params.file_base_for_tests[0] = '\0';
|
||||
RNA_string_get(op->ptr, "filepath", export_params.filepath);
|
||||
export_params.blen_filepath = CTX_data_main(C)->filepath;
|
||||
|
||||
@@ -125,7 +125,7 @@ static std::vector<char> read_temp_file_in_vectorchar(const std::string &file_pa
|
||||
TEST_F(PlyExportTest, WriteHeaderAscii)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = true;
|
||||
_params.export_normals = false;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -163,7 +163,7 @@ TEST_F(PlyExportTest, WriteHeaderAscii)
|
||||
TEST_F(PlyExportTest, WriteHeaderBinary)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = false;
|
||||
_params.export_normals = false;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -201,7 +201,7 @@ TEST_F(PlyExportTest, WriteHeaderBinary)
|
||||
TEST_F(PlyExportTest, WriteVerticesAscii)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = true;
|
||||
_params.export_normals = false;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -233,7 +233,7 @@ TEST_F(PlyExportTest, WriteVerticesAscii)
|
||||
TEST_F(PlyExportTest, WriteVerticesBinary)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = false;
|
||||
_params.export_normals = false;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -275,7 +275,7 @@ TEST_F(PlyExportTest, WriteVerticesBinary)
|
||||
TEST_F(PlyExportTest, WriteFacesAscii)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = true;
|
||||
_params.export_normals = false;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -305,7 +305,7 @@ TEST_F(PlyExportTest, WriteFacesAscii)
|
||||
TEST_F(PlyExportTest, WriteFacesBinary)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = false;
|
||||
_params.export_normals = false;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -348,7 +348,7 @@ TEST_F(PlyExportTest, WriteFacesBinary)
|
||||
TEST_F(PlyExportTest, WriteVertexNormalsAscii)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = true;
|
||||
_params.export_normals = true;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -380,7 +380,7 @@ TEST_F(PlyExportTest, WriteVertexNormalsAscii)
|
||||
TEST_F(PlyExportTest, WriteVertexNormalsBinary)
|
||||
{
|
||||
std::string filePath = get_temp_ply_filename(temp_file_path);
|
||||
PLYExportParams _params;
|
||||
PLYExportParams _params = {};
|
||||
_params.ascii_format = false;
|
||||
_params.export_normals = true;
|
||||
_params.vertex_colors = PLY_VERTEX_COLOR_NONE;
|
||||
@@ -450,14 +450,14 @@ class ply_exporter_ply_data_test : public PlyExportTest {
|
||||
|
||||
TEST_F(ply_exporter_ply_data_test, CubeLoadPLYDataVertices)
|
||||
{
|
||||
PLYExportParams params;
|
||||
PLYExportParams params = {};
|
||||
PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/cube_all_data.blend",
|
||||
params);
|
||||
EXPECT_EQ(plyData.vertices.size(), 8);
|
||||
}
|
||||
TEST_F(ply_exporter_ply_data_test, CubeLoadPLYDataUV)
|
||||
{
|
||||
PLYExportParams params;
|
||||
PLYExportParams params = {};
|
||||
params.export_uv = true;
|
||||
PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/cube_all_data.blend",
|
||||
params);
|
||||
@@ -465,16 +465,16 @@ TEST_F(ply_exporter_ply_data_test, CubeLoadPLYDataUV)
|
||||
}
|
||||
TEST_F(ply_exporter_ply_data_test, SuzanneLoadPLYDataUV)
|
||||
{
|
||||
PLYExportParams params;
|
||||
PLYExportParams params = {};
|
||||
params.export_uv = true;
|
||||
PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/suzanne_all_data.blend",
|
||||
params);
|
||||
EXPECT_EQ(plyData.uv_coordinates.size(), 541);
|
||||
EXPECT_EQ(plyData.uv_coordinates.size(), 542);
|
||||
}
|
||||
|
||||
TEST_F(ply_exporter_ply_data_test, CubeLoadPLYDataUVDisabled)
|
||||
{
|
||||
PLYExportParams params;
|
||||
PLYExportParams params = {};
|
||||
params.export_uv = false;
|
||||
PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/cube_all_data.blend",
|
||||
params);
|
||||
|
||||
Reference in New Issue
Block a user