Merge pull request #289 from storytold/fix/227-shape-effect-points

Effects: effect points on shape layers start at the layer centre (#227)

# Conflicts:
#	crates/ui-egui/src/panels/puppet_tool.rs
#	crates/ui-egui/src/panels/viewer.rs
This commit is contained in:
Brandon Thomas
2026-10-09 09:32:13 -04:00
36 changed files with 684 additions and 154 deletions
+4 -4
View File
@@ -12,7 +12,7 @@ use effectcraft_engine::render::EvalCtx;
use effectcraft_engine::time::Tick;
use egui::{Color32, Pos2, Stroke};
use super::viewer::{ViewerMap, l2c};
use super::viewer::{ViewerMap, fx2c};
use crate::EffectcraftApp;
/// Deformed meshes of a layer's Puppet effect: (mesh uid, mesh, deformed vertices, pins).
@@ -89,7 +89,7 @@ pub fn overlay(app: &EffectcraftApp, ctx: &egui::Context, cid: ItemId, layer: &L
/// rigged, as in After Effects (#284).
pub fn target(ectx: &EvalCtx, layers: &[(&Layer, Overlay)], cpt: [f64; 2], on_art: impl Fn(&Layer) -> bool) -> Option<LayerId> {
let on_mesh = |l: &Layer, ov: &Overlay| {
let Some(inv) = l2c(ectx, l).0.inverse() else { return false };
let Some(inv) = fx2c(ectx, l).inverse() else { return false };
let p = inv.apply(gv2(cpt[0], cpt[1]));
ov.iter().any(|(_, mesh, def, _)| puppet::contains(mesh, def, [p.x, p.y]))
};
@@ -106,7 +106,7 @@ pub fn reveal_pin(app: &mut EffectcraftApp, layer: LayerId, pin: u64) {
}
}
/// Where a pin sits now (layer space): its Position, or (Bend / Starch / Overlap pins) its rest
/// Where a pin sits now (effect space): its Position, or (Bend / Starch / Overlap pins) its rest
/// point carried along by the deformation.
pub fn pin_position(mesh: &Mesh, def: &[[f64; 2]], p: &Pin) -> [f64; 2] {
if p.kind.moves() {
@@ -148,7 +148,7 @@ pub fn draw(
selected: &[u64],
hover: Option<Pos2>,
) -> Vec<PinHit> {
let (m, _) = l2c(ectx, layer);
let m = fx2c(ectx, layer);
let scr = |q: [f64; 2]| {
let c = m.apply(gv2(q[0], q[1]));
map.to_screen([c.x, c.y])