mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Make lines update in real-time in the simulation-view too.
This approach does suffer from returning to exactly the same point, which can mess up the view. part of CURA-11521
This commit is contained in:
parent
7c00d2f0b3
commit
6e75eb34af
3 changed files with 27 additions and 1 deletions
|
@ -143,6 +143,7 @@ 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
|
||||
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
|
||||
|
@ -162,12 +163,19 @@ class SimulationPass(RenderPass):
|
|||
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()
|
||||
self._layer_shader.setUniformValue("u_last_vertex", pos_a)
|
||||
self._layer_shader.setUniformValue("u_next_vertex", pos_a)
|
||||
self._layer_shader.setUniformValue("u_last_line_ratio", 1.0)
|
||||
else:
|
||||
pos_b = Vector(polygon.data[index + 1][0],
|
||||
polygon.data[index + 1][1],
|
||||
polygon.data[index + 1][2])
|
||||
vec = pos_a * (1.0 - ratio) + pos_b * ratio
|
||||
head_position = vec + node.getWorldPosition()
|
||||
towards_next_vertex = 2
|
||||
self._layer_shader.setUniformValue("u_last_vertex", pos_a)
|
||||
self._layer_shader.setUniformValue("u_next_vertex", pos_b)
|
||||
self._layer_shader.setUniformValue("u_last_line_ratio", ratio)
|
||||
break
|
||||
break
|
||||
if self._layer_view.getMinimumLayer() > layer:
|
||||
|
@ -176,7 +184,7 @@ class SimulationPass(RenderPass):
|
|||
|
||||
# Calculate the range of paths in the last layer
|
||||
current_layer_start = end
|
||||
current_layer_end = end + int( self._layer_view.getCurrentPath()) * 2 # Because each point is used twice
|
||||
current_layer_end = end + towards_next_vertex + int( self._layer_view.getCurrentPath()) * 2 # Because each point is used twice
|
||||
|
||||
# This uses glDrawRangeElements internally to only draw a certain range of lines.
|
||||
# All the layers but the current selected layer are rendered first
|
||||
|
|
|
@ -19,6 +19,10 @@ vertex41core =
|
|||
|
||||
uniform highp mat4 u_normalMatrix;
|
||||
|
||||
uniform vec3 u_last_vertex;
|
||||
uniform vec3 u_next_vertex;
|
||||
uniform float u_last_line_ratio;
|
||||
|
||||
in highp vec4 a_vertex;
|
||||
in lowp vec4 a_color;
|
||||
in lowp vec4 a_material_color;
|
||||
|
@ -134,6 +138,10 @@ vertex41core =
|
|||
void main()
|
||||
{
|
||||
vec4 v1_vertex = a_vertex;
|
||||
if (v1_vertex.xyz == u_next_vertex)
|
||||
{
|
||||
v1_vertex.xyz = mix(u_last_vertex, u_next_vertex, u_last_line_ratio);
|
||||
}
|
||||
v1_vertex.y -= a_line_dim.y / 2; // half layer down
|
||||
|
||||
vec4 world_space_vert = u_modelMatrix * v1_vertex;
|
||||
|
|
|
@ -10,6 +10,10 @@ vertex41core =
|
|||
|
||||
uniform highp mat4 u_normalMatrix;
|
||||
|
||||
uniform vec3 u_last_vertex;
|
||||
uniform vec3 u_next_vertex;
|
||||
uniform float u_last_line_ratio;
|
||||
|
||||
in highp vec4 a_vertex;
|
||||
in lowp vec4 a_color;
|
||||
in lowp vec4 a_grayColor;
|
||||
|
@ -35,6 +39,10 @@ vertex41core =
|
|||
void main()
|
||||
{
|
||||
vec4 v1_vertex = a_vertex;
|
||||
if (v1_vertex.xyz == u_next_vertex)
|
||||
{
|
||||
v1_vertex.xyz = mix(u_last_vertex, u_next_vertex, u_last_line_ratio);
|
||||
}
|
||||
v1_vertex.y -= a_line_dim.y / 2; // half layer down
|
||||
|
||||
vec4 world_space_vert = u_modelMatrix * v1_vertex;
|
||||
|
@ -274,6 +282,8 @@ u_viewMatrix = view_matrix
|
|||
u_projectionMatrix = projection_matrix
|
||||
u_normalMatrix = normal_matrix
|
||||
u_lightPosition = light_0_position
|
||||
u_lastVertex = last_vertex
|
||||
u_nextVertex = next_vertex
|
||||
|
||||
[attributes]
|
||||
a_vertex = vertex
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue