mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 07:55:55 +08:00
Fix rotation on mirrored objects
This commit is contained in:
parent
5a43a70e16
commit
371a3753f2
@ -246,8 +246,14 @@ bool GLGizmoSVG::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
|
||||
angle -= PI / 2; // Grabber is upward
|
||||
|
||||
double new_angle = angle + *m_rotate_start_angle;
|
||||
|
||||
bool is_volume_mirrored = has_reflection(m_volume->get_matrix());
|
||||
bool is_instance_mirrored = has_reflection(m_parent.get_selection().get_first_volume()->get_instance_transformation().get_matrix());
|
||||
if (is_volume_mirrored != is_instance_mirrored)
|
||||
new_angle = -angle + *m_rotate_start_angle;
|
||||
|
||||
// move to range <-M_PI, M_PI>
|
||||
Geometry::to_range_pi_pi(new_angle);
|
||||
Geometry::to_range_pi_pi(new_angle);
|
||||
|
||||
double z_rotation = m_volume->emboss_shape->fix_3mf_tr.has_value()?
|
||||
(new_angle - m_angle.value_or(0.f)) : // relative angle
|
||||
@ -1885,7 +1891,7 @@ void GLGizmoSVG::draw_rotation()
|
||||
Geometry::to_range_pi_pi(angle_rad);
|
||||
|
||||
double diff_angle = angle_rad - angle;
|
||||
|
||||
|
||||
do_local_z_rotate(m_parent, diff_angle);
|
||||
|
||||
// calc angle after rotation
|
||||
@ -1947,9 +1953,14 @@ void GLGizmoSVG::draw_mirroring()
|
||||
selection.mirror(axis, get_drag_transformation_type(selection));
|
||||
};
|
||||
selection_transform(selection, selection_mirror_fnc, m_volume);
|
||||
|
||||
m_parent.do_mirror(L("Set Mirror"));
|
||||
wxGetApp().obj_manipul()->UpdateAndShow(true);
|
||||
|
||||
// Mirror is ignoring keep up !!
|
||||
if (m_keep_up)
|
||||
m_angle = calc_angle(selection);
|
||||
|
||||
volume_transformation_changed();
|
||||
|
||||
|
||||
if (m_volume_shape.projection.use_surface)
|
||||
process();
|
||||
|
@ -408,15 +408,15 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
|
||||
bool is_mirrored = false;
|
||||
const GLVolume* gl_volume = selection.get_first_volume();
|
||||
if (gl_volume != nullptr) {
|
||||
const ModelInstance *instance = get_model_instance(*gl_volume, selection.get_model()->objects);
|
||||
bool is_instance_mirrored = (instance != nullptr)? has_reflection(instance->get_matrix()) : false;
|
||||
if (is_embossed_object(selection)) {
|
||||
const ModelInstance *instance = get_model_instance(*gl_volume, selection.get_model()->objects);
|
||||
if (instance != nullptr)
|
||||
is_mirrored = has_reflection(instance->get_matrix());
|
||||
is_mirrored = is_instance_mirrored;
|
||||
} else {
|
||||
const ModelVolume *volume = get_model_volume(*gl_volume, selection.get_model()->objects);
|
||||
if (volume != nullptr)
|
||||
is_mirrored = has_reflection(volume->get_matrix());
|
||||
}
|
||||
is_mirrored = is_instance_mirrored != has_reflection(volume->get_matrix());
|
||||
}
|
||||
}
|
||||
if (is_mirrored)
|
||||
relative_angle *= -1;
|
||||
@ -548,8 +548,11 @@ bool start_dragging(const Vec2d &mouse_pos,
|
||||
Transform3d instance_tr_inv = instance_tr.inverse();
|
||||
Transform3d world_tr = instance_tr * volume_tr;
|
||||
std::optional<float> start_angle;
|
||||
if (up_limit.has_value())
|
||||
if (up_limit.has_value()) {
|
||||
start_angle = Emboss::calc_up(world_tr, *up_limit);
|
||||
if (start_angle.has_value() && has_reflection(world_tr))
|
||||
start_angle = -(*start_angle);
|
||||
}
|
||||
|
||||
std::optional<float> start_distance;
|
||||
if (!volume->emboss_shape->projection.use_surface)
|
||||
|
Loading…
x
Reference in New Issue
Block a user