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->is_model_part()) {
|
||||||
if (volume->source.is_connector) {
|
if (volume->source.is_connector) {
|
||||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
if (attributes.has(ModelObjectCutAttribute::KeepUpper)) {
|
||||||
ModelVolume* vol = upper->add_volume(*volume);
|
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)) {
|
if (attributes.has(ModelObjectCutAttribute::KeepLower)) {
|
||||||
ModelVolume* vol = lower->add_volume(*volume);
|
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
|
// 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);
|
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 (m_hover_id == m_group_id) {
|
||||||
#if use_grabber_extension
|
#if use_grabber_extension
|
||||||
Vec3d starting_box_center = m_plane_center;
|
Vec3d starting_box_center = m_plane_center - Vec3d::UnitZ();// some Margin
|
||||||
starting_box_center[Z] -= 1.0; // some Margin
|
|
||||||
rotate_vec3d_around_center(starting_box_center, m_rotation_gizmo.get_rotation(), m_plane_center);
|
rotate_vec3d_around_center(starting_box_center, m_rotation_gizmo.get_rotation(), m_plane_center);
|
||||||
#else
|
#else
|
||||||
const Vec3d& starting_box_center = m_plane_center;
|
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 ClippingPlane* cp = m_c->object_clipper()->get_clipping_plane();
|
||||||
const Vec3d& normal = cp && cp->is_active() ? cp->get_normal() : m_clp_normal;
|
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) {
|
for (size_t i = 0; i < connectors.size(); ++i) {
|
||||||
const CutConnector& connector = connectors[i];
|
const CutConnector& connector = connectors[i];
|
||||||
@ -1268,29 +1267,34 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
|||||||
if(!mo)
|
if(!mo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Plater::TakeSnapshot snapshot(plater, _L("Cut by Plane"));
|
|
||||||
|
|
||||||
const bool has_connectors = !mo->cut_connectors.empty();
|
const bool has_connectors = !mo->cut_connectors.empty();
|
||||||
// update connectors pos as offset of its center before cut performing
|
{
|
||||||
if (has_connectors && m_connector_mode == CutConnectorMode::Manual) {
|
Plater::TakeSnapshot snapshot(plater, _L("Cut by Plane"));
|
||||||
for (CutConnector& connector : mo->cut_connectors) {
|
// update connectors pos as offset of its center before cut performing
|
||||||
connector.rotation = m_rotation_gizmo.get_rotation();
|
if (has_connectors && m_connector_mode == CutConnectorMode::Manual) {
|
||||||
|
for (CutConnector& connector : mo->cut_connectors) {
|
||||||
|
connector.rotation = m_rotation_gizmo.get_rotation();
|
||||||
|
|
||||||
if (m_connector_type == CutConnectorType::Dowel) {
|
if (m_connector_type == CutConnectorType::Dowel) {
|
||||||
if (m_connector_style == size_t(CutConnectorStyle::Prizm))
|
if (m_connector_style == size_t(CutConnectorStyle::Prizm))
|
||||||
connector.height *= 2;
|
connector.height *= 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// culculate shift of the connector center regarding to the position on the cut plane
|
// culculate shift of the connector center regarding to the position on the cut plane
|
||||||
Vec3d norm = m_grabbers[0].center - m_plane_center;
|
#if use_grabber_extension
|
||||||
norm.normalize();
|
Vec3d shifted_center = m_plane_center + Vec3d::UnitZ();
|
||||||
Vec3d shift = norm * (0.5 * connector.height);
|
rotate_vec3d_around_center(shifted_center, m_rotation_gizmo.get_rotation(), m_plane_center);
|
||||||
connector.pos += shift;
|
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;
|
||||||
}
|
}
|
||||||
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(),
|
plater->cut(object_idx, instance_idx, cut_center_offset, m_rotation_gizmo.get_rotation(),
|
||||||
@ -1421,6 +1425,8 @@ bool GLGizmoCut3D::process_cut_line(SLAGizmoEventType action, const Vec2d& mouse
|
|||||||
Vec3f camera_dir = camera.get_dir_forward().cast<float>();
|
Vec3f camera_dir = camera.get_dir_forward().cast<float>();
|
||||||
Vec3f line_dir = (m_line_end - m_line_beg).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();
|
Vec3f cross_dir = line_dir.cross(camera_dir).normalized();
|
||||||
Eigen::Quaterniond q;
|
Eigen::Quaterniond q;
|
||||||
Transform3d m = Transform3d::Identity();
|
Transform3d m = Transform3d::Identity();
|
||||||
|
Loading…
Reference in New Issue
Block a user