mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Numpy magic to speed up the expansion of indices-to-vectors to just vectors. CURA-2548
Sending models to engine that have indices is slow
This commit is contained in:
parent
7082ff7d68
commit
b9dd2ef6f9
1 changed files with 6 additions and 11 deletions
|
@ -163,22 +163,17 @@ class StartSliceJob(Job):
|
|||
obj.id = id(object)
|
||||
verts = mesh_data.getVertices()
|
||||
indices = mesh_data.getIndices()
|
||||
|
||||
if indices is not None:
|
||||
#TODO: This is a very slow way of doing it! It also locks up the GUI.
|
||||
flat_vert_list = []
|
||||
for face in indices:
|
||||
for vert_index in face:
|
||||
flat_vert_list.append(verts[vert_index])
|
||||
Job.yieldThread()
|
||||
verts = numpy.array(flat_vert_list)
|
||||
flat_verts = numpy.take(verts, indices.flatten(), axis=0)
|
||||
else:
|
||||
verts = numpy.array(verts)
|
||||
flat_verts = numpy.array(verts)
|
||||
|
||||
# Convert from Y up axes to Z up axes. Equals a 90 degree rotation.
|
||||
verts[:, [1, 2]] = verts[:, [2, 1]]
|
||||
verts[:, 1] *= -1
|
||||
flat_verts[:, [1, 2]] = flat_verts[:, [2, 1]]
|
||||
flat_verts[:, 1] *= -1
|
||||
|
||||
obj.vertices = verts
|
||||
obj.vertices = flat_verts
|
||||
|
||||
self._handlePerObjectSettings(object, obj)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue