Submesh 4/n: TexturesVertex submeshing

Summary: Add submeshing capability for meshes with TexturesVertex.

Reviewed By: bottler

Differential Revision: D35448534

fbshipit-source-id: 6d16a31a5bfb24ce122cf3c300a7616bc58353d1
This commit is contained in:
Krzysztof Chalupka
2022-04-11 16:27:53 -07:00
committed by Facebook GitHub Bot
parent 050f650ae8
commit 22f86072ca
3 changed files with 109 additions and 7 deletions

View File

@@ -145,6 +145,53 @@ class TestTexturesVertex(TestCaseMixin, unittest.TestCase):
self.assertClose(faces_verts_texts_packed, faces_verts_texts)
def test_submeshes(self):
# define TexturesVertex
verts_features = torch.tensor(
[
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
[0, 1, 0],
],
dtype=torch.float32,
)
textures = TexturesVertex(
verts_features=[verts_features, verts_features, verts_features]
)
subtextures = textures.submeshes(
[
[
torch.LongTensor([0, 2, 3]),
torch.LongTensor(list(range(8))),
],
[],
[
torch.LongTensor([4]),
],
],
None,
)
subtextures_features = subtextures.verts_features_list()
self.assertEqual(len(subtextures_features), 3)
self.assertTrue(
torch.equal(
subtextures_features[0],
torch.FloatTensor([[1, 0, 0], [1, 0, 0], [1, 0, 0]]),
)
)
self.assertTrue(torch.equal(subtextures_features[1], verts_features))
self.assertTrue(
torch.equal(subtextures_features[2], torch.FloatTensor([[0, 1, 0]]))
)
def test_clone(self):
tex = TexturesVertex(verts_features=torch.rand(size=(10, 100, 128)))
tex.verts_features_list()