Repository navigation
feat(projection): bezier patch-grid warp — perspective corner-pin, auto-smooth, row/col insert - #287
Merged
Merged
Conversation
Add `BezierWarp` and `WarpMode::Bezier`: an anchor cage with cubic handles on every edge, each cell a Coons patch, tessellated into a `WarpMesh` for `WarpStage`. Ported from varda with the same JSON shape so warps round-trip. New `perspective` flag (serde default false, so varda files stay bilinear) evaluates the cage in the projective frame of its outer corners: a straight-edged cage is exactly the `CornerPin` homography, and dragging a corner re-projects the cage while keeping its curves. Breaking for downstream exhaustive matches on `WarpMode`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ol insert - `with_auto_smooth`: handles follow a Catmull-Rom baseline as anchors move, keeping manual shaping as an offset; computed in the perspective frame so corner-pins stay exact. `smooth_all` resets to the baseline. - `move_handle(.., mirror)`: keeps the opposite handle collinear. - `move_anchors`: group translate (a single anchor still corner-pins). - `insert_col`/`insert_row`: exact patch split (de Casteljau + Coons iso-curve); `remove_col`/`remove_row` invert it. New `col_u`/`row_v` knots (omitted from JSON when uniform) keep the video mapping fixed. - `set_cage_subdivisions` now rebuilds with smooth handles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a bezier warp to
rustjay-projectionso any engine app can bend surfaces, not just corner-pin or hand-edit a mesh.BezierWarp: ananchor_cols × anchor_rowscage with cubic handles on every edge; each cell is a Coons patch.tessellate()produces theWarpMeshthatWarpStagealready draws.WarpMode::Bezier(BezierWarp), handled inWarpStage::from_modeandWarpMode::is_identity.move_anchor,move_handle,set_cage_subdivisions(2×2 up to 64×64),set_tess,validate(for anything loaded from a file), andsurface()so editors can draw the cage curves.BezierWarpwith the same JSON shape, so warp files move between the two.Perspective
New
perspectivefield (serde defaultfalse). When it's on, the cage is evaluated in the projective frame of its four outer corners:CornerPinhomography, not a bilinear quad.Varda files have no such field, so they load bilinear as before.
BezierWarp::corner_pin(corners, tess)builds a perspective cage.Editing (second commit)
For reshaping larger cages:
with_auto_smooth(|w| ...): after anchor moves, each handle follows a Catmull-Rom baseline and keeps any manual shaping as an offset. The baseline is computed in the perspective frame, so corner-pins stay exact.smooth_all()resets every handle to the baseline.move_handle(.., mirror: bool): keeps the opposite handle collinear (smooth through the anchor). This adds a parameter tomove_handle.move_anchors(&[(r, c)], d): moves a group of anchors together. A single anchor still behaves likemove_anchor, so a perspective corner still corner-pins.insert_col(u)/insert_row(v): an exact patch split (de Casteljau on the edges, plus the Coons iso-curve, which is an exact cubic). The surface and the video mapping don't change.remove_col/remove_rowinvert it.col_u/row_vfields record the source parameter of each grid line, which is what keeps inserts exact. They're omitted from JSON when evenly spaced, so varda can still read the files.set_cage_subdivisionsnow rebuilds with smooth handles instead of straight ones.Breaking change
Adding a
WarpModevariant breaks exhaustivematches downstream (e.g. KOVVBOJ) when they bump the engine rev. Nothing in this workspace matched it outsidewarp.rs.Tests
straight_perspective_bezier_is_exact_corner_pincompares tocompute_forward_homographywithin 1e-5, after a corner drag, and after resampling to a 4×3 cage.inserting_rows_and_cols_is_exact_and_removing_undoes_itchecks the surface is unchanged within 1e-4, with and without perspective.auto_smooth_keeps_corner_pins_exact_and_mirror_keeps_handles_collinearbezier_warp_mode_round_trips_and_loads_varda_shapecovers JSON round-trip and a varda file withoutperspectiveloading as bilinear identity.cargo test -p rustjay-projection --lib warppasses (12 tests).cargo check --workspacepasses. Clippy shows no warnings inwarp.rs.First consumer: vidGeo, a standalone live bezier/corner-pin editor that exports warp JSON, XYUV and baked video.
🤖 Generated with Claude Code