mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 16:25:56 +08:00
Fix rotation on mirrored objects
This commit is contained in:
parent
5a43a70e16
commit
371a3753f2
@ -246,6 +246,12 @@ bool GLGizmoSVG::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
|
|||||||
angle -= PI / 2; // Grabber is upward
|
angle -= PI / 2; // Grabber is upward
|
||||||
|
|
||||||
double new_angle = angle + *m_rotate_start_angle;
|
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>
|
// move to range <-M_PI, M_PI>
|
||||||
Geometry::to_range_pi_pi(new_angle);
|
Geometry::to_range_pi_pi(new_angle);
|
||||||
|
|
||||||
@ -1947,9 +1953,14 @@ void GLGizmoSVG::draw_mirroring()
|
|||||||
selection.mirror(axis, get_drag_transformation_type(selection));
|
selection.mirror(axis, get_drag_transformation_type(selection));
|
||||||
};
|
};
|
||||||
selection_transform(selection, selection_mirror_fnc, m_volume);
|
selection_transform(selection, selection_mirror_fnc, m_volume);
|
||||||
|
|
||||||
m_parent.do_mirror(L("Set Mirror"));
|
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)
|
if (m_volume_shape.projection.use_surface)
|
||||||
process();
|
process();
|
||||||
|
@ -408,14 +408,14 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
|
|||||||
bool is_mirrored = false;
|
bool is_mirrored = false;
|
||||||
const GLVolume* gl_volume = selection.get_first_volume();
|
const GLVolume* gl_volume = selection.get_first_volume();
|
||||||
if (gl_volume != nullptr) {
|
if (gl_volume != nullptr) {
|
||||||
if (is_embossed_object(selection)) {
|
|
||||||
const ModelInstance *instance = get_model_instance(*gl_volume, selection.get_model()->objects);
|
const ModelInstance *instance = get_model_instance(*gl_volume, selection.get_model()->objects);
|
||||||
if (instance != nullptr)
|
bool is_instance_mirrored = (instance != nullptr)? has_reflection(instance->get_matrix()) : false;
|
||||||
is_mirrored = has_reflection(instance->get_matrix());
|
if (is_embossed_object(selection)) {
|
||||||
|
is_mirrored = is_instance_mirrored;
|
||||||
} else {
|
} else {
|
||||||
const ModelVolume *volume = get_model_volume(*gl_volume, selection.get_model()->objects);
|
const ModelVolume *volume = get_model_volume(*gl_volume, selection.get_model()->objects);
|
||||||
if (volume != nullptr)
|
if (volume != nullptr)
|
||||||
is_mirrored = has_reflection(volume->get_matrix());
|
is_mirrored = is_instance_mirrored != has_reflection(volume->get_matrix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_mirrored)
|
if (is_mirrored)
|
||||||
@ -548,8 +548,11 @@ bool start_dragging(const Vec2d &mouse_pos,
|
|||||||
Transform3d instance_tr_inv = instance_tr.inverse();
|
Transform3d instance_tr_inv = instance_tr.inverse();
|
||||||
Transform3d world_tr = instance_tr * volume_tr;
|
Transform3d world_tr = instance_tr * volume_tr;
|
||||||
std::optional<float> start_angle;
|
std::optional<float> start_angle;
|
||||||
if (up_limit.has_value())
|
if (up_limit.has_value()) {
|
||||||
start_angle = Emboss::calc_up(world_tr, *up_limit);
|
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;
|
std::optional<float> start_distance;
|
||||||
if (!volume->emboss_shape->projection.use_surface)
|
if (!volume->emboss_shape->projection.use_surface)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user