Skip to content

Commit a9ba88a

Browse files
committed
Return crash during migration
1 parent cf271df commit a9ba88a

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

editor/src/messages/portfolio/document_migration.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,18 +1634,18 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
16341634

16351635
// TODO: Also add this for "Animation Time"
16361636

1637-
// // Upgrade the "Instance Position" node to add the "Loop Level" input
1638-
// if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector_nodes::instance::instance_position::IDENTIFIER) && inputs_count < 2 {
1639-
// let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
1640-
// document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
1641-
1642-
// document
1643-
// .network_interface
1644-
// .set_input(&InputConnector::node(*node_id, 0), NodeInput::value(TaggedValue::None, false), network_path);
1645-
// document
1646-
// .network_interface
1647-
// .set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::U32(0), false), network_path);
1648-
// }
1637+
// Upgrade the "Instance Position" node to add the "Loop Level" input
1638+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector_nodes::instance::instance_position::IDENTIFIER) && inputs_count < 2 {
1639+
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
1640+
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
1641+
1642+
document
1643+
.network_interface
1644+
.set_input(&InputConnector::node(*node_id, 0), NodeInput::value(TaggedValue::None, false), network_path);
1645+
document
1646+
.network_interface
1647+
.set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::U32(0), false), network_path);
1648+
}
16491649

16501650
// Migrate from the old source/target "Morph" node to the new vector table based "Morph" node.
16511651
// This doesn't produce exactly equivalent results in cases involving input vector tables with multiple rows.

node-graph/nodes/vector/src/instance.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,18 @@ async fn instance_repeat<T: Into<Graphic> + Default + Send + Clone + 'static>(
8484
}
8585

8686
#[node_macro::node(category("Instancing"), path(core_types::vector))]
87-
async fn instance_position(ctx: impl Ctx + ExtractPosition) -> DVec2 {
87+
async fn instance_position(
88+
ctx: impl Ctx + ExtractPosition,
89+
_primary: (),
90+
/// The number of nested loops to traverse outwards (from the innermost loop) to get the position from. The most upstream loop is level 0, and downstream loops add levels.
91+
///
92+
/// In programming terms: inside the double loop `i { j { ... } }`, *Loop Level* 0 = `j` and 1 = `i`. After inserting a third loop `k { ... }`, inside it, levels would be 0 = `k`, 1 = `j`, and 2 = `i`.
93+
loop_level: u32,
94+
) -> DVec2 {
8895
let Some(position_iter) = ctx.try_position() else { return DVec2::ZERO };
8996
let mut last = DVec2::ZERO;
9097
for (i, position) in position_iter.enumerate() {
91-
if i == 0 as usize {
98+
if i == loop_level as usize {
9299
return position;
93100
}
94101
last = position;

0 commit comments

Comments
 (0)