diff --git a/cura/Layer.py b/cura/Layer.py index 52c4583f54..11c6a7f908 100644 --- a/cura/Layer.py +++ b/cura/Layer.py @@ -15,6 +15,7 @@ class Layer: self._height = 0.0 self._thickness = 0.0 self._polygons = [] # type: List[LayerPolygon] + self._vertex_count = 0 self._element_count = 0 @property @@ -29,6 +30,10 @@ class Layer: def polygons(self) -> List[LayerPolygon]: return self._polygons + @property + def vertexCount(self): + return self._vertex_count + @property def elementCount(self): return self._element_count @@ -64,11 +69,13 @@ class Layer: def build(self, vertex_offset, index_offset, vertices, colors, line_dimensions, feedrates, extruders, line_types, indices): result_vertex_offset = vertex_offset result_index_offset = index_offset + self._vertex_count = 0 self._element_count = 0 for polygon in self._polygons: polygon.build(result_vertex_offset, result_index_offset, vertices, colors, line_dimensions, feedrates, extruders, line_types, indices) result_vertex_offset += polygon.lineMeshVertexCount() result_index_offset += polygon.lineMeshElementCount() + self._vertex_count += polygon.vertexCount self._element_count += polygon.elementCount return result_vertex_offset, result_index_offset diff --git a/cura/LayerPolygon.py b/cura/LayerPolygon.py index cf4bb47a86..610366d5fc 100644 --- a/cura/LayerPolygon.py +++ b/cura/LayerPolygon.py @@ -187,6 +187,10 @@ class LayerPolygon: def data(self): return self._data + @property + def vertexCount(self): + return self._vertex_end - self._vertex_begin + @property def elementCount(self): return (self._index_end - self._index_begin) * 2 # The range of vertices multiplied by 2 since each vertex is used twice diff --git a/plugins/SimulationView/SimulationPass.py b/plugins/SimulationView/SimulationPass.py index 3f5f12a702..b17b38be38 100644 --- a/plugins/SimulationView/SimulationPass.py +++ b/plugins/SimulationView/SimulationPass.py @@ -162,7 +162,7 @@ class SimulationPass(RenderPass): head_position = Vector(polygon.data[index+offset][0], polygon.data[index+offset][1], polygon.data[index+offset][2]) + node.getWorldPosition() break break - end += layer_data.getLayer(layer).lineMeshVertexCount() + end += layer_data.getLayer(layer).vertexCount if layer < self._layer_view._minimum_layer_num: start = end