Merge main into M7 3D branch

Resolve conflicts with perf (layer cache / Arc<Buf>), export (RenderOpts.view: None
for output), timeline (separate dimensions + one-node POI visibility), mask/pen
viewer gestures (alongside camera tools and view-aware layer matrices), key
dialogs (alongside Camera/Light Settings), render queue + MCP command modules.
3D path tangent honours separated position; DOF blurs a per-frame copy so cached
layer buffers stay shared. New test: cached renders match uncached after camera,
focus, light and 3D view changes. Fix a clone-on-copy lint from main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-01 23:24:08 -04:00
co-authored by Claude Opus 5.5
128 changed files with 23915 additions and 686 deletions
+3 -2
View File
@@ -208,8 +208,9 @@ pub fn rig_rotation(ctx: &EvalCtx, layer: &Layer) -> Mat4 {
/// Direction of travel of a layer's position (parent space) at the context time.
fn path_tangent(ctx: &EvalCtx, layer: &Layer) -> Option<Vec3> {
let tr = layer.transform()?;
let p = tr.get("position")?;
if p.keys.len() < 2 && !p.has_expression() {
// Position (or its separated X/Y/Z dimensions) must be animated.
let moving = ["position", "positionX", "positionY", "positionZ"].iter().any(|m| tr.get(m).is_some_and(|p| p.keys.len() > 1 || p.has_expression()));
if !moving {
return None;
}
let dt = effectcraft_time::Tick::from_seconds_f64(0.005);
+9 -3
View File
@@ -13,6 +13,8 @@
//! alpha-shaped and coloured shadows through Light Transmission); Shadow Diffusion softens them
//! with a penumbra that grows with the distance between caster and receiver.
use std::sync::Arc;
use effectcraft_color::{BlendMode, blend_pixel};
use effectcraft_effects::Buf;
use effectcraft_geom::{Mat3, Mat4, Vec3, vec3};
@@ -44,7 +46,7 @@ pub(crate) struct Item<'a> {
pub layer: &'a Layer,
/// Position in the layer stack (higher = above).
order: usize,
buf: Buf,
buf: Arc<Buf>,
bicubic: bool,
geos: Vec<Geo>,
mat: Material,
@@ -181,8 +183,12 @@ pub(crate) fn prepare<'a>(r: &Renderer, ctx: &EvalCtx<'a>, layer: &'a Layer, ord
let sigma = radius / 1.5;
let pad = (sigma * 3.0).ceil() as u32 + 1;
let padded = buf.img.padded(pad);
buf.img = effectcraft_raster::gaussian_blur(&padded, sigma, sigma, false);
buf.offset = [buf.offset[0] + pad as f64, buf.offset[1] + pad as f64];
// The (cached, shared) layer buffer stays untouched; the blurred copy is per frame.
buf = Arc::new(Buf {
img: effectcraft_raster::gaussian_blur(&padded, sigma, sigma, false),
offset: [buf.offset[0] + pad as f64, buf.offset[1] + pad as f64],
scale: buf.scale,
});
}
}
let n = if in_run { mb_samples(r, ctx, layer) } else { 1 };
+42
View File
@@ -86,3 +86,45 @@ fn camera_parented_to_towards_camera_layer_does_not_recurse() {
c.layers.push(l);
let _ = crate::render_frame(&p, cid, Tick::ZERO, 0.5);
}
/// The layer cache holds layer pixels only; camera, lights, DOF and the view override act at
/// compositing time, so cached renders must match uncached ones after any of them change.
#[test]
fn layer_cache_is_independent_of_camera_lights_and_view() {
let (mut p, cid, comp) = setup();
let mut cam = build::layer(&mut p, &comp, "Camera", LayerSource::Camera, (200, 100), None);
cam.props.prop_mut("cameraOptions/dof").unwrap().value = Value::Bool(true);
cam.props.prop_mut("cameraOptions/aperture").unwrap().value = Value::Scalar(40.0);
let light = build::layer(&mut p, &comp, "Light", LayerSource::Light { kind: effectcraft_project::LightKind::Point }, (200, 100), None);
let a = solid(&mut p, &comp, true, [80.0, 50.0, 0.0]);
let b = solid(&mut p, &comp, true, [120.0, 50.0, 150.0]);
let c = p.comp_mut(cid).unwrap();
c.layers.extend([cam, light, a, b]);
let cache = crate::LayerCache::new(64 << 20);
let render = |p: &Project, cached: bool, view: Option<super::CameraState>| {
let opts = crate::RenderOpts { view, motion_blur: false, ..Default::default() };
let mut r = crate::Renderer::new(p, &crate::NoFootage, opts);
if cached {
r.cache = Some(&cache);
}
r.comp_frame(cid, Tick::ZERO)
};
let check = |p: &Project, view: Option<super::CameraState>| {
let warm = render(p, true, view);
assert_eq!(render(p, true, view), warm);
assert_eq!(render(p, false, view), warm, "cached render differs from uncached");
warm
};
let first = check(&p, None);
// Move the camera, refocus, change the light: cached pixels must follow.
let c = p.comp_mut(cid).unwrap();
c.layers[0].props.prop_mut("transform/position").unwrap().value = Value::Vec3([40.0, 20.0, -250.0]);
c.layers[0].props.prop_mut("cameraOptions/focusDistance").unwrap().value = Value::Scalar(400.0);
c.layers[1].props.prop_mut("lightOptions/intensity").unwrap().value = Value::Scalar(40.0);
let second = check(&p, None);
assert_ne!(first, second, "camera/light changes re-render");
let top = super::default_view_cam(super::View3D::Top, 200.0, 100.0).state();
let third = check(&p, Some(top));
assert_ne!(third, second);
assert!(cache.stats().hits > 0, "the cache was actually used");
}