Skip to content

feat(projection): bezier patch-grid warp — perspective corner-pin, auto-smooth, row/col insert - #287

Merged
BlueJayLouche merged 3 commits into
mainfrom
feat/bezier-warp
Nov 25, 2026
Merged

BlueJayLouche merged 3 commits into
mainfrom
feat/bezier-warp

Conversation

@BlueJayLouche

@BlueJayLouche BlueJayLouche commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

What

Adds a bezier warp to rustjay-projection so any engine app can bend surfaces, not just corner-pin or hand-edit a mesh.

  • BezierWarp: an anchor_cols × anchor_rows cage with cubic handles on every edge; each cell is a Coons patch. tessellate() produces the WarpMesh that WarpStage already draws.
  • WarpMode::Bezier(BezierWarp), handled in WarpStage::from_mode and WarpMode::is_identity.
  • Editing helpers: move_anchor, move_handle, set_cage_subdivisions (2×2 up to 64×64), set_tess, validate (for anything loaded from a file), and surface() so editors can draw the cage curves.
  • Ported from varda's BezierWarp with the same JSON shape, so warp files move between the two.

Perspective

New perspective field (serde default false). When it's on, the cage is evaluated in the projective frame of its four outer corners:

  • A 2×2 cage with straight handles is exactly the CornerPin homography, not a bilinear quad.
  • Dragging an outer corner re-projects the whole cage and keeps its curves.

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 to move_handle.
  • move_anchors(&[(r, c)], d): moves a group of anchors together. A single anchor still behaves like move_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_row invert it.
  • New col_u / row_v fields 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_subdivisions now rebuilds with smooth handles instead of straight ones.

Breaking change

Adding a WarpMode variant breaks exhaustive matches downstream (e.g. KOVVBOJ) when they bump the engine rev. Nothing in this workspace matched it outside warp.rs.

Tests

  • straight_perspective_bezier_is_exact_corner_pin compares to compute_forward_homography within 1e-5, after a corner drag, and after resampling to a 4×3 cage.
  • inserting_rows_and_cols_is_exact_and_removing_undoes_it checks the surface is unchanged within 1e-4, with and without perspective.
  • auto_smooth_keeps_corner_pins_exact_and_mirror_keeps_handles_collinear
  • bezier_warp_mode_round_trips_and_loads_varda_shape covers JSON round-trip and a varda file without perspective loading as bilinear identity.

cargo test -p rustjay-projection --lib warp passes (12 tests). cargo check --workspace passes. Clippy shows no warnings in warp.rs.

First consumer: vidGeo, a standalone live bezier/corner-pin editor that exports warp JSON, XYUV and baked video.

🤖 Generated with Claude Code

BlueJayLouche and others added 2 commits November 18, 2026 21:11
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>
@BlueJayLouche BlueJayLouche changed the title feat(projection): bezier patch-grid warp with perspective corner-pin feat(projection): bezier patch-grid warp — perspective corner-pin, auto-smooth, row/col insert Nov 18, 2026
@BlueJayLouche
BlueJayLouche merged commit 02531c3 into main Nov 25, 2026
2 checks passed
@BlueJayLouche
BlueJayLouche deleted the feat/bezier-warp branch November 25, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant