From 8b0ee4c4a2530a3fea99402f4abdae000774bf9a Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 5 Jul 2019 12:23:13 +0200 Subject: [PATCH] Improve OBJ mesh export in case output format is not explicitly specified --- src/Mod/Mesh/App/Mesh.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index ad52ae220e..5b70871f23 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -362,13 +362,18 @@ void MeshObject::save(const char* file, MeshCore::MeshIO::Format f, aWriter.Transform(this->_Mtrx); if (aWriter.SaveAny(file, f)) { - if (mat && mat->binding == MeshCore::MeshIO::PER_FACE && f == MeshCore::MeshIO::OBJ) { - Base::FileInfo fi(file); - std::string fn = fi.dirPath() + "/" + mat->library; - fi.setFile(fn); - Base::ofstream str(fi, std::ios::out | std::ios::binary); - aWriter.SaveMTL(str); - str.close(); + if (mat && mat->binding == MeshCore::MeshIO::PER_FACE) { + if (f == MeshCore::MeshIO::Undefined) + f = MeshCore::MeshOutput::GetFormat(file); + + if (f == MeshCore::MeshIO::OBJ) { + Base::FileInfo fi(file); + std::string fn = fi.dirPath() + "/" + mat->library; + fi.setFile(fn); + Base::ofstream str(fi, std::ios::out | std::ios::binary); + aWriter.SaveMTL(str); + str.close(); + } } } }