FIX: enable wireframe in paint tool

Jira: STUDIO-3996

The buffer data submitted when the wireframe function is closed is half less than the buffer data submitted when the wireframe function is open

Change-Id: I92542190a5a45f562ec89d7c41fef3cdf1c26418
(cherry picked from commit b95650954f8bdb0cf81a2063efba4b2fced13a2f)
This commit is contained in:
zhou.xu
2023-09-11 15:23:29 +08:00
committed by Lane.Wei
parent 5225e8d891
commit 5658d32633
6 changed files with 40 additions and 28 deletions

View File

@@ -77,13 +77,13 @@ std::pair<bool, std::string> GLShadersManager::init()
//if (GUI::wxGetApp().plater() && GUI::wxGetApp().plater()->is_wireframe_enabled())
// valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"}, {"FLIP_TRIANGLE_NORMALS"sv});
//else
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}, {"FLIP_TRIANGLE_NORMALS"sv});
valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"}, {"FLIP_TRIANGLE_NORMALS"sv});//{"mm_gouraud.vs", "mm_gouraud.fs"}
}
else {
//if (GUI::wxGetApp().plater() && GUI::wxGetApp().plater()->is_wireframe_enabled())
// valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"});
//else
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"});
valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"});//{"mm_gouraud.vs", "mm_gouraud.fs"}
}
//BBS: add shader for outline

View File

@@ -356,17 +356,17 @@ void GLGizmoMmuSegmentation::show_tooltip_information(float caption_max, float x
std::vector<std::string> tip_items;
switch (m_tool_type) {
case ToolType::BRUSH:
tip_items = {"paint", "erase", "cursor_size", "clipping_of_view"};
case ToolType::BRUSH:
tip_items = {"paint", "erase", "cursor_size", "clipping_of_view", "toggle_wireframe"};
break;
case ToolType::BUCKET_FILL:
tip_items = {"paint", "erase", "smart_fill_angle", "clipping_of_view"};
case ToolType::BUCKET_FILL:
tip_items = {"paint", "erase", "smart_fill_angle", "clipping_of_view", "toggle_wireframe"};
break;
case ToolType::SMART_FILL:
// TODO:
break;
case ToolType::GAP_FILL:
tip_items = {"gap_area"};
tip_items = {"gap_area", "toggle_wireframe"};
break;
default:
break;

View File

@@ -1252,6 +1252,12 @@ float TriangleSelectorPatch::gap_area = TriangleSelectorPatch::GapAreaMin;
void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
{
static bool last_show_wireframe = false;
if (last_show_wireframe != wxGetApp().plater()->is_show_wireframe()) {
last_show_wireframe = wxGetApp().plater()->is_show_wireframe();
m_update_render_data = true;
m_paint_changed = true;
}
if (m_update_render_data)
update_render_data();
@@ -1262,9 +1268,9 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
GLint position_id = -1;
GLint barycentric_id = -1;
if (wxGetApp().plater()->is_wireframe_enabled()) {
position_id = shader->get_attrib_location("v_position");
barycentric_id = shader->get_attrib_location("v_barycentric");
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);
}
@@ -1324,7 +1330,7 @@ void TriangleSelectorPatch::update_triangles_per_type()
patch.triangle_indices.reserve(m_triangles.size() / 3);
}
bool using_wireframe = (wxGetApp().plater()->is_wireframe_enabled())?true:false;
bool using_wireframe = (wxGetApp().plater()->is_wireframe_enabled() && wxGetApp().plater()->is_show_wireframe()) ? true : false;
for (auto& triangle : m_triangles) {
if (!triangle.valid() || triangle.is_split())
@@ -1382,7 +1388,7 @@ void TriangleSelectorPatch::update_triangles_per_patch()
auto [neighbors, neighbors_propagated] = this->precompute_all_neighbors();
std::vector<bool> visited(m_triangles.size(), false);
bool using_wireframe = (wxGetApp().plater()->is_wireframe_enabled())?true:false;
bool using_wireframe = (wxGetApp().plater()->is_wireframe_enabled() && wxGetApp().plater()->is_show_wireframe()) ? true : false;
auto get_all_touching_triangles = [this](int facet_idx, const Vec3i& neighbors, const Vec3i& neighbors_propagated) -> std::vector<int> {
assert(facet_idx != -1 && facet_idx < int(m_triangles.size()));

View File

@@ -7942,7 +7942,7 @@ Plater::Plater(wxWindow *parent, MainFrame *main_frame)
, p(new priv(this, main_frame))
{
// Initialization performed in the private c-tor
enable_wireframe(false);
enable_wireframe(true);
}
bool Plater::Show(bool show)