Cut WIP: Make negative volumes a little bit "dipper"
+ Some improvements for Undo/Redo stack
This commit is contained in:
parent
9582a9b478
commit
51e77fd81b
@ -1511,11 +1511,17 @@ ModelObjectPtrs ModelObject::cut(size_t instance, const Vec3d& cut_center, const
|
||||
|
||||
if (!volume->is_model_part()) {
|
||||
if (volume->source.is_connector) {
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper)) {
|
||||
ModelVolume* vol = upper->add_volume(*volume);
|
||||
// make a "hole" dipper
|
||||
vol->set_scaling_factor(Z, 1.1 * vol->get_scaling_factor(Z));
|
||||
}
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower)) {
|
||||
ModelVolume* vol = lower->add_volume(*volume);
|
||||
if (!attributes.has(ModelObjectCutAttribute::CreateDowels))
|
||||
if (attributes.has(ModelObjectCutAttribute::CreateDowels))
|
||||
// make a "hole" dipper
|
||||
vol->set_scaling_factor(Z, 1.2 * vol->get_scaling_factor(Z));
|
||||
else
|
||||
// for lower part change type of connector from NEGATIVE_VOLUME to MODEL_PART if this connector is a plug
|
||||
vol->set_type(ModelVolumeType::MODEL_PART);
|
||||
}
|
||||
|
@ -714,8 +714,7 @@ void GLGizmoCut3D::on_dragging(const UpdateData& data)
|
||||
|
||||
if (m_hover_id == m_group_id) {
|
||||
#if use_grabber_extension
|
||||
Vec3d starting_box_center = m_plane_center;
|
||||
starting_box_center[Z] -= 1.0; // some Margin
|
||||
Vec3d starting_box_center = m_plane_center - Vec3d::UnitZ();// some Margin
|
||||
rotate_vec3d_around_center(starting_box_center, m_rotation_gizmo.get_rotation(), m_plane_center);
|
||||
#else
|
||||
const Vec3d& starting_box_center = m_plane_center;
|
||||
@ -1155,7 +1154,7 @@ void GLGizmoCut3D::render_connectors(bool picking)
|
||||
const ClippingPlane* cp = m_c->object_clipper()->get_clipping_plane();
|
||||
const Vec3d& normal = cp && cp->is_active() ? cp->get_normal() : m_clp_normal;
|
||||
|
||||
const Transform3d instance_trafo = Geometry::assemble_transform(Vec3d(0.0, 0.0, sla_shift), Vec3d::Zero(), Vec3d::Ones(), Vec3d::Ones()) * mi->get_transformation().get_matrix();
|
||||
const Transform3d instance_trafo = Geometry::assemble_transform(Vec3d(0.0, 0.0, sla_shift)) * mi->get_transformation().get_matrix();
|
||||
|
||||
for (size_t i = 0; i < connectors.size(); ++i) {
|
||||
const CutConnector& connector = connectors[i];
|
||||
@ -1268,9 +1267,9 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
||||
if(!mo)
|
||||
return;
|
||||
|
||||
Plater::TakeSnapshot snapshot(plater, _L("Cut by Plane"));
|
||||
|
||||
const bool has_connectors = !mo->cut_connectors.empty();
|
||||
{
|
||||
Plater::TakeSnapshot snapshot(plater, _L("Cut by Plane"));
|
||||
// update connectors pos as offset of its center before cut performing
|
||||
if (has_connectors && m_connector_mode == CutConnectorMode::Manual) {
|
||||
for (CutConnector& connector : mo->cut_connectors) {
|
||||
@ -1282,16 +1281,21 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
||||
}
|
||||
else {
|
||||
// culculate shift of the connector center regarding to the position on the cut plane
|
||||
Vec3d norm = m_grabbers[0].center - m_plane_center;
|
||||
norm.normalize();
|
||||
Vec3d shift = norm * (0.5 * connector.height);
|
||||
connector.pos += shift;
|
||||
#if use_grabber_extension
|
||||
Vec3d shifted_center = m_plane_center + Vec3d::UnitZ();
|
||||
rotate_vec3d_around_center(shifted_center, m_rotation_gizmo.get_rotation(), m_plane_center);
|
||||
Vec3d norm = (shifted_center - m_plane_center).normalized();
|
||||
#else
|
||||
Vec3d norm = (m_grabbers[0].center - m_plane_center).normalize();
|
||||
#endif
|
||||
connector.pos += norm * (0.5 * connector.height);
|
||||
}
|
||||
}
|
||||
mo->apply_cut_connectors(_u8L("Connector"), CutConnectorAttributes(CutConnectorType(m_connector_type), CutConnectorStyle(m_connector_style), CutConnectorShape(m_connector_shape_id)));
|
||||
if (m_connector_type == CutConnectorType::Dowel)
|
||||
create_dowels_as_separate_object = true;
|
||||
}
|
||||
}
|
||||
|
||||
plater->cut(object_idx, instance_idx, cut_center_offset, m_rotation_gizmo.get_rotation(),
|
||||
only_if(has_connectors ? true : m_keep_upper, ModelObjectCutAttribute::KeepUpper) |
|
||||
@ -1421,6 +1425,8 @@ bool GLGizmoCut3D::process_cut_line(SLAGizmoEventType action, const Vec2d& mouse
|
||||
Vec3f camera_dir = camera.get_dir_forward().cast<float>();
|
||||
Vec3f line_dir = (m_line_end - m_line_beg).cast<float>();
|
||||
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Cut by line"), UndoRedo::SnapshotType::GizmoAction);
|
||||
|
||||
Vec3f cross_dir = line_dir.cross(camera_dir).normalized();
|
||||
Eigen::Quaterniond q;
|
||||
Transform3d m = Transform3d::Identity();
|
||||
|
Loading…
Reference in New Issue
Block a user