Motion tweens: implement Group + Convert to Movie Clip for DCEL geometry

Both actions were DCEL-stubs (no-ops). They now extract the selected geometry from a
vector layer's active keyframe into a new VectorClip (group vs movie clip) and place a
ClipInstance in its place (identity transform → renders where the geometry was), which
the existing transform-animation system can motion-tween.

- Shared `clip_from_geometry::extract_geometry_to_clip` (+ undo) does the work; the
  actions are thin wrappers. Undo snapshots the source graph + removes the clip/instance.
- `extract_subgraph` now DERIVES shared-fill boundary edges internally (an inside edge
  still used by a non-extracted fill must be duplicated, not moved) and unions them with
  the caller's `explicit_boundary` — so a plain geometry selection needs no boundary
  analysis (the selection already includes fill boundary edges via `select_fill`). The
  region-select caller keeps passing its lasso boundary.
- Handlers: Group / Convert to Movie Clip on a geometry selection now build these actions
  from `selected_fills`/`selected_edges`.

Next: shape tweens (same-topology lerp).
This commit is contained in:
Skyler Lehmkuhl
2026-06-21 09:12:46 -04:00
parent 0914818808
commit 0d253d9629
6 changed files with 211 additions and 97 deletions
@@ -3471,26 +3471,24 @@ impl EditorApp {
self.pending_node_group = true;
}
_ => {
// Existing clip instance grouping fallback (stub)
// Group selected geometry into a group clip + clip instance.
if let Some(layer_id) = self.active_layer_id {
if self.selection.has_geometry_selection() {
// TODO: DCEL group deferred to Phase 2
} else {
let clip_ids: Vec<uuid::Uuid> = self.selection.clip_instances().to_vec();
if clip_ids.len() >= 2 {
let instance_id = uuid::Uuid::new_v4();
let action = lightningbeam_core::actions::GroupAction::new(
layer_id, self.playback_time, Vec::new(), clip_ids, instance_id,
);
if let Err(e) = self.action_executor.execute(Box::new(action)) {
eprintln!("Failed to group: {}", e);
} else {
self.selection.clear();
self.selection.add_clip_instance(instance_id);
}
let fills: Vec<_> = self.selection.selected_fills().iter().copied().collect();
let edges: Vec<_> = self.selection.selected_edges().iter().copied().collect();
let clip_id = uuid::Uuid::new_v4();
let instance_id = uuid::Uuid::new_v4();
let action = lightningbeam_core::actions::GroupAction::new(
layer_id, self.playback_time, fills, edges, clip_id, instance_id,
);
if let Err(e) = self.action_executor.execute(Box::new(action)) {
eprintln!("Failed to group: {}", e);
} else {
self.selection.clear();
self.selection.add_clip_instance(instance_id);
}
}
let _ = layer_id;
// (Grouping existing clip instances is a separate op, not wired.)
}
}
}
@@ -3498,24 +3496,18 @@ impl EditorApp {
MenuAction::ConvertToMovieClip => {
if let Some(layer_id) = self.active_layer_id {
if self.selection.has_geometry_selection() {
// TODO: DCEL convert-to-movie-clip deferred to Phase 2
} else {
let clip_ids: Vec<uuid::Uuid> = self.selection.clip_instances().to_vec();
if clip_ids.len() >= 1 {
let instance_id = uuid::Uuid::new_v4();
let action = lightningbeam_core::actions::ConvertToMovieClipAction::new(
layer_id,
self.playback_time,
Vec::new(),
clip_ids,
instance_id,
);
if let Err(e) = self.action_executor.execute(Box::new(action)) {
eprintln!("Failed to convert to movie clip: {}", e);
} else {
self.selection.clear();
self.selection.add_clip_instance(instance_id);
}
let fills: Vec<_> = self.selection.selected_fills().iter().copied().collect();
let edges: Vec<_> = self.selection.selected_edges().iter().copied().collect();
let clip_id = uuid::Uuid::new_v4();
let instance_id = uuid::Uuid::new_v4();
let action = lightningbeam_core::actions::ConvertToMovieClipAction::new(
layer_id, self.playback_time, fills, edges, clip_id, instance_id,
);
if let Err(e) = self.action_executor.execute(Box::new(action)) {
eprintln!("Failed to convert to movie clip: {}", e);
} else {
self.selection.clear();
self.selection.add_clip_instance(instance_id);
}
}
}