ENH:Hide non-bottom brim ears, disable dragging

Jira: STUDIO-8686 8681
Change-Id: Ie32eaeb807b25605d668c16c55ecbacf167a38e3
(cherry picked from commit 6b36c305d86fe8ef37b34b16d960ca90c8a07a5f)
This commit is contained in:
Mack 2024-11-21 21:17:14 +08:00 committed by lane.wei
parent 45dfb816d0
commit 6a12df8afa
2 changed files with 23 additions and 10 deletions

View File

@ -37,7 +37,7 @@ bool GLGizmoBrimEars::on_init()
{
m_new_point_head_diameter = get_brim_default_radius();
m_shortcut_key = WXK_CONTROL_L;
m_desc["head_diameter"] = _L("Head diameter");
@ -99,6 +99,16 @@ void GLGizmoBrimEars::on_render_for_picking()
render_points(selection, true);
}
bool GLGizmoBrimEars::is_use_point(const BrimPoint &point) const
{
const Selection &selection = m_parent.get_selection();
const GLVolume *volume = selection.get_volume(*selection.get_volume_idxs().begin());
Transform3d trsf = volume->get_instance_transformation().get_matrix();
auto world_point = trsf * point.pos.cast<double>();
if (world_point[2] > 0) return false;
return true;
}
void GLGizmoBrimEars::render_points(const Selection &selection, bool picking) const
{
auto editing_cache = m_editing_cache;
@ -126,6 +136,7 @@ void GLGizmoBrimEars::render_points(const Selection &selection, bool picking) co
ColorRGBA render_color;
for (size_t i = 0; i < cache_size; ++i) {
const BrimPoint &brim_point = editing_cache[i].brim_point;
if (!is_use_point(brim_point)) continue;
const bool &point_selected = editing_cache[i].selected;
const bool &hover = editing_cache[i].is_hover;
const bool &error = editing_cache[i].is_error;
@ -457,15 +468,16 @@ void GLGizmoBrimEars::delete_selected_points()
void GLGizmoBrimEars::on_update(const UpdateData &data)
{
if (m_hover_id != -1) {
std::pair<Vec3f, Vec3f> pos_and_normal;
if (!unproject_on_mesh2(data.mouse_pos.cast<double>(), pos_and_normal)) return;
m_editing_cache[m_hover_id].brim_point.pos[0] = pos_and_normal.first.x();
m_editing_cache[m_hover_id].brim_point.pos[1] = pos_and_normal.first.y();
//m_editing_cache[m_hover_id].normal = pos_and_normal.second;
m_editing_cache[m_hover_id].normal = Vec3f(0, 0, 1);
find_single();
}
//Disable moving point
//if (m_hover_id != -1) {
// std::pair<Vec3f, Vec3f> pos_and_normal;
// if (!unproject_on_mesh2(data.mouse_pos.cast<double>(), pos_and_normal)) return;
// m_editing_cache[m_hover_id].brim_point.pos[0] = pos_and_normal.first.x();
// m_editing_cache[m_hover_id].brim_point.pos[1] = pos_and_normal.first.y();
// //m_editing_cache[m_hover_id].normal = pos_and_normal.second;
// m_editing_cache[m_hover_id].normal = Vec3f(0, 0, 1);
// find_single();
//}
}
std::vector<const ConfigOption *> GLGizmoBrimEars::get_config_options(const std::vector<std::string> &keys) const

View File

@ -168,6 +168,7 @@ protected:
float get_brim_default_radius() const;
ExPolygon make_polygon(BrimPoint point, const Geometry::Transformation &trsf);
void find_single();
bool is_use_point(const BrimPoint &point) const;
};
wxDECLARE_EVENT(wxEVT_THREAD_DONE, wxCommandEvent);