Effects: effect points on shape layers start at the layer centre (#227)
Shape and text layers have comp-sized effect bounds centred on their origin, but effects measured positions from the origin: a point at its default "layer centre" sat at the comp's bottom-right corner, so Twirl on a centred shape changed nothing and Bulge only its bottom-right quarter. As in After Effects, effects now work in effect space, measured from the top-left of the layer's effect bounds. The renderer moves the layer buffer into effect space for the whole stack (Buf::rebase, CPU and GPU alike) and hands effects everything else in it: masks, other layers' pixels for layer parameters (each in its own effect space, so Set Matte and displacement maps see a whole shape layer), the layer's own frames (layer_input, also what Puppet, Roto Brush and the Layer panel read) and the comp camera (CompScene::rebased). Layer bounds are now right for every effect, so pin_rect and EffectEnv::bounds_origin go and layer_rect serves edge pinning too. Adjustment layers still run on the comp below as it is. effect_bounds / EvalCtx::effect_to_comp replace the repeated "comp size when there is no source" code; the viewer's effect point handles and eyedroppers, Puppet pins, the Layer panel (paint, Roto Brush) and the tracker's Corner Pin output use them. Project schema 2: opening a schema 1 project moves positions held by effects on shape and text layers by half the comp size, so set points keep their place (point parameters with keyframes, Paint paths and clone positions, Puppet seeds and pins, Liquify and Roto Brush strokes). Points still at their default become the layer centre; expression controls, adjustment layers and expressions are left as they are (docs/architecture.md). The disk cache's render version is bumped. Tests: default_effect_points_sit_at_the_centre_of_a_shape_layer and layer_parameters_see_a_whole_shape_layer (render, both fail before), effect_points_on_a_shape_layer (GPU vs CPU), opening_a_schema_1_project_moves_shape_layer_effect_points_into_effect_space (engine), and the effects migration tests. Part of #227 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
52ab38fcff
commit
940bea3ba7
@@ -298,13 +298,36 @@ pub struct CompLight {
|
||||
/// The comp's camera and lights relative to the effect's layer.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub struct CompScene {
|
||||
/// Layer pixels (x, y, z) → layer pixels, homogeneous rows X, Y, W: the comp camera's view
|
||||
/// of the layer brought back into the layer's own pixel grid (identity on the layer plane
|
||||
/// for the default camera).
|
||||
/// Effect-space pixels (x, y, z) → effect-space pixels, homogeneous rows X, Y, W: the comp
|
||||
/// camera's view of the layer brought back into the layer's own pixel grid (identity on the
|
||||
/// layer plane for the default camera).
|
||||
pub camera: Option<[[f64; 4]; 3]>,
|
||||
pub light: Option<CompLight>,
|
||||
}
|
||||
|
||||
impl CompScene {
|
||||
/// The scene measured from `origin` (in its current coordinates, as [`crate::Buf::rebase`]):
|
||||
/// a point `p` becomes `p − origin`.
|
||||
pub fn rebased(mut self, origin: [f64; 2]) -> CompScene {
|
||||
if let Some(c) = &mut self.camera {
|
||||
for row in c.iter_mut() {
|
||||
row[3] += row[0] * origin[0] + row[1] * origin[1];
|
||||
}
|
||||
let w = c[2];
|
||||
for (row, o) in c.iter_mut().zip(origin) {
|
||||
for (v, wv) in row.iter_mut().zip(w) {
|
||||
*v -= o * wv;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(l) = &mut self.light {
|
||||
l.pos[0] -= origin[0];
|
||||
l.pos[1] -= origin[1];
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn sub(a: [f64; 3], b: [f64; 3]) -> [f64; 3] {
|
||||
[a[0] - b[0], a[1] - b[1], a[2] - b[2]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user