-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mesh] TriangleMesh's "+=" operator appends UVs regardless of the presence of existing features #6728
base: main
Are you sure you want to change the base?
Conversation
…e of existing features.
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdbharath Thanks for your PR, please have a look at the comment
@@ -77,30 +74,29 @@ TriangleMesh &TriangleMesh::operator+=(const TriangleMesh &mesh) { | |||
if (HasAdjacencyList()) { | |||
ComputeAdjacencyList(); | |||
} | |||
if (add_textures) { | |||
if (mesh.HasTriangleUvs()) { | |||
size_t old_tri_uv_num = triangle_uvs_.size(); | |||
triangle_uvs_.resize(old_tri_uv_num + mesh.triangle_uvs_.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this
does not have any UV coordinates then triangle_uvs_.size()
will be different from the total number of triangles in the resulting mesh. This would break with the assumption that triangle_uvs_.size() == 3*number of triangles
Hi @cdbharath , we think mixing meshes with and without texture uvs can be problematic. I added a special case for empty meshes that allows your workflow with the += operator. |
Allows appending of UV coordinates, textures and material IDs with
+=
operator overload inTriangleMesh
class irrespective of the presence of these attributes in the existing mesh (mesh on LHS to += operator)Type
Motivation and Context
The
+=
operator overload ofTriangleMesh
class does not append UV coordinates, textures and material IDs when the existing mesh (mesh on LHS to += operator) already contains any of these attributes. There is no reason to limit+=
for UVs toTriangleMesh
with the attributes already assigned as it currently happens here.Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
The current change doesn't check if the presence of UV coordinates, textures and material IDs in the existing mesh and appends only based on their availability in the incoming mesh.
I am attaching a screenshot that shows the addition of UV coordinates based on
+=
operator. The test code is as followsThe following is the resulting mesh with its texture UVs.