mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 07:03:56 -06:00
Speed up building of the layerdata mesh
Use numpy copies rather than python iteration since it is far faster. Contributes to CURA-224
This commit is contained in:
parent
98d2acaba7
commit
75b8466065
1 changed files with 5 additions and 8 deletions
|
@ -63,6 +63,7 @@ class LayerData(MeshData):
|
||||||
offset = data.build(offset, vertices, colors, indices)
|
offset = data.build(offset, vertices, colors, indices)
|
||||||
self._element_counts[layer] = data.elementCount
|
self._element_counts[layer] = data.elementCount
|
||||||
|
|
||||||
|
self.clear()
|
||||||
self.addVertices(vertices)
|
self.addVertices(vertices)
|
||||||
self.addColors(colors)
|
self.addColors(colors)
|
||||||
self.addIndices(indices.flatten())
|
self.addIndices(indices.flatten())
|
||||||
|
@ -198,18 +199,14 @@ class Polygon():
|
||||||
|
|
||||||
def build(self, offset, vertices, colors, indices):
|
def build(self, offset, vertices, colors, indices):
|
||||||
self._begin = offset
|
self._begin = offset
|
||||||
|
self._end = self._begin + len(self._data) - 1
|
||||||
|
|
||||||
color = self.getColor()
|
color = self.getColor()
|
||||||
color.setValues(color.r * 0.5, color.g * 0.5, color.b * 0.5, color.a)
|
color.setValues(color.r * 0.5, color.g * 0.5, color.b * 0.5, color.a)
|
||||||
|
color = numpy.array([color.r, color.g, color.b, color.a], numpy.float32)
|
||||||
|
|
||||||
for i in range(len(self._data)):
|
vertices[self._begin:self._end + 1, :] = self._data[:, :]
|
||||||
vertices[offset + i, :] = self._data[i, :]
|
colors[self._begin:self._end + 1, :] = color
|
||||||
colors[offset + i, 0] = color.r
|
|
||||||
colors[offset + i, 1] = color.g
|
|
||||||
colors[offset + i, 2] = color.b
|
|
||||||
colors[offset + i, 3] = color.a
|
|
||||||
|
|
||||||
self._end = self._begin + len(self._data) - 1
|
|
||||||
|
|
||||||
for i in range(self._begin, self._end):
|
for i in range(self._begin, self._end):
|
||||||
indices[i, 0] = i
|
indices[i, 0] = i
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue