Skip to content

Commit 1df843a

Browse files
committed
MeshHelper - fix normals and tangents type hints
1 parent 2da57a3 commit 1df843a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

UnityPy/helpers/MeshHelper.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ class MeshHandler:
7878
version: Tuple[int, int, int, int]
7979
m_VertexCount: int = 0
8080
m_Vertices: Optional[List[Tuple3f]] = None
81-
m_Normals: Optional[List[Tuple3f]] = None
81+
# normals can be stored as Tuple4f,
82+
# in such cases the 4th dimension is always 0 and can be discarded
83+
m_Normals: Optional[Union[List[Tuple3f], List[Tuple4f]]] = None
8284
m_Colors: Optional[List[Tuple4f]] = None
8385
m_UV0: Optional[List[Tuple2f]] = None
8486
m_UV1: Optional[List[Tuple2f]] = None
@@ -88,7 +90,7 @@ class MeshHandler:
8890
m_UV5: Optional[List[Tuple2f]] = None
8991
m_UV6: Optional[List[Tuple2f]] = None
9092
m_UV7: Optional[List[Tuple2f]] = None
91-
m_Tangents: Optional[List[float]] = None
93+
m_Tangents: Optional[List[Tuple4f]] = None
9294
m_BoneIndices: Optional[List[int]] = None
9395
m_BoneWeights: Optional[List[float]] = None
9496
m_IndexBuffer: Optional[List[int]] = None
@@ -663,7 +665,7 @@ def get_triangles(self) -> List[List[Tuple[int, ...]]]:
663665
): # TriangleStrip
664666
# todo: use as_strided, then fix winding, finally remove degenerates
665667
triIndex = 0
666-
triangles = [None] * (indexCount - 2) # type: ignore
668+
triangles = [None] * (indexCount - 2) # type: ignore
667669

668670
for i in range(indexCount - 2):
669671
a, b, c = self.m_IndexBuffer[firstIndex + i : firstIndex + i + 3]
@@ -683,10 +685,10 @@ def get_triangles(self) -> List[List[Tuple[int, ...]]]:
683685
elif topology == MeshTopology.Quads:
684686
# one quad is two triangles, so // 4 * 2 = // 2
685687
# TODO: use as_strided
686-
triangles = [None] * (indexCount // 2) # type: ignore
688+
triangles = [None] * (indexCount // 2) # type: ignore
687689
triIndex = 0
688-
for i in range(firstIndex, firstIndex+indexCount,4):
689-
a,b,c,d = self.m_IndexBuffer[i:i+4]
690+
for i in range(firstIndex, firstIndex + indexCount, 4):
691+
a, b, c, d = self.m_IndexBuffer[i : i + 4]
690692
triangles[triIndex] = a, b, c
691693
triangles[triIndex + 1] = a, c, d
692694
triIndex += 2

0 commit comments

Comments
 (0)