Skip to content

Commit da278e0

Browse files
committed
New node: Map Points
Also resolves #3217
1 parent 258748e commit da278e0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
20432043
input_metadata: vec![
20442044
("Content", "TODO").into(),
20452045
InputMetadata::with_name_description_override(
2046-
"Separation Disk Diameter",
2046+
"Separation",
20472047
"TODO",
20482048
WidgetOverride::Number(NumberInputSettings {
20492049
min: Some(0.01),

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,23 @@ async fn instance_map(ctx: impl Ctx + CloneVarArgs + ExtractAll, content: Table<
13501350
rows.into_iter().collect()
13511351
}
13521352

1353+
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
1354+
async fn map_points(ctx: impl Ctx + CloneVarArgs + ExtractAll, content: Table<Vector>, mapped: impl Node<Context<'static>, Output = DVec2>) -> Table<Vector> {
1355+
let mut content = content;
1356+
let mut index = 0;
1357+
1358+
for row in content.iter_mut() {
1359+
for (_, position) in row.element.point_domain.positions_mut() {
1360+
let owned_ctx = OwnedContextImpl::from(ctx.clone()).with_index(index).with_position(*position);
1361+
index += 1;
1362+
1363+
*position = mapped.eval(owned_ctx.into_context()).await;
1364+
}
1365+
}
1366+
1367+
content
1368+
}
1369+
13531370
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
13541371
async fn flatten_path<T: 'n + Send>(
13551372
_: impl Ctx,

0 commit comments

Comments
 (0)