mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 08:35:56 +08:00
Fix transformation of embossed full instance
This commit is contained in:
parent
9c04671954
commit
1d89f1ad52
@ -378,16 +378,14 @@ std::string GLGizmoSVG::on_get_name() const { return _u8L("SVG"); }
|
|||||||
|
|
||||||
void GLGizmoSVG::on_render() {
|
void GLGizmoSVG::on_render() {
|
||||||
// no volume selected
|
// no volume selected
|
||||||
|
const Selection &selection = m_parent.get_selection();
|
||||||
if (m_volume == nullptr ||
|
if (m_volume == nullptr ||
|
||||||
get_model_volume(m_volume_id, m_parent.get_selection().get_model()->objects) == nullptr)
|
get_model_volume(m_volume_id, selection.get_model()->objects) == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Selection &selection = m_parent.get_selection();
|
if (!selection.volumes_count() != 1)
|
||||||
if (selection.is_empty()) return;
|
return;
|
||||||
|
|
||||||
// prevent get local coordinate system on multi volumes
|
|
||||||
if (!selection.is_single_volume_or_modifier() &&
|
|
||||||
!selection.is_single_volume_instance()) return;
|
|
||||||
bool is_surface_dragging = m_surface_drag.has_value();
|
bool is_surface_dragging = m_surface_drag.has_value();
|
||||||
bool is_parent_dragging = m_parent.is_mouse_dragging();
|
bool is_parent_dragging = m_parent.is_mouse_dragging();
|
||||||
// Do NOT render rotation grabbers when dragging object
|
// Do NOT render rotation grabbers when dragging object
|
||||||
|
@ -52,6 +52,10 @@ Transform3d get_volume_transformation(
|
|||||||
// initial rotation in Z axis
|
// initial rotation in Z axis
|
||||||
std::optional<float> current_angle = {},
|
std::optional<float> current_angle = {},
|
||||||
const std::optional<double> &up_limit = {});
|
const std::optional<double> &up_limit = {});
|
||||||
|
|
||||||
|
// distinguish between transformation of volume inside object
|
||||||
|
// and object(single full instance with one volume)
|
||||||
|
bool is_embossed_object(const Selection &selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Slic3r::GUI {
|
namespace Slic3r::GUI {
|
||||||
@ -346,7 +350,7 @@ bool face_selected_volume_to_camera(const Camera &camera, GLCanvas3D &canvas, co
|
|||||||
Transform3d new_volume_tr = get_volume_transformation(world_tr, wanted_direction, world_position,
|
Transform3d new_volume_tr = get_volume_transformation(world_tr, wanted_direction, world_position,
|
||||||
fix, instance_tr_inv, current_angle, wanted_up_limit);
|
fix, instance_tr_inv, current_angle, wanted_up_limit);
|
||||||
|
|
||||||
if (canvas.get_selection().is_single_full_object()) {
|
if (is_embossed_object(canvas.get_selection())) {
|
||||||
// transform instance instead of volume
|
// transform instance instead of volume
|
||||||
Transform3d new_instance_tr = instance_tr * new_volume_tr * volume.get_matrix().inverse();
|
Transform3d new_instance_tr = instance_tr * new_volume_tr * volume.get_matrix().inverse();
|
||||||
instance.set_transformation(Geometry::Transformation(new_instance_tr));
|
instance.set_transformation(Geometry::Transformation(new_instance_tr));
|
||||||
@ -379,7 +383,7 @@ 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 (selection.is_single_full_object()) {
|
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)
|
if (instance != nullptr)
|
||||||
is_mirrored = has_reflection(instance->get_matrix());
|
is_mirrored = has_reflection(instance->get_matrix());
|
||||||
@ -392,14 +396,9 @@ void do_local_z_rotate(GLCanvas3D &canvas, double relative_angle)
|
|||||||
if (is_mirrored)
|
if (is_mirrored)
|
||||||
relative_angle *= -1;
|
relative_angle *= -1;
|
||||||
|
|
||||||
|
|
||||||
selection.setup_cache();
|
selection.setup_cache();
|
||||||
|
|
||||||
auto selection_rotate_fnc = [&selection, &relative_angle](){
|
auto selection_rotate_fnc = [&selection, &relative_angle](){
|
||||||
TransformationType transformation_type = selection.is_single_full_object() ?
|
selection.rotate(Vec3d(0., 0., relative_angle), get_drag_transformation_type(selection));
|
||||||
TransformationType::Instance_Relative_Independent:
|
|
||||||
TransformationType::Local_Relative_Independent;
|
|
||||||
selection.rotate(Vec3d(0., 0., relative_angle), transformation_type);
|
|
||||||
};
|
};
|
||||||
selection_transform(selection, selection_rotate_fnc);
|
selection_transform(selection, selection_rotate_fnc);
|
||||||
|
|
||||||
@ -432,8 +431,7 @@ void do_local_z_move(GLCanvas3D &canvas, double relative_move) {
|
|||||||
|
|
||||||
TransformationType get_drag_transformation_type(const Selection &selection)
|
TransformationType get_drag_transformation_type(const Selection &selection)
|
||||||
{
|
{
|
||||||
assert(selection.volumes_count() == 1);
|
return is_embossed_object(selection) ?
|
||||||
return selection.is_single_full_object() ?
|
|
||||||
TransformationType::Instance_Relative_Joint :
|
TransformationType::Instance_Relative_Joint :
|
||||||
TransformationType::Local_Relative_Joint;
|
TransformationType::Local_Relative_Joint;
|
||||||
}
|
}
|
||||||
@ -643,4 +641,10 @@ bool dragging(const Vec2d &mouse_pos,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_embossed_object(const Selection &selection)
|
||||||
|
{
|
||||||
|
assert(selection.volumes_count() == 1);
|
||||||
|
return selection.is_single_full_object() || selection.is_single_full_instance();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user