mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Formulate layerview logic using numpy to speed up. Also changed layer data packets from engine to make it possible.
This commit is contained in:
parent
ac0f743855
commit
f184baadf0
6 changed files with 202 additions and 92 deletions
|
|
@ -50,18 +50,22 @@ class LayerDataBuilder(MeshBuilder):
|
|||
|
||||
def build(self):
|
||||
vertex_count = 0
|
||||
index_count = 0
|
||||
for layer, data in self._layers.items():
|
||||
vertex_count += data.vertexCount()
|
||||
vertex_count += data.lineMeshVertexCount()
|
||||
index_count += data.lineMeshElementCount()
|
||||
|
||||
vertices = numpy.empty((vertex_count, 3), numpy.float32)
|
||||
colors = numpy.empty((vertex_count, 4), numpy.float32)
|
||||
indices = numpy.empty((vertex_count, 2), numpy.int32)
|
||||
indices = numpy.empty((index_count, 2), numpy.int32)
|
||||
|
||||
offset = 0
|
||||
vertex_offset = 0
|
||||
index_offset = 0
|
||||
for layer, data in self._layers.items():
|
||||
offset = data.build(offset, vertices, colors, indices)
|
||||
( vertex_offset, index_offset ) = data.build( vertex_offset, index_offset, vertices, colors, indices)
|
||||
self._element_counts[layer] = data.elementCount
|
||||
|
||||
self.clear()
|
||||
self.addVertices(vertices)
|
||||
self.addColors(colors)
|
||||
self.addIndices(indices.flatten())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue