From b1ff9d9fd4221e70b8ec86f816756f25d3fc3575 Mon Sep 17 00:00:00 2001 From: Krzysztof Chalupka Date: Tue, 12 Apr 2022 10:46:48 -0700 Subject: [PATCH] Disallow None vertex/face lists in texture submeshing Summary: In order to simplify the interface, we disallow passing None as vertex/face lists to textures.submeshes. This function would only ever get called from within meshes.submeshes where we can provide both arguments, even if they're not necessary for a specific submesh type. Reviewed By: bottler Differential Revision: D35581161 fbshipit-source-id: aeab99308a319b144e141ca85ca7515f855116da --- pytorch3d/renderer/mesh/textures.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pytorch3d/renderer/mesh/textures.py b/pytorch3d/renderer/mesh/textures.py index 3a83dd7f..4bf442e6 100644 --- a/pytorch3d/renderer/mesh/textures.py +++ b/pytorch3d/renderer/mesh/textures.py @@ -244,8 +244,8 @@ class TexturesBase: def submeshes( self, - vertex_ids_list: Optional[List[List[torch.LongTensor]]], - faces_ids_list: Optional[List[List[torch.LongTensor]]], + vertex_ids_list: List[List[torch.LongTensor]], + faces_ids_list: List[List[torch.LongTensor]], ) -> "TexturesBase": """ Extract sub-textures used for submeshing. @@ -1477,8 +1477,8 @@ class TexturesVertex(TexturesBase): def submeshes( self, - vertex_ids_list: Optional[List[List[torch.LongTensor]]], - faces_ids_list: Optional[List[List[torch.LongTensor]]], + vertex_ids_list: List[List[torch.LongTensor]], + faces_ids_list: List[List[torch.LongTensor]], ) -> "TexturesVertex": """ Extract a sub-texture for use in a submesh. @@ -1502,9 +1502,7 @@ class TexturesVertex(TexturesBase): sum(len(vertices) for vertices in vertex_ids_list). Each element contains vertex features corresponding to the subset of vertices in that submesh. """ - if vertex_ids_list is None or len(vertex_ids_list) != len( - self.verts_features_list() - ): + if len(vertex_ids_list) != len(self.verts_features_list()): raise IndexError( "verts_features_list must be of " "the same length as vertex_ids_list." )