Skip to content

Commit

Permalink
perf: faster triangle calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Nov 1, 2024
1 parent 5fbb6e1 commit 723c725
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions zmesh/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,9 @@ def clone(self):
else:
return Mesh(np.copy(self.vertices), np.copy(self.faces), np.copy(self.normals))

def triangles(self):
Nf = self.faces.shape[0]
tris = np.zeros( (Nf, 3, 3), dtype=np.float32, order='C' ) # triangle, vertices, (x,y,z)

for i in range(Nf):
for j in range(3):
tris[i,j,:] = self.vertices[ self.faces[i,j] ]

return tris
def triangles(self) -> np.ndarray:
"""Returns vertex triples representing triangluar faces."""
return self.vertices[self.faces]

@classmethod
def concatenate(cls, *meshes, id=None):
Expand Down

0 comments on commit 723c725

Please sign in to comment.