diff --git a/node-graph/interpreted-executor/src/node_registry.rs b/node-graph/interpreted-executor/src/node_registry.rs index cb52a423d6..1e252a5db6 100644 --- a/node-graph/interpreted-executor/src/node_registry.rs +++ b/node-graph/interpreted-executor/src/node_registry.rs @@ -57,6 +57,7 @@ fn node_registry() -> HashMap>, to: Table>), #[cfg(feature = "gpu")] into_node!(from: &WasmEditorApi, to: &WgpuExecutor), + convert_node!(from: DVec2, to: DVec2), convert_node!(from: String, to: String), convert_node!(from: bool, to: String), convert_node!(from: DVec2, to: String), @@ -275,6 +276,8 @@ fn node_registry() -> HashMap {{ + let x: Vec<(ProtoNodeIdentifier, NodeConstructor, NodeIOTypes)> = vec![ + convert_node!(from: f32, to: $to), + convert_node!(from: f64, to: $to), + convert_node!(from: i8, to: $to), + convert_node!(from: u8, to: $to), + convert_node!(from: u16, to: $to), + convert_node!(from: i16, to: $to), + convert_node!(from: i32, to: $to), + convert_node!(from: u32, to: $to), + convert_node!(from: i64, to: $to), + convert_node!(from: u64, to: $to), + convert_node!(from: i128, to: $to), + convert_node!(from: u128, to: $to), + convert_node!(from: isize, to: $to), + convert_node!(from: usize, to: $to), ]; x }}; diff --git a/node-graph/libraries/core-types/src/ops.rs b/node-graph/libraries/core-types/src/ops.rs index 7344f8641f..d09d8194a0 100644 --- a/node-graph/libraries/core-types/src/ops.rs +++ b/node-graph/libraries/core-types/src/ops.rs @@ -1,8 +1,7 @@ -use crate::{ - Node, - table::{Table, TableRow}, - transform::Footprint, -}; +use crate::Node; +use crate::table::{Table, TableRow}; +use crate::transform::Footprint; +use glam::DVec2; use std::future::Future; use std::marker::PhantomData; @@ -55,12 +54,10 @@ impl Convert for T { } } -// trait mentioning inner type in args pub trait TableConvert { fn convert_row(self) -> U; } -// impl + Send> Convert, ()> for Table { async fn convert(self, _: Footprint, _: ()) -> Table { let table: Table = self @@ -76,6 +73,12 @@ impl + Send> Convert, ()> for Table { } } +impl Convert for DVec2 { + async fn convert(self, _: Footprint, _: ()) -> DVec2 { + self + } +} + /// Implements the [`Convert`] trait for conversion between the cartesian product of Rust's primitive numeric types. macro_rules! impl_convert { ($from:ty, $to:ty) => { @@ -100,6 +103,12 @@ macro_rules! impl_convert { impl_convert!(u128, $to); impl_convert!(isize, $to); impl_convert!(usize, $to); + + impl Convert for $to { + async fn convert(self, _: Footprint, _: ()) -> DVec2 { + DVec2::splat(self as f64) + } + } }; } impl_convert!(f32);