Make use of ImageFrame in the node system more extensively (#1055) (#1062)

Make the node system use ImageFrame more extensively (#1055)
This commit is contained in:
Alexandru Ică
2023-03-02 15:55:10 +02:00
committed by Keavon Chambers
parent 02d4565b0c
commit 0b813805d2
6 changed files with 215 additions and 158 deletions

View File

@@ -19,17 +19,8 @@ pub struct NodeGraphExecutor {
}
impl NodeGraphExecutor {
/// Sets the transform property on the input node
fn set_input_transform(network: &mut NodeNetwork, transform: DAffine2) {
let Some(input_node) = network.nodes.get_mut(&network.inputs[0]) else {
return;
};
input_node.inputs[1] = NodeInput::value(TaggedValue::DAffine2(transform), false);
}
/// Execute the network by flattening it and creating a borrow stack. Casts the output to the generic `T`.
fn execute_network<T: dyn_any::StaticType>(&mut self, mut network: NodeNetwork, image_frame: ImageFrame) -> Result<T, String> {
Self::set_input_transform(&mut network, image_frame.transform);
network.duplicate_outputs(&mut generate_uuid);
network.remove_dead_nodes();
@@ -49,7 +40,7 @@ impl NodeGraphExecutor {
use dyn_any::IntoDynAny;
use graph_craft::executor::Executor;
let boxed = self.executor.execute(image_frame.image.into_dyn()).map_err(|e| e.to_string())?;
let boxed = self.executor.execute(image_frame.into_dyn()).map_err(|e| e.to_string())?;
dyn_any::downcast::<T>(boxed).map(|v| *v)
}