mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-18 21:35:53 +08:00
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:
parent
5225e8d891
commit
5658d32633
@ -19,12 +19,13 @@ const float EPSILON = 0.0001;
|
|||||||
//BBS: add grey and orange
|
//BBS: add grey and orange
|
||||||
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||||
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||||
|
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||||
|
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
varying vec3 clipping_planes_dots;
|
varying vec3 clipping_planes_dots;
|
||||||
varying vec4 model_pos;
|
varying vec4 model_pos;
|
||||||
|
varying vec4 world_pos;
|
||||||
uniform bool volume_mirrored;
|
uniform bool volume_mirrored;
|
||||||
|
|
||||||
struct SlopeDetection
|
struct SlopeDetection
|
||||||
@ -65,19 +66,24 @@ void main()
|
|||||||
float alpha = uniform_color.a;
|
float alpha = uniform_color.a;
|
||||||
|
|
||||||
vec3 triangle_normal = normalize(cross(dFdx(model_pos.xyz), dFdy(model_pos.xyz)));
|
vec3 triangle_normal = normalize(cross(dFdx(model_pos.xyz), dFdy(model_pos.xyz)));
|
||||||
#ifdef FLIP_TRIANGLE_NORMALS
|
|
||||||
triangle_normal = -triangle_normal;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec3 transformed_normal = normalize(slope.volume_world_normal_matrix * triangle_normal);
|
|
||||||
if (slope.actived && transformed_normal.z < slope.normal_z - EPSILON) {
|
|
||||||
//color = vec3(0.7, 0.7, 1.0);
|
|
||||||
color = color * 0.5 + ORANGE * 0.5;
|
|
||||||
alpha = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (volume_mirrored)
|
if (volume_mirrored)
|
||||||
|
{
|
||||||
triangle_normal = -triangle_normal;
|
triangle_normal = -triangle_normal;
|
||||||
|
}
|
||||||
|
vec3 transformed_normal = normalize(slope.volume_world_normal_matrix * triangle_normal);
|
||||||
|
|
||||||
|
if (slope.actived) {
|
||||||
|
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||||
|
{
|
||||||
|
color = LightBlue;
|
||||||
|
alpha = 1.0;
|
||||||
|
}
|
||||||
|
else if( transformed_normal.z < slope.normal_z - EPSILON)
|
||||||
|
{
|
||||||
|
color = color * 0.7 + LightRed * 0.3;
|
||||||
|
alpha = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// First transform the normal into camera space and normalize the result.
|
// First transform the normal into camera space and normalize the result.
|
||||||
vec3 eye_normal = normalize(gl_NormalMatrix * triangle_normal);
|
vec3 eye_normal = normalize(gl_NormalMatrix * triangle_normal);
|
||||||
|
@ -13,7 +13,7 @@ uniform vec4 clipping_plane;
|
|||||||
|
|
||||||
varying vec3 clipping_planes_dots;
|
varying vec3 clipping_planes_dots;
|
||||||
varying vec4 model_pos;
|
varying vec4 model_pos;
|
||||||
|
varying vec4 world_pos;
|
||||||
varying vec3 barycentric_coordinates;
|
varying vec3 barycentric_coordinates;
|
||||||
|
|
||||||
struct SlopeDetection
|
struct SlopeDetection
|
||||||
@ -29,7 +29,7 @@ void main()
|
|||||||
model_pos = vec4(v_position, 1.0);
|
model_pos = vec4(v_position, 1.0);
|
||||||
// Point in homogenous coordinates.
|
// Point in homogenous coordinates.
|
||||||
//vec4 world_pos = volume_world_matrix * gl_Vertex;
|
//vec4 world_pos = volume_world_matrix * gl_Vertex;
|
||||||
vec4 world_pos = volume_world_matrix * model_pos;
|
world_pos = volume_world_matrix * model_pos;
|
||||||
|
|
||||||
//gl_Position = ftransform();
|
//gl_Position = ftransform();
|
||||||
gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position.x, v_position.y, v_position.z, 1.0);
|
gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position.x, v_position.y, v_position.z, 1.0);
|
||||||
|
@ -77,13 +77,13 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||||||
//if (GUI::wxGetApp().plater() && GUI::wxGetApp().plater()->is_wireframe_enabled())
|
//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});
|
// valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"}, {"FLIP_TRIANGLE_NORMALS"sv});
|
||||||
//else
|
//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 {
|
else {
|
||||||
//if (GUI::wxGetApp().plater() && GUI::wxGetApp().plater()->is_wireframe_enabled())
|
//if (GUI::wxGetApp().plater() && GUI::wxGetApp().plater()->is_wireframe_enabled())
|
||||||
// valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"});
|
// valid &= append_shader("mm_gouraud", {"mm_gouraud_wireframe.vs", "mm_gouraud_wireframe.fs"});
|
||||||
//else
|
//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
|
//BBS: add shader for outline
|
||||||
|
@ -357,16 +357,16 @@ void GLGizmoMmuSegmentation::show_tooltip_information(float caption_max, float x
|
|||||||
std::vector<std::string> tip_items;
|
std::vector<std::string> tip_items;
|
||||||
switch (m_tool_type) {
|
switch (m_tool_type) {
|
||||||
case ToolType::BRUSH:
|
case ToolType::BRUSH:
|
||||||
tip_items = {"paint", "erase", "cursor_size", "clipping_of_view"};
|
tip_items = {"paint", "erase", "cursor_size", "clipping_of_view", "toggle_wireframe"};
|
||||||
break;
|
break;
|
||||||
case ToolType::BUCKET_FILL:
|
case ToolType::BUCKET_FILL:
|
||||||
tip_items = {"paint", "erase", "smart_fill_angle", "clipping_of_view"};
|
tip_items = {"paint", "erase", "smart_fill_angle", "clipping_of_view", "toggle_wireframe"};
|
||||||
break;
|
break;
|
||||||
case ToolType::SMART_FILL:
|
case ToolType::SMART_FILL:
|
||||||
// TODO:
|
// TODO:
|
||||||
break;
|
break;
|
||||||
case ToolType::GAP_FILL:
|
case ToolType::GAP_FILL:
|
||||||
tip_items = {"gap_area"};
|
tip_items = {"gap_area", "toggle_wireframe"};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1252,6 +1252,12 @@ float TriangleSelectorPatch::gap_area = TriangleSelectorPatch::GapAreaMin;
|
|||||||
|
|
||||||
void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
|
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)
|
if (m_update_render_data)
|
||||||
update_render_data();
|
update_render_data();
|
||||||
|
|
||||||
@ -1262,9 +1268,9 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
|
|||||||
GLint position_id = -1;
|
GLint position_id = -1;
|
||||||
GLint barycentric_id = -1;
|
GLint barycentric_id = -1;
|
||||||
if (wxGetApp().plater()->is_wireframe_enabled()) {
|
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()) {
|
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");
|
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", show_wireframe on");
|
||||||
shader->set_uniform("show_wireframe", true);
|
shader->set_uniform("show_wireframe", true);
|
||||||
}
|
}
|
||||||
@ -1324,7 +1330,7 @@ void TriangleSelectorPatch::update_triangles_per_type()
|
|||||||
patch.triangle_indices.reserve(m_triangles.size() / 3);
|
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) {
|
for (auto& triangle : m_triangles) {
|
||||||
if (!triangle.valid() || triangle.is_split())
|
if (!triangle.valid() || triangle.is_split())
|
||||||
@ -1382,7 +1388,7 @@ void TriangleSelectorPatch::update_triangles_per_patch()
|
|||||||
auto [neighbors, neighbors_propagated] = this->precompute_all_neighbors();
|
auto [neighbors, neighbors_propagated] = this->precompute_all_neighbors();
|
||||||
std::vector<bool> visited(m_triangles.size(), false);
|
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> {
|
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()));
|
assert(facet_idx != -1 && facet_idx < int(m_triangles.size()));
|
||||||
|
@ -7942,7 +7942,7 @@ Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
|||||||
, p(new priv(this, main_frame))
|
, p(new priv(this, main_frame))
|
||||||
{
|
{
|
||||||
// Initialization performed in the private c-tor
|
// Initialization performed in the private c-tor
|
||||||
enable_wireframe(false);
|
enable_wireframe(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plater::Show(bool show)
|
bool Plater::Show(bool show)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user