-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmesh.py
36 lines (27 loc) · 875 Bytes
/
mesh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Nikita Akimov
#
# GitHub
# https://github.com/Korchy/bpy_plus
class Mesh:
""" Abstract class for working with meshes
"""
@staticmethod
def tris(obj) -> int:
""" Return a number of triangles in the mesh object
:param obj: mesh
:type obj: bpy.types.Object
:return: number of triangles in the mesh object
:rtype: int
"""
return sum(len(polygon.vertices) - 2 for polygon in obj.data.polygons)
@staticmethod
def apply_transforms(obj):
""" Apply all transformations (Translation, Rotation, Scale) to object
:param obj: mesh
:type obj: bpy.types.Object
"""
matrix_world = obj.matrix_world.copy()
for vert in obj.data.vertices:
vert.co = matrix_world @ vert.co
obj.matrix_world.identity()