Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge PR #8087: fix(liquify): include cubic overshoot in source reads

aionggeedeacb36e26
diff --cc crates/algo/src/liquify.rs
index 045e6e583,d22ce795e..ee678d1aa
--- a/crates/algo/src/liquify.rs
+++ b/crates/algo/src/liquify.rs
@@@ -663,8 -653,9 +663,10 @@@ pub fn apply_liquify(src: &Surface, fie
if field.is_identity() || b.is_empty() {
return out;
}
- let maxd = f64::from(field.max_displacement()).ceil() as i32 + 3;
+ // A 1D Catmull-Rom stencil's absolute weights sum to at most 5/4, so the 2D
+ // interpolated displacement can reach 25/16 of the largest nodal displacement.
+ let maxd = ((f64::from(field.max_displacement()) * (25.0 / 16.0)).ceil() as i32).saturating_add(3);
+ let has_freeze = field.freeze.iter().any(|&f| f > 0.0);
let tiles: Vec<Rect> = b.tiles().map(|t| t.rect().intersect(&b)).filter(|r| !r.is_empty() && field.touches(*r)).collect();
let work = |t: &Rect| -> Option<(Rect, Vec<f32>)> {
let w = t.width() as usize;