mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 16:59:01 +08:00
Tech ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES - Mirror transform in local system for volumes and a few fixes in rotation
This commit is contained in:
parent
0a238adbab
commit
f69e557e20
@ -930,7 +930,7 @@ void ObjectManipulation::update_mirror_buttons_visibility()
|
||||
std::array<MirrorButtonState, 3> new_states = {mbHidden, mbHidden, mbHidden};
|
||||
|
||||
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
if (!is_world_coordinates()) {
|
||||
if (is_local_coordinates()) {
|
||||
#else
|
||||
if (!m_world_coordinates) {
|
||||
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
|
@ -245,7 +245,11 @@ void GLGizmoRotate::init_data_from_selection(const Selection& selection)
|
||||
else if (coordinates_type == ECoordinatesType::Local && selection.is_single_volume_or_modifier()) {
|
||||
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
m_orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true) * v.get_volume_transformation().get_matrix(true, false, true, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
m_orient_matrix = v.get_instance_transformation().get_matrix(true, false, true, true);
|
||||
}
|
||||
#else
|
||||
if (wxGetApp().obj_manipul()->get_world_coordinates())
|
||||
m_orient_matrix = Transform3d::Identity();
|
||||
|
@ -793,7 +793,7 @@ void Selection::translate(const Vec3d& displacement, bool local)
|
||||
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
else if (type == ECoordinatesType::Local) {
|
||||
const VolumeCache& volume_data = m_cache.volumes_data[i];
|
||||
const Vec3d local_displacement = (volume_data.get_volume_rotation_matrix() * volume_data.get_volume_mirror_matrix()) * displacement;
|
||||
const Vec3d local_displacement = volume_data.get_volume_rotation_matrix() * displacement;
|
||||
v.set_volume_offset(volume_data.get_volume_position() + local_displacement);
|
||||
}
|
||||
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
@ -813,11 +813,13 @@ void Selection::translate(const Vec3d& displacement, bool local)
|
||||
if (is_from_fully_selected_instance(i)) {
|
||||
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
if (type == ECoordinatesType::Local) {
|
||||
const VolumeCache& volume_data = m_cache.volumes_data[i];
|
||||
const Vec3d world_displacement = volume_data.get_instance_rotation_matrix() * displacement;
|
||||
#else
|
||||
if (local) {
|
||||
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
const VolumeCache& volume_data = m_cache.volumes_data[i];
|
||||
const Vec3d world_displacement = (volume_data.get_instance_rotation_matrix() * volume_data.get_instance_mirror_matrix()) * displacement;
|
||||
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
v.set_instance_offset(volume_data.get_instance_position() + world_displacement);
|
||||
}
|
||||
else
|
||||
@ -1439,6 +1441,9 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) const
|
||||
glsafe(::glTranslated(center.x(), center.y(), center.z()));
|
||||
#if ENABLE_WORLD_COORDINATE
|
||||
Transform3d orient_matrix = Transform3d::Identity();
|
||||
#if ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
|
||||
#else
|
||||
if (boost::starts_with(sidebar_field, "position") || boost::starts_with(sidebar_field, "scale"))
|
||||
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
|
||||
else if (boost::starts_with(sidebar_field, "rotation")) {
|
||||
@ -1452,6 +1457,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field) const
|
||||
orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()));
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_INSTANCE_COORDINATES_FOR_VOLUMES
|
||||
|
||||
glsafe(::glMultMatrixd(orient_matrix.data()));
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user