Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
| Context not available. | |||||
| }; | }; | ||||
| const std::string all_objects_file = "io_tests/blend_scene/all_objects.blend"; | const std::string all_objects_file = "io_tests/blend_scene/all_objects.blend"; | ||||
| const std::string all_curve_objects_file = "io_tests/blend_scene/all_curves.blend"; | |||||
| TEST_F(obj_exporter_test, filter_objects_curves_as_mesh) | TEST_F(obj_exporter_test, filter_objects_curves_as_mesh) | ||||
| { | { | ||||
| Context not available. | |||||
| return; | return; | ||||
| } | } | ||||
| auto [objmeshes, objcurves]{filter_supported_objects(depsgraph, _export.params)}; | auto [objmeshes, objcurves]{filter_supported_objects(depsgraph, _export.params)}; | ||||
| EXPECT_EQ(objmeshes.size(), 19); | EXPECT_EQ(objmeshes.size(), 20); | ||||
| EXPECT_EQ(objcurves.size(), 0); | EXPECT_EQ(objcurves.size(), 0); | ||||
| } | } | ||||
| Context not available. | |||||
| _export.params.export_curves_as_nurbs = true; | _export.params.export_curves_as_nurbs = true; | ||||
| auto [objmeshes, objcurves]{filter_supported_objects(depsgraph, _export.params)}; | auto [objmeshes, objcurves]{filter_supported_objects(depsgraph, _export.params)}; | ||||
| EXPECT_EQ(objmeshes.size(), 18); | EXPECT_EQ(objmeshes.size(), 18); | ||||
| EXPECT_EQ(objcurves.size(), 2); | EXPECT_EQ(objcurves.size(), 3); | ||||
| } | } | ||||
| TEST_F(obj_exporter_test, filter_objects_selected) | TEST_F(obj_exporter_test, filter_objects_selected) | ||||
| Context not available. | |||||
| EXPECT_EQ_ARRAY(path_with_frame, path_truth, BLI_strlen_utf8(path_truth)); | EXPECT_EQ_ARRAY(path_with_frame, path_truth, BLI_strlen_utf8(path_truth)); | ||||
| } | } | ||||
| TEST_F(obj_exporter_test, curve_nurbs_points) | |||||
| { | |||||
| if (!load_file_and_depsgraph(all_curve_objects_file)) { | |||||
| ADD_FAILURE(); | |||||
| return; | |||||
| } | |||||
| OBJExportParamsDefault _export; | |||||
| _export.params.export_curves_as_nurbs = true; | |||||
| auto [objmeshes_unused, objcurves]{filter_supported_objects(depsgraph, _export.params)}; | |||||
| for (auto &objcurve : objcurves) { | |||||
| if (all_nurbs_truth.count(objcurve->get_curve_name()) != 1) { | |||||
| ADD_FAILURE(); | |||||
| return; | |||||
| } | |||||
| const NurbsObject *const nurbs_truth = all_nurbs_truth.at(objcurve->get_curve_name()).get(); | |||||
| EXPECT_EQ(objcurve->total_splines(), nurbs_truth->total_splines()); | |||||
| for (int spline_index : IndexRange(objcurve->total_splines())) { | |||||
| EXPECT_EQ(objcurve->total_spline_vertices(spline_index), | |||||
| nurbs_truth->total_spline_vertices(spline_index)); | |||||
| EXPECT_EQ(objcurve->get_nurbs_degree(spline_index), | |||||
| nurbs_truth->get_nurbs_degree(spline_index)); | |||||
| EXPECT_EQ(objcurve->total_spline_control_points(spline_index), | |||||
| nurbs_truth->total_spline_control_points(spline_index)); | |||||
| } | |||||
| } | |||||
| } | |||||
| TEST_F(obj_exporter_test, curve_coordinates) | |||||
| { | |||||
| if (!load_file_and_depsgraph(all_curve_objects_file)) { | |||||
| ADD_FAILURE(); | |||||
| return; | |||||
| } | |||||
| OBJExportParamsDefault _export; | |||||
| _export.params.export_curves_as_nurbs = true; | |||||
| auto [objmeshes_unused, objcurves]{filter_supported_objects(depsgraph, _export.params)}; | |||||
| for (auto &objcurve : objcurves) { | |||||
| if (all_nurbs_truth.count(objcurve->get_curve_name()) != 1) { | |||||
| ADD_FAILURE(); | |||||
| return; | |||||
| } | |||||
| const NurbsObject *const nurbs_truth = all_nurbs_truth.at(objcurve->get_curve_name()).get(); | |||||
| EXPECT_EQ(objcurve->total_splines(), nurbs_truth->total_splines()); | |||||
| for (int spline_index : IndexRange(objcurve->total_splines())) { | |||||
| for (int vertex_index : IndexRange(objcurve->total_spline_vertices(spline_index))) { | |||||
| EXPECT_V3_NEAR(objcurve->vertex_coordinates( | |||||
| spline_index, vertex_index, _export.params.scaling_factor), | |||||
| nurbs_truth->vertex_coordinates(spline_index, vertex_index), | |||||
| 0.000001f); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| static std::unique_ptr<OBJWriter> init_writer(const OBJExportParams ¶ms, | static std::unique_ptr<OBJWriter> init_writer(const OBJExportParams ¶ms, | ||||
| const std::string out_filepath) | const std::string out_filepath) | ||||
| { | { | ||||
| Context not available. | |||||
| _export.params); | _export.params); | ||||
| } | } | ||||
| TEST_F(obj_exporter_regression_test, all_curves) | |||||
| { | |||||
| OBJExportParamsDefault _export; | |||||
| _export.params.export_materials = false; | |||||
| compare_obj_export_to_golden( | |||||
| "io_tests/blend_scene/all_curves.blend", "io_tests/obj/all_curves.obj", "", _export.params); | |||||
| } | |||||
| TEST_F(obj_exporter_regression_test, all_curves_as_nurbs) | |||||
| { | |||||
| OBJExportParamsDefault _export; | |||||
| _export.params.export_materials = false; | |||||
| _export.params.export_curves_as_nurbs = true; | |||||
| compare_obj_export_to_golden("io_tests/blend_scene/all_curves.blend", | |||||
| "io_tests/obj/all_curves_as_nurbs.obj", | |||||
| "", | |||||
| _export.params); | |||||
| } | |||||
| TEST_F(obj_exporter_regression_test, all_objects) | TEST_F(obj_exporter_regression_test, all_objects) | ||||
| { | { | ||||
| OBJExportParamsDefault _export; | OBJExportParamsDefault _export; | ||||
| Context not available. | |||||