From d4da0d555881380d8f001a6d9626446a4ca18339 Mon Sep 17 00:00:00 2001 From: Rene Sepulveda Date: Thu, 29 Feb 2024 17:03:42 -0500 Subject: [PATCH 1/2] Allow material conversion when legacy has > 1 materials --- cpp/open3d/t/geometry/TriangleMesh.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp index 6f33f8e44f7..3ffa11a3c2d 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.cpp +++ b/cpp/open3d/t/geometry/TriangleMesh.cpp @@ -365,8 +365,8 @@ geometry::TriangleMesh TriangleMesh::FromLegacy( .Reshape({-1, 3, 2})); } - // Convert material if legacy mesh only has one - if (mesh_legacy.materials_.size() == 1) { + // Convert material first material if legacy mesh has one + if (mesh_legacy.materials_.size() > 0) { const auto &mat = mesh_legacy.materials_.begin()->second; auto &tmat = mesh.GetMaterial(); tmat.SetDefaultProperties(); @@ -393,10 +393,11 @@ geometry::TriangleMesh TriangleMesh::FromLegacy( Image::FromLegacy(*mat.clearCoatRoughness)); if (mat.anisotropy) tmat.SetAnisotropyMap(Image::FromLegacy(*mat.anisotropy)); - } else if (mesh_legacy.materials_.size() > 1) { + } + if (mesh_legacy.materials_.size() > 1) { utility::LogWarning( "Legacy mesh has more than 1 material which is not supported " - "by Tensor-based meshes."); + "by Tensor-based mesh. Only first material was converted."); } return mesh; } From e79693cdf10af29acad136a3c7be4b48e8aabf43 Mon Sep 17 00:00:00 2001 From: Rene Sepulveda Date: Thu, 29 Feb 2024 21:11:51 -0500 Subject: [PATCH 2/2] Fix comment and update warning output --- cpp/open3d/t/geometry/TriangleMesh.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/open3d/t/geometry/TriangleMesh.cpp b/cpp/open3d/t/geometry/TriangleMesh.cpp index 3ffa11a3c2d..be5442b6428 100644 --- a/cpp/open3d/t/geometry/TriangleMesh.cpp +++ b/cpp/open3d/t/geometry/TriangleMesh.cpp @@ -365,7 +365,7 @@ geometry::TriangleMesh TriangleMesh::FromLegacy( .Reshape({-1, 3, 2})); } - // Convert material first material if legacy mesh has one + // Convert first material only if one or more are present if (mesh_legacy.materials_.size() > 0) { const auto &mat = mesh_legacy.materials_.begin()->second; auto &tmat = mesh.GetMaterial(); @@ -397,7 +397,8 @@ geometry::TriangleMesh TriangleMesh::FromLegacy( if (mesh_legacy.materials_.size() > 1) { utility::LogWarning( "Legacy mesh has more than 1 material which is not supported " - "by Tensor-based mesh. Only first material was converted."); + "by Tensor-based mesh. Only material {} was converted.", + mesh_legacy.materials_.begin()->first); } return mesh; }