mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 06:04:01 -06:00
Tech ENABLE_SINKING_CONTOURS -> 1st installment
This commit is contained in:
parent
be9114c6c8
commit
22f04ca46e
7 changed files with 286 additions and 27 deletions
|
@ -676,6 +676,9 @@ void Selection::translate(const Vec3d& displacement, bool local)
|
|||
translation_type = Volume;
|
||||
}
|
||||
}
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
v.update_sinking_contours();
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
}
|
||||
|
||||
#if !DISABLE_INSTANCES_SYNCH
|
||||
|
@ -701,15 +704,18 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||
int rot_axis_max = 0;
|
||||
if (rotation.isApprox(Vec3d::Zero())) {
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume &volume = *(*m_volumes)[i];
|
||||
GLVolume &v = *(*m_volumes)[i];
|
||||
if (m_mode == Instance) {
|
||||
volume.set_instance_rotation(m_cache.volumes_data[i].get_instance_rotation());
|
||||
volume.set_instance_offset(m_cache.volumes_data[i].get_instance_position());
|
||||
v.set_instance_rotation(m_cache.volumes_data[i].get_instance_rotation());
|
||||
v.set_instance_offset(m_cache.volumes_data[i].get_instance_position());
|
||||
}
|
||||
else if (m_mode == Volume) {
|
||||
volume.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation());
|
||||
volume.set_volume_offset(m_cache.volumes_data[i].get_volume_position());
|
||||
v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation());
|
||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position());
|
||||
}
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
v.update_sinking_contours();
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
}
|
||||
}
|
||||
else { // this is not the wipe tower
|
||||
|
@ -749,22 +755,22 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||
};
|
||||
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume &volume = *(*m_volumes)[i];
|
||||
GLVolume &v = *(*m_volumes)[i];
|
||||
if (is_single_full_instance())
|
||||
rotate_instance(volume, i);
|
||||
rotate_instance(v, i);
|
||||
else if (is_single_volume() || is_single_modifier()) {
|
||||
if (transformation_type.independent())
|
||||
volume.set_volume_rotation(volume.get_volume_rotation() + rotation);
|
||||
v.set_volume_rotation(v.get_volume_rotation() + rotation);
|
||||
else {
|
||||
const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
|
||||
const Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix());
|
||||
volume.set_volume_rotation(new_rotation);
|
||||
v.set_volume_rotation(new_rotation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_mode == Instance)
|
||||
rotate_instance(volume, i);
|
||||
rotate_instance(v, i);
|
||||
else if (m_mode == Volume) {
|
||||
// extracts rotations from the composed transformation
|
||||
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation);
|
||||
|
@ -772,11 +778,14 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||
if (transformation_type.joint()) {
|
||||
const Vec3d local_pivot = m_cache.volumes_data[i].get_instance_full_matrix().inverse() * m_cache.dragging_center;
|
||||
const Vec3d offset = m * (m_cache.volumes_data[i].get_volume_position() - local_pivot);
|
||||
volume.set_volume_offset(local_pivot + offset);
|
||||
v.set_volume_offset(local_pivot + offset);
|
||||
}
|
||||
volume.set_volume_rotation(new_rotation);
|
||||
v.set_volume_rotation(new_rotation);
|
||||
}
|
||||
}
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
v.update_sinking_contours();
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -821,6 +830,9 @@ void Selection::flattening_rotate(const Vec3d& normal)
|
|||
// Additional rotation to align tnormal with the down vector in the world coordinate space.
|
||||
auto extra_rotation = Eigen::Quaterniond().setFromTwoVectors(tnormal, - Vec3d::UnitZ());
|
||||
v.set_instance_rotation(Geometry::extract_euler_angles(extra_rotation.toRotationMatrix() * m_cache.volumes_data[i].get_instance_rotation_matrix()));
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
v.update_sinking_contours();
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
}
|
||||
|
||||
#if !DISABLE_INSTANCES_SYNCH
|
||||
|
@ -846,12 +858,12 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume &volume = *(*m_volumes)[i];
|
||||
GLVolume &v = *(*m_volumes)[i];
|
||||
#if ENABLE_ALLOW_NEGATIVE_Z
|
||||
#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
if (!is_sla)
|
||||
#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA
|
||||
is_any_volume_sinking |= !volume.is_modifier && std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end();
|
||||
is_any_volume_sinking |= !v.is_modifier && std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end();
|
||||
#endif // ENABLE_ALLOW_NEGATIVE_Z
|
||||
if (is_single_full_instance()) {
|
||||
if (transformation_type.relative()) {
|
||||
|
@ -860,23 +872,23 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
// extracts scaling factors from the composed transformation
|
||||
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
|
||||
if (transformation_type.joint())
|
||||
volume.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||
v.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||
|
||||
volume.set_instance_scaling_factor(new_scale);
|
||||
v.set_instance_scaling_factor(new_scale);
|
||||
}
|
||||
else {
|
||||
if (transformation_type.world() && (std::abs(scale.x() - scale.y()) > EPSILON || std::abs(scale.x() - scale.z()) > EPSILON)) {
|
||||
// Non-uniform scaling. Transform the scaling factors into the local coordinate system.
|
||||
// This is only possible, if the instance rotation is mulitples of ninety degrees.
|
||||
assert(Geometry::is_rotation_ninety_degrees(volume.get_instance_rotation()));
|
||||
volume.set_instance_scaling_factor((volume.get_instance_transformation().get_matrix(true, false, true, true).matrix().block<3, 3>(0, 0).transpose() * scale).cwiseAbs());
|
||||
assert(Geometry::is_rotation_ninety_degrees(v.get_instance_rotation()));
|
||||
v.set_instance_scaling_factor((v.get_instance_transformation().get_matrix(true, false, true, true).matrix().block<3, 3>(0, 0).transpose() * scale).cwiseAbs());
|
||||
}
|
||||
else
|
||||
volume.set_instance_scaling_factor(scale);
|
||||
v.set_instance_scaling_factor(scale);
|
||||
}
|
||||
}
|
||||
else if (is_single_volume() || is_single_modifier())
|
||||
volume.set_volume_scaling_factor(scale);
|
||||
v.set_volume_scaling_factor(scale);
|
||||
else {
|
||||
Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale);
|
||||
if (m_mode == Instance) {
|
||||
|
@ -884,9 +896,9 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
// extracts scaling factors from the composed transformation
|
||||
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
|
||||
if (transformation_type.joint())
|
||||
volume.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||
v.set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||
|
||||
volume.set_instance_scaling_factor(new_scale);
|
||||
v.set_instance_scaling_factor(new_scale);
|
||||
}
|
||||
else if (m_mode == Volume) {
|
||||
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> new_matrix = (m * m_cache.volumes_data[i].get_volume_scale_matrix()).matrix().block(0, 0, 3, 3);
|
||||
|
@ -894,11 +906,14 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type
|
|||
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
|
||||
if (transformation_type.joint()) {
|
||||
Vec3d offset = m * (m_cache.volumes_data[i].get_volume_position() + m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center);
|
||||
volume.set_volume_offset(m_cache.dragging_center - m_cache.volumes_data[i].get_instance_position() + offset);
|
||||
v.set_volume_offset(m_cache.dragging_center - m_cache.volumes_data[i].get_instance_position() + offset);
|
||||
}
|
||||
volume.set_volume_scaling_factor(new_scale);
|
||||
v.set_volume_scaling_factor(new_scale);
|
||||
}
|
||||
}
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
v.update_sinking_contours();
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
}
|
||||
|
||||
#if !DISABLE_INSTANCES_SYNCH
|
||||
|
@ -972,6 +987,9 @@ void Selection::mirror(Axis axis)
|
|||
v.set_instance_mirror(axis, -(*m_volumes)[i]->get_instance_mirror(axis));
|
||||
else if (m_mode == Volume)
|
||||
v.set_volume_mirror(axis, -(*m_volumes)[i]->get_volume_mirror(axis));
|
||||
#if ENABLE_SINKING_CONTOURS
|
||||
v.update_sinking_contours();
|
||||
#endif // ENABLE_SINKING_CONTOURS
|
||||
}
|
||||
|
||||
#if !DISABLE_INSTANCES_SYNCH
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue