Files
effectcraft/crates
b325b99f0f Puppet: a mesh that spreads a pin's pull and keeps its area (#2866) (#3066)
* Puppet: a mesh that spreads a pin's pull and keeps its area (#2866)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Puppet: adding a pin and solving agree on what the pin holds (#2866)

`puppet.addPin` chose a new pin's position by whether the click was on the deformed mesh, while the solve
chooses what the pin holds by whether its rest point is on the rest mesh. On a turned mesh a click just
off the outline unmaps to a rest point on the mesh: the pin held that point, but at the click, which
pulled the mesh over (6 px at a third of a turn).

Both now use `puppet::held_point`, and a pin that holds a point goes where that point is now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Tests: the off-mesh pin test checks a pin was added (#2866)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Puppet: a solve that fits a frame, shared by drawing and the overlay (#2866)

The solve was redone for the overlay after drawing, ran every refinement round however little they
moved, and built a fresh banded factor for each of up to five sets of stiffened weights, with room
for one of 320 MB.

- A round that moves no vertex 1e-4 px ends the refinement. On the far drags, the push, the cross
  and the S curve that changes no vertex by 1e-4 px, at 40 rounds or 200.
- Stiffened weights refactor into the same storage in the same order, and the factor's inner loops
  run over slices (same sums in the same order, so the same numbers).
- The factor is capped at 8 million values (64 MB). The densest mesh the tool builds (a target of
  20,000 triangles) needs 4.7 million; past the cap conjugate gradients solve the same system.
- Drawing and the overlay (`puppet.info`, adding a pin, the Puppet tools) share one cached solve.

On a 1280x720 solid with a far drag: 20,000 triangles 15.3 s to about 2.7 s, 10,000 2.2 s to about
0.8 s; with the pins at rest, 5.4 s to about 1 s.

The module doc now describes point pins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Tests: pin edge cases, the refinement mapping and smoothing (#2866)

- Mesh Rotation Refinement to rounds: the default (40), 0, negative, past the maximum, NaN and
  infinities.
- A pin on a vertex holds that vertex; one on an edge between two triangles holds the same point
  through either; one off the outline by round-off holds the point on it, and one further off its
  nearest vertex at the same offset; a Bend pin alone keeps its vertex in place.
- Smoothing falls back to the solve when the vertices don't match the mesh or no split is worth it,
  and every small triangle lies in the triangle its `parent` names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Puppet: the drawing keeps pins on their points and overlapping sheets apart (#2866)

- Smoothing bent the drawn mesh away from the points pins hold inside triangles: on the far drags
  and the S curve the image under a pin landed up to 10 px from it. The vertex gradients the
  smoothing uses now take the least change that puts each held point where the solve did (a few
  sweeps for pins sharing a vertex); edges still depend only on their two vertices, so no cracks.
- A 2x2 sample cell shared by two overlapping sheets coloured all its samples with the first
  sheet's read. A sheet whose source disagrees with the first's by more than 2 px now reads its own
  colour at its own first sample, weighted by its own samples; one sheet's cells read as before.
- The solver comparisons check both solves are the same length and finite before measuring how far
  apart they are (`f64::max` skips a NaN).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Puppet: held pins stay on their points together, and a narrow sheet in a pixel keeps its colour (#2866)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Puppet: the solve follows pins smoothly past what the mesh can give (#2866)

Stiffening triangles from the last solve's shape swung from pass to pass when
pins asked for more than the mesh could give, so half a pixel of drag moved
it hundreds of pixels. The stage is removed; the stress tests' limits are
set to what the solve now gives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* #2866: bound the Puppet solver's pin system and keep saved rigs' look

The drawing's hold on pinned points solved one dense system over every
held pin: n x (n + 2) values and O(n^3) elimination per render, with n
uncapped. Points only meet through shared mesh vertices, so the system
now splits into groups of linked points; a group of up to 128 points is
solved exactly as before, a larger one by 32 passes of cyclic
projection, so memory and work grow linearly with the pin count.

Rigs saved before this change keep their look: a hidden Solver Version
parameter defaults to the current solve for new instances, and
migrate::legacy_default gives instances saved without it the first
solve, which renders through puppet/legacy.rs (main's solve and
drawing, bit-identical on four test rigs). The overlay and addPin's
placement follow the rig's version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: FredApps <[email protected]>
2026-12-01 11:27:25 +01:00
..