| 19 | using ModelExportTest = RadiantTest; |
| 20 | |
| 21 | TEST_F(ModelExportTest, ExportPatchMesh) |
| 22 | { |
| 23 | // Load a map with a cylinder patch |
| 24 | loadMap("modelexport_patch.map"); |
| 25 | |
| 26 | auto patchNode = algorithm::findFirstPatchWithMaterial(GlobalMapModule().findOrInsertWorldspawn(), |
| 27 | "textures/darkmod/wood/boards/ship_hull_medium"); |
| 28 | EXPECT_TRUE(patchNode); |
| 29 | |
| 30 | Node_setSelected(patchNode, true); |
| 31 | |
| 32 | // Choose a file in our temp data folder |
| 33 | std::string modRelativePath = "models/temp/temp_patch.lwo"; |
| 34 | |
| 35 | fs::path outputFilename = _context.getTestProjectPath(); |
| 36 | outputFilename /= modRelativePath; |
| 37 | os::makeDirectory(outputFilename.parent_path().string()); |
| 38 | |
| 39 | auto exporter = GlobalModelFormatManager().getExporter("lwo"); |
| 40 | |
| 41 | cmd::ArgumentList argList; |
| 42 | |
| 43 | // ExportSelectedAsModel <Path> <ExportFormat> [<ExportOrigin>] [<OriginEntityName>] [<CustomOrigin>][<SkipCaulk>][<ReplaceSelectionWithModel>][<ExportLightsAsObjects>] |
| 44 | argList.push_back(outputFilename.string()); |
| 45 | argList.push_back(std::string("lwo")); |
| 46 | argList.push_back(model::getExportOriginString(model::ModelExportOrigin::SelectionCenter)); // centerObjects |
| 47 | argList.push_back(std::string()); // OriginEntityName |
| 48 | argList.push_back(Vector3()); // CustomOrigin |
| 49 | argList.push_back(true); // skipCaulk |
| 50 | argList.push_back(false); // replaceSelectionWithModel |
| 51 | argList.push_back(false); // exportLightsAsObjects |
| 52 | |
| 53 | GlobalCommandSystem().executeCommand("ExportSelectedAsModel", argList); |
| 54 | |
| 55 | auto model = GlobalModelCache().getModel(modRelativePath); |
| 56 | |
| 57 | EXPECT_TRUE(model); |
| 58 | |
| 59 | // We expect exactly the same amount of vertices as in the patch mesh |
| 60 | // This ensures that no vertices have been duplicated or faces separated |
| 61 | auto patch = std::dynamic_pointer_cast<IPatchNode>(patchNode); |
| 62 | EXPECT_EQ(model->getVertexCount(), patch->getPatch().getTesselatedPatchMesh().vertices.size()); |
| 63 | |
| 64 | // Clean up the file |
| 65 | fs::remove(outputFilename); |
| 66 | } |
| 67 | |
| 68 | // #5658: Model exporter failed to write the file if the folder doesn't exist |
| 69 | TEST_F(ModelExportTest, ExportFolderNotExisting) |
nothing calls this directly
no test coverage detected