mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
fix _num_faces_per_mesh in join_batch
Summary: As reported in https://github.com/facebookresearch/pytorch3d/pull/1100, _num_faces_per_mesh was changing in the source mesh in join_batch. This affects both TexturesUV and TexturesAtlas Reviewed By: nikhilaravi Differential Revision: D34643675 fbshipit-source-id: d67bdaca7278f18a76cfb15ba59d0ea85575bd36
This commit is contained in:
parent
16d0aa82c1
commit
4a1f176054
@ -569,7 +569,7 @@ class TexturesAtlas(TexturesBase):
|
||||
|
||||
atlas_list = []
|
||||
atlas_list += self.atlas_list()
|
||||
num_faces_per_mesh = self._num_faces_per_mesh
|
||||
num_faces_per_mesh = self._num_faces_per_mesh.copy()
|
||||
for tex in textures:
|
||||
atlas_list += tex.atlas_list()
|
||||
num_faces_per_mesh += tex._num_faces_per_mesh
|
||||
@ -1073,7 +1073,7 @@ class TexturesUV(TexturesBase):
|
||||
faces_uvs_list += self.faces_uvs_list()
|
||||
verts_uvs_list += self.verts_uvs_list()
|
||||
maps_list += self.maps_list()
|
||||
num_faces_per_mesh = self._num_faces_per_mesh
|
||||
num_faces_per_mesh = self._num_faces_per_mesh.copy()
|
||||
for tex in textures:
|
||||
verts_uvs_list += tex.verts_uvs_list()
|
||||
faces_uvs_list += tex.faces_uvs_list()
|
||||
|
@ -793,7 +793,12 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
faces_uvs=torch.arange(150).reshape(1, 50, 3),
|
||||
verts_uvs=torch.rand(1, 150, 2) * 0.2 + 0.3,
|
||||
)
|
||||
self.assertEqual(a._num_faces_per_mesh, [100])
|
||||
self.assertEqual(b._num_faces_per_mesh, [50])
|
||||
c = a.join_batch([b]).join_scene()
|
||||
self.assertEqual(a._num_faces_per_mesh, [100])
|
||||
self.assertEqual(b._num_faces_per_mesh, [50])
|
||||
self.assertEqual(c._num_faces_per_mesh, [150])
|
||||
|
||||
color = c.faces_verts_textures_packed()
|
||||
color1 = color[:100, :, 0].flatten()
|
||||
@ -904,7 +909,12 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
textures2 = TexturesAtlas(atlas=[atlas2])
|
||||
mesh1 = Meshes(verts=[verts], faces=[faces], textures=textures1)
|
||||
mesh2 = Meshes(verts=[verts_shifted1], faces=[faces], textures=textures2)
|
||||
self.assertEqual(textures1._num_faces_per_mesh, [len(faces)])
|
||||
self.assertEqual(textures2._num_faces_per_mesh, [len(faces)])
|
||||
mesh_joined = join_meshes_as_scene([mesh1, mesh2])
|
||||
self.assertEqual(textures1._num_faces_per_mesh, [len(faces)])
|
||||
self.assertEqual(textures2._num_faces_per_mesh, [len(faces)])
|
||||
self.assertEqual(mesh_joined.textures._num_faces_per_mesh, [len(faces) * 2])
|
||||
|
||||
R, T = look_at_view_transform(18, 0, 0)
|
||||
cameras = FoVPerspectiveCameras(device=device, R=R, T=T)
|
||||
|
Loading…
x
Reference in New Issue
Block a user