Skip to content

Commit

Permalink
Make extend respect subclasses of textures
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gil Moshayof authored and facebook-github-bot committed May 7, 2021
1 parent d17b121 commit 3416332
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pytorch3d/renderer/mesh/textures.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def atlas_packed(self) -> torch.Tensor:

def extend(self, N: int) -> "TexturesAtlas":
new_props = self._extend(N, ["atlas_padded", "_num_faces_per_mesh"])
new_tex = TexturesAtlas(atlas=new_props["atlas_padded"])
new_tex = self.__class__(atlas=new_props["atlas_padded"])
new_tex._num_faces_per_mesh = new_props["_num_faces_per_mesh"]
return new_tex

Expand Down Expand Up @@ -865,7 +865,7 @@ def extend(self, N: int) -> "TexturesUV":
"_num_faces_per_mesh",
],
)
new_tex = TexturesUV(
new_tex = self.__class__(
maps=new_props["maps_padded"],
faces_uvs=new_props["faces_uvs_padded"],
verts_uvs=new_props["verts_uvs_padded"],
Expand Down Expand Up @@ -1339,7 +1339,7 @@ def verts_features_packed(self) -> torch.Tensor:

def extend(self, N: int) -> "TexturesVertex":
new_props = self._extend(N, ["verts_features_padded", "_num_verts_per_mesh"])
new_tex = TexturesVertex(verts_features=new_props["verts_features_padded"])
new_tex = self.__class__(verts_features=new_props["verts_features_padded"])
new_tex._num_verts_per_mesh = new_props["_num_verts_per_mesh"]
return new_tex

Expand Down

0 comments on commit 3416332

Please sign in to comment.