@@ -41,7 +41,9 @@ def flat_list_to_tuples(data: Sequence[T], item_size: int) -> List[tuple[T, ...]
41
41
return [tuple (data [i : i + item_size ]) for i in range (0 , len (data ), item_size )]
42
42
43
43
44
- def vector_list_to_tuples (data : List [Union [Vector2f , Vector3f , Vector4f ]]) -> List [tuple ]:
44
+ def vector_list_to_tuples (
45
+ data : List [Union [Vector2f , Vector3f , Vector4f ]],
46
+ ) -> List [tuple ]:
45
47
if isinstance (data [0 ], Vector2f ):
46
48
return [(v .x , v .y ) for v in data ]
47
49
elif isinstance (data [0 ], Vector3f ):
@@ -396,9 +398,7 @@ def read_vertex_data(
396
398
component_data = struct .unpack (
397
399
f">{ count } { component_dtype } " , componentBytes
398
400
)
399
- component_data = flat_list_to_tuples (
400
- component_data , channel_dimension
401
- )
401
+ component_data = flat_list_to_tuples (component_data , channel_dimension )
402
402
403
403
self .assign_channel_vertex_data (chn , component_data )
404
404
@@ -653,16 +653,17 @@ def get_triangles(self) -> List[List[Tuple[int, ...]]]:
653
653
indexCount = m_SubMesh .indexCount
654
654
topology = m_SubMesh .topology
655
655
656
- triangles : List [int ]
656
+ triangles : List [Tuple [ int , ...] ]
657
657
658
658
if topology == MeshTopology .Triangles :
659
- triangles = self .m_IndexBuffer [firstIndex : firstIndex + indexCount ]
659
+ triangles = self .m_IndexBuffer [firstIndex : firstIndex + indexCount ] # type: ignore
660
+ triangles = [triangles [i : i + 3 ] for i in range (0 , len (triangles ), 3 )] # type: ignore
660
661
elif (
661
662
self .version [0 ] < 4 or topology == MeshTopology .TriangleStrip
662
663
): # TriangleStrip
663
664
# todo: use as_strided, then fix winding, finally remove degenerates
664
665
triIndex = 0
665
- triangles = list (( indexCount - 2 ) * 3 )
666
+ triangles = [ None ] * ( indexCount - 2 ) # type: ignore
666
667
667
668
for i in range (indexCount - 2 ):
668
669
a , b , c = self .m_IndexBuffer [firstIndex + i : firstIndex + i + 3 ]
@@ -682,11 +683,10 @@ def get_triangles(self) -> List[List[Tuple[int, ...]]]:
682
683
elif topology == MeshTopology .Quads :
683
684
# one quad is two triangles, so // 4 * 2 = // 2
684
685
# TODO: use as_strided
685
- triangles = list (indexCount // 2 , 3 )
686
+ triangles = [ None ] * (indexCount // 2 ) # type: ignore
686
687
triIndex = 0
687
- for a , b , c , d in self .m_IndexBuffer [
688
- firstIndex : firstIndex + indexCount : 4
689
- ]:
688
+ for i in range (firstIndex , firstIndex + indexCount ,4 ):
689
+ a ,b ,c ,d = self .m_IndexBuffer [i :i + 4 ]
690
690
triangles [triIndex ] = a , b , c
691
691
triangles [triIndex + 1 ] = a , c , d
692
692
triIndex += 2
@@ -695,7 +695,6 @@ def get_triangles(self) -> List[List[Tuple[int, ...]]]:
695
695
"Failed getting triangles. Submesh topology is lines or points."
696
696
)
697
697
698
- triangles = [triangles [i : i + 3 ] for i in range (0 , len (triangles ), 3 )]
699
698
submeshes .append (triangles )
700
699
701
700
return submeshes
0 commit comments