|
@@ -121,6 +121,7 @@ class SimulationPass(RenderPass):
|
|
|
disabled_batch = RenderBatch(self._disabled_shader)
|
|
|
head_position = None # Indicates the current position of the print head
|
|
|
nozzle_node = None
|
|
|
+ not_a_vector = Vector(math.nan, math.nan, math.nan)
|
|
|
|
|
|
for node in DepthFirstIterator(self._scene.getRoot()):
|
|
|
|
|
@@ -143,6 +144,10 @@ class SimulationPass(RenderPass):
|
|
|
if self._layer_view.getCurrentLayer() > -1 and ((not self._layer_view._only_show_top_layers) or (not self._layer_view.getCompatibilityMode())):
|
|
|
start = 0
|
|
|
end = 0
|
|
|
+ vertex_before_head = not_a_vector
|
|
|
+ vertex_after_head = not_a_vector
|
|
|
+ vertex_distance_ratio = 0.0
|
|
|
+ towards_next_vertex = 0
|
|
|
element_counts = layer_data.getElementCounts()
|
|
|
for layer in sorted(element_counts.keys()):
|
|
|
# In the current layer, we show just the indicated paths
|
|
@@ -159,6 +164,8 @@ class SimulationPass(RenderPass):
|
|
|
ratio = self._layer_view.getCurrentPath() - math.floor(self._layer_view.getCurrentPath())
|
|
|
pos_a = Vector(polygon.data[index][0], polygon.data[index][1],
|
|
|
polygon.data[index][2])
|
|
|
+ vertex_before_head = pos_a
|
|
|
+ vertex_distance_ratio = ratio
|
|
|
if ratio <= 0.0001 or index + 1 == len(polygon.data):
|
|
|
# in case there multiple polygons and polygon changes, the first point has the same value as the last point in the previous polygon
|
|
|
head_position = pos_a + node.getWorldPosition()
|
|
@@ -168,6 +175,8 @@ class SimulationPass(RenderPass):
|
|
|
polygon.data[index + 1][2])
|
|
|
vec = pos_a * (1.0 - ratio) + pos_b * ratio
|
|
|
head_position = vec + node.getWorldPosition()
|
|
|
+ vertex_after_head = pos_b
|
|
|
+ towards_next_vertex = 2 # Add two to the index to print the current and next vertices as an 'unfinished' line (to the nozzle).
|
|
|
break
|
|
|
break
|
|
|
if self._layer_view.getMinimumLayer() > layer:
|
|
@@ -187,6 +196,11 @@ class SimulationPass(RenderPass):
|
|
|
self._current_shader = self._layer_shader
|
|
|
self._switching_layers = True
|
|
|
|
|
|
+ # reset 'last vertex'
|
|
|
+ self._layer_shader.setUniformValue("u_last_vertex", not_a_vector)
|
|
|
+ self._layer_shader.setUniformValue("u_next_vertex", not_a_vector)
|
|
|
+ self._layer_shader.setUniformValue("u_last_line_ratio", 1.0)
|
|
|
+
|
|
|
# The first line does not have a previous line: add a MoveCombingType in front for start detection
|
|
|
# this way the first start of the layer can also be drawn
|
|
|
prev_line_types = numpy.concatenate([numpy.asarray([LayerPolygon.MoveCombingType], dtype = numpy.float32), layer_data._attributes["line_types"]["value"]])
|
|
@@ -203,6 +217,17 @@ class SimulationPass(RenderPass):
|
|
|
current_layer_batch.addItem(node.getWorldTransformation(), layer_data)
|
|
|
current_layer_batch.render(self._scene.getActiveCamera())
|
|
|
|
|
|
+ # Last line may be partial
|
|
|
+ if vertex_after_head != not_a_vector and vertex_after_head != not_a_vector:
|
|
|
+ self._layer_shader.setUniformValue("u_last_vertex", vertex_before_head)
|
|
|
+ self._layer_shader.setUniformValue("u_next_vertex", vertex_after_head)
|
|
|
+ self._layer_shader.setUniformValue("u_last_line_ratio", vertex_distance_ratio)
|
|
|
+ last_line_start = current_layer_end
|
|
|
+ last_line_end = current_layer_end + towards_next_vertex
|
|
|
+ last_line_batch = RenderBatch(self._layer_shader, type = RenderBatch.RenderType.Solid, mode=RenderBatch.RenderMode.Lines, range = (last_line_start, last_line_end))
|
|
|
+ last_line_batch.addItem(node.getWorldTransformation(), layer_data)
|
|
|
+ last_line_batch.render(self._scene.getActiveCamera())
|
|
|
+
|
|
|
self._old_current_layer = self._layer_view.getCurrentLayer()
|
|
|
self._old_current_path = self._layer_view.getCurrentPath()
|
|
|
|