Fix crop glitch

This commit is contained in:
Ruben van de Ven 2025-11-11 16:57:13 +01:00
parent 38baeacd01
commit c79baf9db6

View file

@ -472,27 +472,51 @@ impl Filter for CropFilter {
if !within_laser_bounds(&point.position) { if !within_laser_bounds(&point.position) {
let mut either = false; let mut either = false;
if id > 0 { if id > 0 {
// previous is _in_ frame. Insert blank _after_ crop
let prev_position = points.points[id-1].position; let prev_position = points.points[id-1].position;
if within_laser_bounds(&prev_position) { if within_laser_bounds(&prev_position) {
either = true; either = true;
// interpolate with prev // interpolate with prev
let clip = clip_line_to_bounds(&prev_position, &point.position); let clip = clip_line_to_bounds(&prev_position, &point.position);
if let Some((p1, p2)) = clip { if let Some((p1, p2)) = clip {
new_positions.push(p1); new_points.push(laser::Point{
new_positions.push(p2); position: p1,
.. point.clone()
});
new_points.push(laser::Point{
position: p2,
.. point.clone()
});
new_points.push(laser::Point{
position: p2,
.. point.blanked()
});
// new_positions.push(p1);
// new_positions.push(p2);
} }
} }
} }
if id < (points.points.len()-1) { if id < (points.points.len()-1) {
let next_position = points.points[id+1].position; let next_position = points.points[id+1].position;
// if next is _in_ frame. Insert blank _before_ crop
if within_laser_bounds(&next_position) { if within_laser_bounds(&next_position) {
either = true; either = true;
// interpolate with next // interpolate with next
let clip = clip_line_to_bounds(&point.position, &next_position); let clip = clip_line_to_bounds(&point.position, &next_position);
if let Some((p1, p2)) = clip { if let Some((p1, p2)) = clip {
new_positions.push(p1); new_points.push(laser::Point{
new_positions.push(p2); position: p1,
.. point.blanked()
});
new_points.push(laser::Point{
position: p1,
.. point.clone()
});
new_points.push(laser::Point{
position: p2,
.. point.clone()
});
} }
} }
} }
@ -502,17 +526,18 @@ impl Filter for CropFilter {
continue; continue;
} }
} else { } else {
new_positions.push(point.position.clone()); new_points.push(*point);
// new_positions.push(point.position.clone());
} }
for position in new_positions { // for position in new_positions {
// let pos: [f32; 2] = position.clone(); // // let pos: [f32; 2] = position.clone();
let new_point = laser::Point { // let new_point = laser::Point {
position, // position,
.. point.clone() // .. point.clone()
}; // };
new_points.push(new_point); // new_points.push(new_point);
} // }
} }
LaserPoints{ LaserPoints{
points: new_points, points: new_points,