Skip to content

Commit 3416332

Browse files
Gil Moshayoffacebook-github-bot
Gil Moshayof
authored andcommitted
Make extend respect subclasses of textures
Summary: 3 extend functions in textures.py updated to call `self.__class__` rather than create a new object of its type. As mentioned in #618 . Reviewed By: bottler Differential Revision: D28281218 fbshipit-source-id: b9c99ab87e46a3f28c37efa1ee2c2dceb560b491
1 parent d17b121 commit 3416332

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pytorch3d/renderer/mesh/textures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def atlas_packed(self) -> torch.Tensor:
470470

471471
def extend(self, N: int) -> "TexturesAtlas":
472472
new_props = self._extend(N, ["atlas_padded", "_num_faces_per_mesh"])
473-
new_tex = TexturesAtlas(atlas=new_props["atlas_padded"])
473+
new_tex = self.__class__(atlas=new_props["atlas_padded"])
474474
new_tex._num_faces_per_mesh = new_props["_num_faces_per_mesh"]
475475
return new_tex
476476

@@ -865,7 +865,7 @@ def extend(self, N: int) -> "TexturesUV":
865865
"_num_faces_per_mesh",
866866
],
867867
)
868-
new_tex = TexturesUV(
868+
new_tex = self.__class__(
869869
maps=new_props["maps_padded"],
870870
faces_uvs=new_props["faces_uvs_padded"],
871871
verts_uvs=new_props["verts_uvs_padded"],
@@ -1339,7 +1339,7 @@ def verts_features_packed(self) -> torch.Tensor:
13391339

13401340
def extend(self, N: int) -> "TexturesVertex":
13411341
new_props = self._extend(N, ["verts_features_padded", "_num_verts_per_mesh"])
1342-
new_tex = TexturesVertex(verts_features=new_props["verts_features_padded"])
1342+
new_tex = self.__class__(verts_features=new_props["verts_features_padded"])
13431343
new_tex._num_verts_per_mesh = new_props["_num_verts_per_mesh"]
13441344
return new_tex
13451345

0 commit comments

Comments
 (0)