ENH:update the camera's horizontal rotation radian
if the camera is already horizontal jira: none Change-Id: I45c88d0c394421e90404c8749192bb4bd7b6543b
This commit is contained in:
parent
473a86435f
commit
9eb08038b6
|
@ -333,6 +333,18 @@ void Camera::rotate_local_with_target(const Vec3d& rotation_rad, Vec3d target)
|
|||
}
|
||||
}
|
||||
|
||||
void Camera::calc_horizontal_rotate_rad(float &rotation_rad) {
|
||||
if (is_looking_front()) {
|
||||
auto right = get_dir_right();
|
||||
auto temp_rotation_rad = acos(right.dot(Vec3d(1, 0, 0)));
|
||||
auto value = Vec3d(1, 0, 0).cross(right);
|
||||
if (value.z() > 0.01) {
|
||||
temp_rotation_rad = -temp_rotation_rad;
|
||||
}
|
||||
rotation_rad = temp_rotation_rad;
|
||||
}
|
||||
}
|
||||
|
||||
// Virtual trackball, rotate around an axis, where the eucledian norm of the axis gives the rotation angle in radians.
|
||||
void Camera::rotate_local_around_target(const Vec3d& rotation_rad)
|
||||
{
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
// BBS rotate the camera on a sphere having center == target
|
||||
void rotate_on_sphere_with_target(double delta_azimut_rad, double delta_zenit_rad, bool apply_limits, Vec3d target);
|
||||
void rotate_local_with_target(const Vec3d& rotation_rad, Vec3d target);
|
||||
|
||||
void calc_horizontal_rotate_rad(float &rotation_rad);
|
||||
// rotate the camera on a sphere having center == m_target and radius == m_distance
|
||||
// using the given variations of spherical coordinates
|
||||
// if apply_limits == true the camera stops rotating when its forward vector is parallel to the world Z axis
|
||||
|
|
|
@ -3569,16 +3569,32 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
{ select_view("bottom"); break; }
|
||||
case '3':
|
||||
case WXK_NUMPAD3: //3 on numpad
|
||||
{ select_view("front"); break; }
|
||||
{
|
||||
select_view("front");
|
||||
m_gizmos.update_paint_base_camera_rotate_rad();
|
||||
break;
|
||||
}
|
||||
case '4':
|
||||
case WXK_NUMPAD4: //4 on numpad
|
||||
{ select_view("rear"); break; }
|
||||
{
|
||||
select_view("rear");
|
||||
m_gizmos.update_paint_base_camera_rotate_rad();
|
||||
break;
|
||||
}
|
||||
case '5':
|
||||
case WXK_NUMPAD5: //5 on numpad
|
||||
{ select_view("left"); break; }
|
||||
{
|
||||
select_view("left");
|
||||
m_gizmos.update_paint_base_camera_rotate_rad();
|
||||
break;
|
||||
}
|
||||
case '6':
|
||||
case WXK_NUMPAD6: //6 on numpad
|
||||
{ select_view("right"); break; }
|
||||
{
|
||||
select_view("right");
|
||||
m_gizmos.update_paint_base_camera_rotate_rad();
|
||||
break;
|
||||
}
|
||||
case '7':
|
||||
case WXK_NUMPAD7: //7 on numpad
|
||||
{ select_plate(); break; }
|
||||
|
|
|
@ -764,6 +764,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_vertical_only) {
|
||||
m_horizontal_only = false;
|
||||
m_is_front_view = true;
|
||||
update_front_view_radian();
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
}
|
||||
|
@ -776,6 +777,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_horizontal_only) {
|
||||
m_vertical_only = false;
|
||||
m_is_front_view = true;
|
||||
update_front_view_radian();
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
}
|
||||
|
@ -785,12 +787,13 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
|||
if (m_is_front_view != is_front_view) {
|
||||
m_is_front_view = is_front_view;
|
||||
if (m_is_front_view) {
|
||||
update_front_view_radian();
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
}
|
||||
m_imgui->disabled_begin(!m_is_front_view);
|
||||
|
||||
if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, 0.f, 360.f, 0, DoubleShowType::DEGREE)) {
|
||||
if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, -180.f, 180.f, 0, DoubleShowType::DEGREE)) {
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
m_imgui->disabled_end();
|
||||
|
|
|
@ -70,6 +70,11 @@ GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_pl
|
|||
return clp_data_out;
|
||||
}
|
||||
|
||||
void GLGizmoPainterBase::update_front_view_radian()
|
||||
{
|
||||
wxGetApp().plater()->get_camera().calc_horizontal_rotate_rad(m_front_view_radian);
|
||||
}
|
||||
|
||||
void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
||||
{
|
||||
auto* shader = wxGetApp().get_shader("gouraud");
|
||||
|
|
|
@ -235,6 +235,7 @@ public:
|
|||
virtual const float get_cursor_height_min() const { return CursorHeightMin; }
|
||||
virtual const float get_cursor_height_max() const { return CursorHeightMax; }
|
||||
virtual const float get_cursor_height_step() const { return CursorHeightStep; }
|
||||
void update_front_view_radian();
|
||||
|
||||
protected:
|
||||
virtual void render_triangles(const Selection& selection) const;
|
||||
|
|
|
@ -332,19 +332,21 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
|||
m_vertical_only = vertical_only;
|
||||
if (m_vertical_only) {
|
||||
m_is_front_view = true;
|
||||
update_front_view_radian();
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
}
|
||||
auto is_front_view = m_is_front_view;
|
||||
m_imgui->bbl_checkbox(_L("View: keep horizontal"), is_front_view);
|
||||
if (m_is_front_view != is_front_view) {
|
||||
if (m_is_front_view != is_front_view){
|
||||
m_is_front_view = is_front_view;
|
||||
if (m_is_front_view) {
|
||||
update_front_view_radian();
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
}
|
||||
m_imgui->disabled_begin(!m_is_front_view);
|
||||
if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, 0.f, 360.f, 0, DoubleShowType::DEGREE)) {
|
||||
if (render_slider_double_input_by_format(slider_input_layout, _u8L("Rotate horizontally"), m_front_view_radian, -180.f, 180.f, 0, DoubleShowType::DEGREE)) {
|
||||
change_camera_view_angle(m_front_view_radian);
|
||||
}
|
||||
m_imgui->disabled_end();
|
||||
|
|
|
@ -607,6 +607,14 @@ void GLGizmosManager::finish_cut_rotation()
|
|||
dynamic_cast<GLGizmoAdvancedCut*>(m_gizmos[Cut].get())->finish_rotation();
|
||||
}
|
||||
|
||||
void GLGizmosManager::update_paint_base_camera_rotate_rad()
|
||||
{
|
||||
if (m_current == MmuSegmentation || m_current == Seam) {
|
||||
auto paint_gizmo = dynamic_cast<GLGizmoPainterBase*>(m_gizmos[m_current].get());
|
||||
paint_gizmo->update_front_view_radian();
|
||||
}
|
||||
}
|
||||
|
||||
Vec3d GLGizmosManager::get_flattening_normal() const
|
||||
{
|
||||
if (!m_enabled || m_gizmos.empty())
|
||||
|
@ -1370,7 +1378,7 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
|||
// BBS
|
||||
else if (m_current == MmuSegmentation) {
|
||||
GLGizmoMmuSegmentation* mmu_seg = dynamic_cast<GLGizmoMmuSegmentation*>(get_current());
|
||||
if (mmu_seg != nullptr) {
|
||||
if (mmu_seg != nullptr && evt.ControlDown() == false) {
|
||||
if (keyCode >= WXK_NUMPAD0 && keyCode <= WXK_NUMPAD9) {
|
||||
keyCode = keyCode- WXK_NUMPAD0+'0';
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ public:
|
|||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void update_paint_base_camera_rotate_rad();
|
||||
Vec3d get_flattening_normal() const;
|
||||
|
||||
void set_flattening_data(const ModelObject* model_object);
|
||||
|
|
Loading…
Reference in New Issue