mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 06:33:57 -06:00
FIX:Replace v_barycentric by gl_Color to slove factory computer issues
modify Shortcut keys to toggle Wireframe Jira: STUDIO-4772 Change-Id: Ica5c1c6c0a41ed247c85173b3b0437632f596e7d (cherry picked from commit 79a1805e8fde6e0b735a529ab7c7c7fe9015865b)
This commit is contained in:
parent
8a8020e0a9
commit
17e9bb48d8
5 changed files with 22 additions and 24 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_barycentric;
|
||||
//attribute vec3 v_position;
|
||||
//attribute vec3 v_barycentric;
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
|
@ -25,19 +25,18 @@ struct SlopeDetection
|
|||
uniform SlopeDetection slope;
|
||||
void main()
|
||||
{
|
||||
//model_pos = gl_Vertex;
|
||||
model_pos = vec4(v_position, 1.0);
|
||||
model_pos = gl_Vertex;
|
||||
//model_pos = vec4(v_position, 1.0);
|
||||
// Point in homogenous coordinates.
|
||||
//vec4 world_pos = volume_world_matrix * gl_Vertex;
|
||||
world_pos = volume_world_matrix * model_pos;
|
||||
|
||||
//gl_Position = ftransform();
|
||||
gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position.x, v_position.y, v_position.z, 1.0);
|
||||
gl_Position = ftransform();
|
||||
//gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position, 1.0);
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
|
||||
//compute the Barycentric Coordinates
|
||||
//int vertexMod3 = gl_VertexID % 3;
|
||||
//barycentric_coordinates = vec3(float(vertexMod3 == 0), float(vertexMod3 == 1), float(vertexMod3 == 2));
|
||||
barycentric_coordinates = v_barycentric;
|
||||
barycentric_coordinates = gl_Color.xyz;//v_barycentric
|
||||
}
|
||||
|
|
|
@ -3356,8 +3356,8 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
wxGetApp().plater()->toggle_render_statistic_dialog();
|
||||
m_dirty = true;
|
||||
#endif
|
||||
}
|
||||
else if (evt.ShiftDown() && evt.ControlDown() && keyCode == WXK_RETURN) {
|
||||
} else if ((evt.ShiftDown() && evt.ControlDown() && keyCode == WXK_RETURN) ||
|
||||
evt.ShiftDown() && evt.AltDown() && keyCode == WXK_RETURN) {
|
||||
wxGetApp().plater()->toggle_show_wireframe();
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ bool GLGizmoMmuSegmentation::on_init()
|
|||
m_desc["height_range"] = _L("Height range");
|
||||
|
||||
//add toggle wire frame hint
|
||||
m_desc["toggle_wireframe_caption"] = _L("Ctrl + Shift + Enter");
|
||||
m_desc["toggle_wireframe_caption"] = _L("Alt + Shift + Enter");
|
||||
m_desc["toggle_wireframe"] = _L("Toggle Wireframe");
|
||||
|
||||
init_extruders_data();
|
||||
|
|
|
@ -1267,12 +1267,14 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
|
|||
assert(shader->get_name() == "mm_gouraud");
|
||||
GLint position_id = -1;
|
||||
GLint barycentric_id = -1;
|
||||
bool show_wireframe = false;
|
||||
if (wxGetApp().plater()->is_wireframe_enabled()) {
|
||||
if (m_need_wireframe && wxGetApp().plater()->is_show_wireframe()) {
|
||||
position_id = shader->get_attrib_location("v_position");
|
||||
barycentric_id = shader->get_attrib_location("v_barycentric");
|
||||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", show_wireframe on");
|
||||
shader->set_uniform("show_wireframe", true);
|
||||
show_wireframe = true;
|
||||
}
|
||||
else {
|
||||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", show_wireframe off");
|
||||
|
@ -1298,7 +1300,7 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
|
|||
shader->set_uniform("uniform_color", new_color);
|
||||
//shader->set_uniform("uniform_color", color);
|
||||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", buffer_idx %1%: new_color[%2%, %3%, %4%, %5%]")%buffer_idx%new_color[0]%new_color[1]%new_color[2]%new_color[3];
|
||||
this->render(buffer_idx, (int)position_id, (int)barycentric_id);
|
||||
this->render(buffer_idx, (int) position_id, show_wireframe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1562,7 +1564,7 @@ void TriangleSelectorPatch::update_render_data()
|
|||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", exit");
|
||||
}
|
||||
|
||||
void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, int barycentric_id)
|
||||
void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, bool show_wireframe)
|
||||
{
|
||||
assert(triangle_indices_idx < this->m_triangle_indices_VBO_ids.size());
|
||||
assert(this->m_triangle_patches.size() == this->m_triangle_indices_VBO_ids.size());
|
||||
|
@ -1575,18 +1577,15 @@ void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, in
|
|||
//glsafe(::glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), (const void*)(0 * sizeof(float))));
|
||||
if (this->m_triangle_indices_sizes[triangle_indices_idx] > 0) {
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->m_vertices_VBO_ids[triangle_indices_idx]));
|
||||
if (position_id != -1) {
|
||||
glsafe(::glEnableVertexAttribArray((GLint)position_id));
|
||||
glsafe(::glVertexAttribPointer((GLint)position_id, 3, GL_FLOAT, GL_FALSE, 6*sizeof(float), nullptr));
|
||||
if (show_wireframe) {
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), (const void *) 0));
|
||||
glsafe(::glColorPointer(3,GL_FLOAT, 6 * sizeof(float), (const void *) (3 * sizeof(float))));
|
||||
glsafe(::glEnableClientState(GL_COLOR_ARRAY));
|
||||
}
|
||||
else {
|
||||
glsafe(::glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), nullptr));
|
||||
}
|
||||
|
||||
if (barycentric_id != -1) {
|
||||
glsafe(::glEnableVertexAttribArray((GLint)barycentric_id));
|
||||
glsafe(::glVertexAttribPointer((GLint)barycentric_id, 3, GL_FLOAT, GL_FALSE, 6*sizeof(float), (GLvoid*)(intptr_t)(3 * sizeof(float))));
|
||||
}
|
||||
//glsafe(::glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), nullptr));
|
||||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: triangle_indices_idx %2%, bind vertex vbo, buffer id %3%")%__LINE__%triangle_indices_idx%this->m_vertices_VBO_ids[triangle_indices_idx];
|
||||
}
|
||||
|
@ -1604,9 +1603,9 @@ void TriangleSelectorPatch::render(int triangle_indices_idx, int position_id, in
|
|||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
if ((this->m_triangle_indices_sizes[triangle_indices_idx] > 0)&&(position_id != -1))
|
||||
glsafe(::glDisableVertexAttribArray(position_id));
|
||||
if ((this->m_triangle_indices_sizes[triangle_indices_idx] > 0)&&(barycentric_id != -1))
|
||||
glsafe(::glDisableVertexAttribArray((GLint)barycentric_id));
|
||||
|
||||
if ((this->m_triangle_indices_sizes[triangle_indices_idx] > 0)&&show_wireframe) {
|
||||
glsafe(::glEnableClientState(GL_COLOR_ARRAY));
|
||||
}
|
||||
if (this->m_triangle_indices_sizes[triangle_indices_idx] > 0)
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ protected:
|
|||
|
||||
private:
|
||||
void update_render_data();
|
||||
void render(int buffer_idx, int position_id = -1, int barycentric_id = -1);
|
||||
void render(int buffer_idx, int position_id = -1, bool show_wireframe=false);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue