Revert speedup

This commit is contained in:
Jaime van Kessel 2020-02-24 12:47:11 +01:00
parent b86658996b
commit 239a8ea3db
No known key found for this signature in database
GPG key ID: 3710727397403C91
2 changed files with 24 additions and 42 deletions

View file

@ -112,24 +112,29 @@ class SimulationPass(RenderPass):
# Render all layers below a certain number as line mesh instead of vertices. # Render all layers below a certain number as line mesh instead of vertices.
if self._layer_view._current_layer_num > -1 and ((not self._layer_view._only_show_top_layers) or (not self._layer_view.getCompatibilityMode())): if self._layer_view._current_layer_num > -1 and ((not self._layer_view._only_show_top_layers) or (not self._layer_view.getCompatibilityMode())):
start = self._layer_view.start_elements_index start = 0
end = self._layer_view.end_elements_index end = 0
index = self._layer_view._current_path_num element_counts = layer_data.getElementCounts()
offset = 0 for layer in sorted(element_counts.keys()):
layer = layer_data.getLayer(self._layer_view._current_layer_num) # In the current layer, we show just the indicated paths
if layer is None: if layer == self._layer_view._current_layer_num:
continue # We look for the position of the head, searching the point of the current path
for polygon in layer.polygons: index = self._layer_view._current_path_num
# The size indicates all values in the two-dimension array, and the second dimension is offset = 0
# always size 3 because we have 3D points. for polygon in layer_data.getLayer(layer).polygons:
if index >= polygon.data.size // 3 - offset: # The size indicates all values in the two-dimension array, and the second dimension is
index -= polygon.data.size // 3 - offset # always size 3 because we have 3D points.
offset = 1 # This is to avoid the first point when there is more than one polygon, since has the same value as the last point in the previous polygon if index >= polygon.data.size // 3 - offset:
continue index -= polygon.data.size // 3 - offset
# The head position is calculated and translated offset = 1 # This is to avoid the first point when there is more than one polygon, since has the same value as the last point in the previous polygon
head_position = Vector(polygon.data[index + offset][0], polygon.data[index + offset][1], continue
polygon.data[index + offset][2]) + node.getWorldPosition() # The head position is calculated and translated
break head_position = Vector(polygon.data[index+offset][0], polygon.data[index+offset][1], polygon.data[index+offset][2]) + node.getWorldPosition()
break
break
if self._layer_view._minimum_layer_num > layer:
start += element_counts[layer]
end += element_counts[layer]
# Calculate the range of paths in the last layer # Calculate the range of paths in the last layer
current_layer_start = end current_layer_start = end

View file

@ -71,8 +71,6 @@ class SimulationView(CuraView):
self._max_paths = 0 self._max_paths = 0
self._current_path_num = 0 self._current_path_num = 0
self._minimum_path_num = 0 self._minimum_path_num = 0
self.start_elements_index = 0
self.end_elements_index = 0
self.currentLayerNumChanged.connect(self._onCurrentLayerNumChanged) self.currentLayerNumChanged.connect(self._onCurrentLayerNumChanged)
self._busy = False self._busy = False
@ -247,7 +245,6 @@ class SimulationView(CuraView):
self._minimum_layer_num = self._current_layer_num self._minimum_layer_num = self._current_layer_num
self._startUpdateTopLayers() self._startUpdateTopLayers()
self.recalculateStartEndElements()
self.currentLayerNumChanged.emit() self.currentLayerNumChanged.emit()
@ -262,7 +259,7 @@ class SimulationView(CuraView):
self._current_layer_num = self._minimum_layer_num self._current_layer_num = self._minimum_layer_num
self._startUpdateTopLayers() self._startUpdateTopLayers()
self.recalculateStartEndElements()
self.currentLayerNumChanged.emit() self.currentLayerNumChanged.emit()
def setPath(self, value: int) -> None: def setPath(self, value: int) -> None:
@ -276,7 +273,6 @@ class SimulationView(CuraView):
self._minimum_path_num = self._current_path_num self._minimum_path_num = self._current_path_num
self._startUpdateTopLayers() self._startUpdateTopLayers()
self.recalculateStartEndElements()
self.currentPathNumChanged.emit() self.currentPathNumChanged.emit()
def setMinimumPath(self, value: int) -> None: def setMinimumPath(self, value: int) -> None:
@ -364,24 +360,6 @@ class SimulationView(CuraView):
return 0.0 # If it's still max-float, there are no measurements. Use 0 then. return 0.0 # If it's still max-float, there are no measurements. Use 0 then.
return self._min_thickness return self._min_thickness
def recalculateStartEndElements(self):
self.start_elements_index = 0
self.end_elements_index = 0
scene = self.getController().getScene()
for node in DepthFirstIterator(scene.getRoot()): # type: ignore
layer_data = node.callDecoration("getLayerData")
if not layer_data:
continue
# Found a the layer data!
element_counts = layer_data.getElementCounts()
for layer in sorted(element_counts.keys()):
if layer == self._current_layer_num:
break
if self._minimum_layer_num > layer:
self.start_elements_index += element_counts[layer]
self.end_elements_index += element_counts[layer]
def getMaxThickness(self) -> float: def getMaxThickness(self) -> float:
return self._max_thickness return self._max_thickness
@ -603,7 +581,6 @@ class SimulationView(CuraView):
def _startUpdateTopLayers(self) -> None: def _startUpdateTopLayers(self) -> None:
if not self._compatibility_mode: if not self._compatibility_mode:
return return
self.recalculateStartEndElements()
if self._top_layers_job: if self._top_layers_job:
self._top_layers_job.finished.disconnect(self._updateCurrentLayerMesh) self._top_layers_job.finished.disconnect(self._updateCurrentLayerMesh)
self._top_layers_job.cancel() self._top_layers_job.cancel()