mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 06:33:57 -06:00
#7461 - Use three floats for defining vertex normal to render travel toolpaths. This fixes a crash on NVIDIA Quadro graphics cards when turning on travel moves visibility in preview.
This commit is contained in:
parent
0538363b2b
commit
cc2b8da6a4
2 changed files with 11 additions and 17 deletions
|
@ -2,18 +2,8 @@
|
||||||
|
|
||||||
varying vec3 eye_normal;
|
varying vec3 eye_normal;
|
||||||
|
|
||||||
vec3 world_normal()
|
|
||||||
{
|
|
||||||
// the world normal is always parallel to the world XY plane
|
|
||||||
// the x component is stored into gl_Vertex.w
|
|
||||||
float x = gl_Vertex.w;
|
|
||||||
float y = sqrt(1.0 - x * x);
|
|
||||||
return vec3(x, y, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 world_position = vec4(gl_Vertex.xyz, 1.0);
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
gl_Position = gl_ModelViewProjectionMatrix * world_position;
|
eye_normal = gl_NormalMatrix * gl_Normal;
|
||||||
eye_normal = gl_NormalMatrix * world_normal();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,7 +608,7 @@ void GCodeViewer::init()
|
||||||
}
|
}
|
||||||
case EMoveType::Travel: {
|
case EMoveType::Travel: {
|
||||||
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line;
|
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line;
|
||||||
buffer.vertices.format = VBuffer::EFormat::PositionNormal1;
|
buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
|
||||||
buffer.shader = "toolpaths_lines";
|
buffer.shader = "toolpaths_lines";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1140,15 +1140,19 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
||||||
// format data into the buffers to be rendered as lines
|
// format data into the buffers to be rendered as lines
|
||||||
auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) {
|
auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) {
|
||||||
// x component of the normal to the current segment (the normal is parallel to the XY plane)
|
// x component of the normal to the current segment (the normal is parallel to the XY plane)
|
||||||
const float normal_x = (curr.position - prev.position).normalized().y();
|
const Vec3f dir = (curr.position - prev.position).normalized();
|
||||||
|
Vec3f normal(dir.y(), -dir.x(), 0.0);
|
||||||
|
normal.normalize();
|
||||||
|
|
||||||
auto add_vertex = [&vertices, normal_x](const GCodeProcessorResult::MoveVertex& vertex) {
|
auto add_vertex = [&vertices, &normal](const GCodeProcessorResult::MoveVertex& vertex) {
|
||||||
// add position
|
// add position
|
||||||
vertices.push_back(vertex.position.x());
|
vertices.push_back(vertex.position.x());
|
||||||
vertices.push_back(vertex.position.y());
|
vertices.push_back(vertex.position.y());
|
||||||
vertices.push_back(vertex.position.z());
|
vertices.push_back(vertex.position.z());
|
||||||
// add normal x component
|
// add normal
|
||||||
vertices.push_back(normal_x);
|
vertices.push_back(normal.x());
|
||||||
|
vertices.push_back(normal.y());
|
||||||
|
vertices.push_back(normal.z());
|
||||||
};
|
};
|
||||||
|
|
||||||
// add previous vertex
|
// add previous vertex
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue