Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
commit
8c4688194a
3 changed files with 31 additions and 14 deletions
|
@ -1679,15 +1679,26 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
}
|
||||
};
|
||||
|
||||
auto extract_move_id = [&seams_ids](size_t id) {
|
||||
for (int i = seams_ids.size() - 1; i >= 0; --i) {
|
||||
if (seams_ids[i] < id + i + 1)
|
||||
return id + (size_t)i + 1;
|
||||
std::vector<size_t> biased_seams_ids(seams_ids.size());
|
||||
for (size_t i = 0; i < seams_ids.size(); ++i) {
|
||||
biased_seams_ids[i] = seams_ids[i] - i - 1;
|
||||
}
|
||||
|
||||
auto extract_move_id = [&biased_seams_ids](size_t id) {
|
||||
size_t new_id = -1;
|
||||
auto it = std::lower_bound(biased_seams_ids.begin(), biased_seams_ids.end(), id);
|
||||
if (it == biased_seams_ids.end())
|
||||
new_id = id + biased_seams_ids.size();
|
||||
else {
|
||||
if (it == biased_seams_ids.begin() && *it < id)
|
||||
new_id = id;
|
||||
else if (it != biased_seams_ids.begin())
|
||||
new_id = id + std::distance(biased_seams_ids.begin(), it);
|
||||
}
|
||||
return id;
|
||||
return (new_id == -1) ? id : new_id;
|
||||
};
|
||||
|
||||
size_t vertex_size_floats = t_buffer.vertices.vertex_size_floats();
|
||||
const size_t vertex_size_floats = t_buffer.vertices.vertex_size_floats();
|
||||
for (const Path& path : t_buffer.paths) {
|
||||
// the two segments of the path sharing the current vertex may belong
|
||||
// to two different vertex buffers
|
||||
|
@ -1696,8 +1707,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
const size_t path_vertices_count = path.vertices_count();
|
||||
const float half_width = 0.5f * path.width;
|
||||
for (size_t j = 1; j < path_vertices_count - 1; ++j) {
|
||||
size_t curr_s_id = path.sub_paths.front().first.s_id + j;
|
||||
size_t move_id = extract_move_id(curr_s_id);
|
||||
const size_t curr_s_id = path.sub_paths.front().first.s_id + j;
|
||||
const size_t move_id = extract_move_id(curr_s_id);
|
||||
const Vec3f& prev = gcode_result.moves[move_id - 1].position;
|
||||
const Vec3f& curr = gcode_result.moves[move_id].position;
|
||||
const Vec3f& next = gcode_result.moves[move_id + 1].position;
|
||||
|
@ -1724,7 +1735,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
float displacement = 0.0f;
|
||||
if (cos_dir > -0.9998477f) {
|
||||
// if the angle between adjacent segments is smaller than 179 degrees
|
||||
Vec3f med_dir = (prev_dir + next_dir).normalized();
|
||||
const Vec3f med_dir = (prev_dir + next_dir).normalized();
|
||||
displacement = half_width * ::tan(::acos(std::clamp(next_dir.dot(med_dir), -1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
|
@ -1735,7 +1746,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
|
||||
if (can_displace) {
|
||||
// displacement to apply to the vertices to match
|
||||
Vec3f displacement_vec = displacement * prev_dir;
|
||||
const Vec3f displacement_vec = displacement * prev_dir;
|
||||
// matches inner corner vertices
|
||||
if (is_right_turn)
|
||||
match_right_vertices(prev_sub_path, next_sub_path, curr_s_id, vertex_size_floats, -displacement_vec);
|
||||
|
@ -1762,9 +1773,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
// smooth toolpaths corners for TBuffers using triangles
|
||||
for (size_t i = 0; i < m_buffers.size(); ++i) {
|
||||
const TBuffer& t_buffer = m_buffers[i];
|
||||
if (t_buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Triangle) {
|
||||
if (t_buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Triangle)
|
||||
smooth_triangle_toolpaths_corners(t_buffer, vertices[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// dismiss, no more needed
|
||||
|
|
|
@ -353,18 +353,24 @@ void GLGizmoCut::update_contours()
|
|||
|
||||
const ModelObject* model_object = wxGetApp().model().objects[selection.get_object_idx()];
|
||||
const int instance_idx = selection.get_instance_idx();
|
||||
std::vector<ObjectID> volumes_idxs = std::vector<ObjectID>(model_object->volumes.size());
|
||||
for (size_t i = 0; i < model_object->volumes.size(); ++i) {
|
||||
volumes_idxs[i] = model_object->volumes[i]->id();
|
||||
}
|
||||
|
||||
if (0.0 < m_cut_z && m_cut_z < m_max_z) {
|
||||
if (m_cut_contours.cut_z != m_cut_z || m_cut_contours.object_id != model_object->id() || m_cut_contours.instance_idx != instance_idx) {
|
||||
if (m_cut_contours.cut_z != m_cut_z || m_cut_contours.object_id != model_object->id() ||
|
||||
m_cut_contours.instance_idx != instance_idx || m_cut_contours.volumes_idxs != volumes_idxs) {
|
||||
m_cut_contours.cut_z = m_cut_z;
|
||||
|
||||
if (m_cut_contours.object_id != model_object->id())
|
||||
if (m_cut_contours.object_id != model_object->id() || m_cut_contours.volumes_idxs != volumes_idxs)
|
||||
m_cut_contours.mesh = model_object->raw_mesh();
|
||||
|
||||
m_cut_contours.position = box.center();
|
||||
m_cut_contours.shift = Vec3d::Zero();
|
||||
m_cut_contours.object_id = model_object->id();
|
||||
m_cut_contours.instance_idx = instance_idx;
|
||||
m_cut_contours.volumes_idxs = volumes_idxs;
|
||||
m_cut_contours.contours.reset();
|
||||
|
||||
MeshSlicingParams slicing_params;
|
||||
|
|
|
@ -37,6 +37,7 @@ class GLGizmoCut : public GLGizmoBase
|
|||
Vec3d shift{ Vec3d::Zero() };
|
||||
ObjectID object_id;
|
||||
int instance_idx{ -1 };
|
||||
std::vector<ObjectID> volumes_idxs;
|
||||
};
|
||||
|
||||
CutContours m_cut_contours;
|
||||
|
|
Loading…
Reference in a new issue