TexturesVertex._num_verts_per_mesh deep copy (#623)

Summary:
When a list of Meshes is `join_batched()`, the `num_verts_per_mesh` in the list would be unexpectedly modified.

Also some cleanup around `_num_verts_per_mesh`.

Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/623

Test Plan: A modification to an existing test checks this.

Reviewed By: nikhilaravi

Differential Revision: D27682104

Pulled By: bottler

fbshipit-source-id: 9d00913dfb4869bd6c7d3f5cc9156b7b6f1aecc9
This commit is contained in:
JudyYe
2021-04-20 03:10:39 -07:00
committed by Facebook GitHub Bot
parent 8660db9806
commit eb04a488c5
2 changed files with 11 additions and 17 deletions

View File

@@ -786,6 +786,11 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase):
mesh_rgb = Meshes(verts=[verts], faces=[faces], textures=rgb_tex)
mesh_rgb3 = join_meshes_as_batch([mesh_rgb, mesh_rgb, mesh_rgb])
check_triple(mesh_rgb, mesh_rgb3)
nums_rgb = mesh_rgb.textures._num_verts_per_mesh
nums_rgb3 = mesh_rgb3.textures._num_verts_per_mesh
self.assertEqual(type(nums_rgb), list)
self.assertEqual(type(nums_rgb3), list)
self.assertListEqual(nums_rgb * 3, nums_rgb3)
# meshes with texture atlas, join into a batch.
device = "cuda:0"