Skip to content

Commit b675e40

Browse files
committed
Fix migrations
1 parent 00dc5d4 commit b675e40

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

editor/src/messages/portfolio/document_migration.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,16 +1669,15 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
16691669
// The old version would zip the source and target table rows, interpoleating each pair together.
16701670
// The migrated version will instead deeply flatten both merged tables and morph sequentially between all source vectors and all target vector elements.
16711671
// This migration assumes most usages didn't involve multiple parallel vector elements, and instead morphed from a single source to a single target vector element.
1672-
// The new v3 signature has 5 inputs, so 3 or 4 inputs can only be old v1 versions.
16731672
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::morph::IDENTIFIER) && (inputs_count == 3 || inputs_count == 4) {
16741673
// 3 inputs - old signature (#3405):
16751674
// async fn morph(_: impl Ctx, source: Table<Vector>, #[expose] target: Table<Vector>, #[default(0.5)] time: Fraction) -> Table<Vector> { ... }
16761675
//
16771676
// 4 inputs - even older signature (commit 80b8df8d4298b6669f124b929ce61bfabfc44e41):
16781677
// async fn morph(_: impl Ctx, source: Table<Vector>, #[expose] target: Table<Vector>, #[default(0.5)] time: Fraction, #[min(0.)] start_index: IntegerCount) -> Table<Vector> { ... }
16791678
//
1680-
// New signature:
1681-
// async fn morph<I: IntoGraphicTable>(_: impl Ctx, content: I, progression: Progression, reverse: bool, distribution: InterpolationDistribution, path: Table<Vector>) -> Table<Vector> { ... }
1679+
// v2 signature:
1680+
// async fn morph<I: IntoGraphicTable>(_: impl Ctx, #[implementations(Table<Graphic>, Table<Vector>)] content: I, progression: Progression) -> Table<Vector> { ... }
16821681

16831682
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
16841683
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
@@ -1714,19 +1713,19 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
17141713
// Connect the old 'progression' input to the new 'progression' input of the Morph node
17151714
document.network_interface.set_input(&InputConnector::node(*node_id, 1), old_inputs[2].clone(), network_path);
17161715

1717-
inputs_count = 3;
1716+
inputs_count = 2;
17181717
}
17191718

17201719
// Migrate from the v2 "Morph" node (2 inputs: content, progression) to the v3 "Morph" node (5 inputs: content, progression, reverse, distribution, path).
17211720
// The old progression used integer part for pair selection (range 0..N-1 where N is the number of content objects).
17221721
// The new progression uses fractional 0..1 for euclidean traversal through all objects.
1723-
// We insert Count Elements → Subtract 1 → Divide to remap: new_progression = old_progression / max(N - 1, 1).
1722+
// We insert Count Elements → Subtract 1 → Divide to remap: new_progression = old_progression / (N - 1).
17241723
// For the common 2-object case (N=2), this divides by 1 which is a no-op, preserving identical behavior.
17251724
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::morph::IDENTIFIER) && inputs_count == 2 {
17261725
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
17271726
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
17281727

1729-
// Reconnect content (input 0) and leave path (input 2) as default
1728+
// Reconnect content (input 0) and leave path (input 4) as default
17301729
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
17311730

17321731
let Some(morph_position) = document.network_interface.position_from_downstream_node(node_id, network_path) else {

0 commit comments

Comments
 (0)