Feat: 1. Vertical and horizontal mode for painting 2. Optimize Camera behavior (#2424)

* fix camera and update locale

* Paint horizontally or vertically
This commit is contained in:
SoftFever 2023-10-15 16:43:52 +08:00 committed by GitHub
parent 53c416b819
commit 388b483774
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 557 additions and 336 deletions

View file

@ -711,6 +711,18 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
ImGui::BBLDragFloat("##gap_area_input", &TriangleSelectorPatch::gap_area, 0.05f, 0.0f, 0.0f, "%.2f");
}
ImGui::Separator();
if(m_imgui->bbl_checkbox(_L("Vertical"), m_vertical_only)){
if(m_vertical_only){
m_horizontal_only = false;
}
}
if(m_imgui->bbl_checkbox(_L("Horizontal"), m_horizontal_only)){
if(m_horizontal_only){
m_vertical_only = false;
}
}
ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.0f, 10.0f));
float get_cur_y = ImGui::GetContentRegionMax().y + ImGui::GetFrameHeight() + y;

View file

@ -25,6 +25,8 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic
// Make sphere and save it into a vertex buffer.
m_vbo_sphere.load_its_flat_shading(its_make_sphere(1., (2*M_PI)/24.));
m_vbo_sphere.finalize_geometry(true);
m_vertical_only = false;
m_horizontal_only = false;
}
void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection)
@ -527,6 +529,7 @@ std::vector<GLGizmoPainterBase::ProjectedHeightRange> GLGizmoPainterBase::get_pr
// concludes that the event was not intended for it, it should return false.
bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down)
{
Vec2d _mouse_position = mouse_position;
if (action == SLAGizmoEventType::MouseWheelUp
|| action == SLAGizmoEventType::MouseWheelDown) {
if (control_down) {
@ -648,7 +651,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
// BBS
if (m_tool_type == ToolType::BRUSH && m_cursor_type == TriangleSelector::CursorType::HEIGHT_RANGE)
{
std::vector<ProjectedHeightRange> projected_height_range_by_mesh = get_projected_height_range(mouse_position, 1., part_volumes, trafo_matrices);
std::vector<ProjectedHeightRange> projected_height_range_by_mesh = get_projected_height_range(_mouse_position, 1., part_volumes, trafo_matrices);
m_last_mouse_click = Vec2d::Zero();
for (int i = 0; i < projected_height_range_by_mesh.size(); i++) {
@ -675,13 +678,20 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
m_triangle_splitting_enabled, m_paint_on_overhangs_only ? m_highlight_by_angle_threshold_deg : 0.f);
m_triangle_selectors[mesh_idx]->request_update_render_data(true);
m_last_mouse_click = mouse_position;
m_last_mouse_click = _mouse_position;
}
return true;
}
std::vector<std::vector<ProjectedMousePosition>> projected_mouse_positions_by_mesh = get_projected_mouse_positions(mouse_position, 1., trafo_matrices);
if (action == SLAGizmoEventType::Dragging && m_tool_type == ToolType::BRUSH ){
if(m_vertical_only)
_mouse_position.x() = m_last_mouse_click.x();
else if(m_horizontal_only)
_mouse_position.y() = m_last_mouse_click.y();
}
std::vector<std::vector<ProjectedMousePosition>> projected_mouse_positions_by_mesh = get_projected_mouse_positions(_mouse_position, 1., trafo_matrices);
m_last_mouse_click = Vec2d::Zero(); // only actual hits should be saved
for (const std::vector<ProjectedMousePosition> &projected_mouse_positions : projected_mouse_positions_by_mesh) {
@ -749,7 +759,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
m_triangle_selectors[mesh_idx]->request_update_render_data(true);
m_last_mouse_click = mouse_position;
m_last_mouse_click = _mouse_position;
}
return true;
@ -787,7 +797,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
}
// Now "click" into all the prepared points and spill paint around them.
update_raycast_cache(mouse_position, camera, trafo_matrices);
update_raycast_cache(_mouse_position, camera, trafo_matrices);
auto seed_fill_unselect_all = [this]() {
for (auto &triangle_selector : m_triangle_selectors) {

View file

@ -304,6 +304,10 @@ protected:
static constexpr float SmartFillAngleMax = 90.f;
static constexpr float SmartFillAngleStep = 1.f;
// Orca: paint behavior enchancement
bool m_vertical_only = false;
bool m_horizontal_only = false;
// It stores the value of the previous mesh_id to which the seed fill was applied.
// It is used to detect when the mouse has moved from one volume to another one.
int m_seed_fill_last_mesh_id = -1;

View file

@ -312,6 +312,9 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
bool b_clp_dist_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
if (slider_clp_dist || b_clp_dist_input) { m_c->object_clipper()->set_position(clp_dist, true); }
ImGui::Separator();
m_imgui->bbl_checkbox(_L("Vertical"), m_vertical_only);
ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.0f, 10.0f));

View file

@ -35,6 +35,7 @@ protected:
std::string get_gizmo_entering_text() const override { return "Entering Seam painting"; }
std::string get_gizmo_leaving_text() const override { return "Leaving Seam painting"; }
std::string get_action_snapshot_name() override { return "Paint-on seam editing"; }
static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero
private:
bool on_init() override;