Merge pull request #2118 from ChristopherLinnett/fix/issue-2092-camera-focus-crash

fix: bound Classic 3D depth-of-field blur and reject non-finite focus distances (#2092)
This commit is contained in:
BFlat
2026-10-30 05:09:17 +07:00
committed by GitHub
9 changed files with 403 additions and 53 deletions
+3 -2
View File
@@ -10,8 +10,9 @@ use crate::context::{Enc, GpuImage, Params};
/// Blur `src` (an unpadded plane buffer) as `d` says. Returns the padded, blurred image.
pub(crate) fn apply(e: &mut Enc, src: &GpuImage, d: &PlaneDof) -> Option<GpuImage> {
let (w, h) = (src.width + 2 * d.pad, src.height + 2 * d.pad);
if !e.g.fits(w + 1, h) || d.radius.len() != w as usize * h as usize || d.levels.is_empty() {
// Saturating, so an oversized padding is refused by `fits` below instead of wrapping around.
let (w, h) = (src.width.saturating_add(d.pad.saturating_mul(2)), src.height.saturating_add(d.pad.saturating_mul(2)));
if !e.g.fits(w.saturating_add(1), h) || d.radius.len() != w as usize * h as usize || d.levels.is_empty() {
return None;
}
let padded = e.image(w, h);