Fix crop glitch
This commit is contained in:
parent
38baeacd01
commit
c79baf9db6
1 changed files with 38 additions and 13 deletions
|
|
@ -472,27 +472,51 @@ impl Filter for CropFilter {
|
|||
if !within_laser_bounds(&point.position) {
|
||||
let mut either = false;
|
||||
if id > 0 {
|
||||
// previous is _in_ frame. Insert blank _after_ crop
|
||||
let prev_position = points.points[id-1].position;
|
||||
if within_laser_bounds(&prev_position) {
|
||||
either = true;
|
||||
// interpolate with prev
|
||||
let clip = clip_line_to_bounds(&prev_position, &point.position);
|
||||
if let Some((p1, p2)) = clip {
|
||||
new_positions.push(p1);
|
||||
new_positions.push(p2);
|
||||
new_points.push(laser::Point{
|
||||
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) {
|
||||
let next_position = points.points[id+1].position;
|
||||
// if next is _in_ frame. Insert blank _before_ crop
|
||||
if within_laser_bounds(&next_position) {
|
||||
either = true;
|
||||
// interpolate with next
|
||||
let clip = clip_line_to_bounds(&point.position, &next_position);
|
||||
if let Some((p1, p2)) = clip {
|
||||
new_positions.push(p1);
|
||||
new_positions.push(p2);
|
||||
new_points.push(laser::Point{
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
new_positions.push(point.position.clone());
|
||||
new_points.push(*point);
|
||||
// new_positions.push(point.position.clone());
|
||||
}
|
||||
|
||||
for position in new_positions {
|
||||
// let pos: [f32; 2] = position.clone();
|
||||
let new_point = laser::Point {
|
||||
position,
|
||||
.. point.clone()
|
||||
};
|
||||
new_points.push(new_point);
|
||||
}
|
||||
// for position in new_positions {
|
||||
// // let pos: [f32; 2] = position.clone();
|
||||
// let new_point = laser::Point {
|
||||
// position,
|
||||
// .. point.clone()
|
||||
// };
|
||||
// new_points.push(new_point);
|
||||
// }
|
||||
}
|
||||
LaserPoints{
|
||||
points: new_points,
|
||||
|
|
|
|||
Loading…
Reference in a new issue