Optimize loading meshes using numpy arrays

1) avoid calling geometry.xxx multiple times as each time it creates a new copy
2) use numpy arrays with correct data type, so Blender could perform buffer copy significantly reducing overhead
This commit is contained in:
Andrej730
2025-02-12 15:47:49 +05:00
parent cb95539cb0
commit 299b5bcf6b
5 changed files with 45 additions and 49 deletions
+1 -1
View File
@@ -614,7 +614,7 @@ class TestApplyIfcMaterialChanges(NewFile):
tool.Geometry._reload_representation(obj)
def get_material_indices(mesh: bpy.types.Mesh) -> np.ndarray:
buffer = np.empty(len(mesh.polygons), dtype=np.int32)
buffer = np.empty(len(mesh.polygons), dtype="I")
mesh.polygons.foreach_get("material_index", buffer)
return buffer