Fix crash when using Imaginate tool (#1064)

Fix crash when using imaginate tool
This commit is contained in:
0HyperCube 2023-03-02 21:14:12 +00:00 committed by Keavon Chambers
parent 66ec85a3c9
commit 7e37fb41a4
5 changed files with 7 additions and 9 deletions

View File

@ -651,7 +651,6 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeTyp
identifier: NodeImplementation::proto("graphene_std::raster::ImaginateNode<_>"),
inputs: vec![
DocumentInputType::value("Input Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
DocumentInputType::value("Transform", TaggedValue::DAffine2(DAffine2::IDENTITY), false),
DocumentInputType::value("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `NodeGraphFrameImaginateRandom` updated with this entry's index
DocumentInputType::value("Resolution", TaggedValue::OptionalDVec2(None), false),
DocumentInputType::value("Samples", TaggedValue::F64(30.), false),

View File

@ -454,7 +454,6 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
let layer_path = context.layer_path.to_vec();
let resolve_input = |name: &str| IMAGINATE_NODE.inputs.iter().position(|input| input.name == name).unwrap_or_else(|| panic!("Input {name} not found"));
let transform_index = resolve_input("Transform");
let seed_index = resolve_input("Seed");
let resolution_index = resolve_input("Resolution");
let samples_index = resolve_input("Samples");
@ -523,7 +522,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
true
};
let transform_not_connected = matches!(document_node.inputs[transform_index], NodeInput::Value { .. });
let transform_not_connected = false;
let progress = {
// Since we don't serialize the status, we need to derive from other state whether the Idle state is actually supposed to be the Terminated state

View File

@ -124,13 +124,12 @@ impl Fsm for ImaginateToolFsmState {
let mut imaginate_inputs: Vec<NodeInput> = imaginate_node_type.inputs.iter().map(|input| input.default.clone()).collect();
imaginate_inputs[0] = NodeInput::node(0, 0);
imaginate_inputs[1] = NodeInput::node(0, 1);
let imaginate_node_id = 100;
let mut network = node_graph::new_image_network(32, imaginate_node_id);
let mut network = node_graph::new_image_network(16, imaginate_node_id);
network.nodes.insert(
imaginate_node_id,
imaginate_node_type.to_document_node(imaginate_inputs, graph_craft::document::DocumentNodeMetadata::position((20, 3))),
imaginate_node_type.to_document_node(imaginate_inputs, graph_craft::document::DocumentNodeMetadata::position((16, 4))),
);
responses.push_back(

View File

@ -121,7 +121,9 @@ impl NodeGraphExecutor {
let get = |name: &str| IMAGINATE_NODE.inputs.iter().position(|input| input.name == name).unwrap_or_else(|| panic!("Input {name} not found"));
let transform: DAffine2 = self.compute_input(&network, &imaginate_node, get("Transform"), Cow::Borrowed(&image_frame))?;
// Get the node graph layer
let layer = document.document_legacy.layer(&layer_path).map_err(|e| format!("No layer: {e:?}"))?;
let transform = layer.transform;
let resolution: Option<glam::DVec2> = self.compute_input(&network, &imaginate_node, get("Resolution"), Cow::Borrowed(&image_frame))?;
let resolution = resolution.unwrap_or_else(|| {

View File

@ -214,7 +214,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
(
NodeIdentifier::new("graphene_std::raster::ImaginateNode<_>"),
|args| {
let cached = graphene_std::any::input_node::<Option<std::sync::Arc<Image>>>(args[16]);
let cached = graphene_std::any::input_node::<Option<std::sync::Arc<Image>>>(args[15]);
let node = graphene_std::raster::ImaginateNode::new(cached);
let any = DynAnyNode::new(ValueNode::new(node));
any.into_type_erased()
@ -223,7 +223,6 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
concrete!(ImageFrame),
concrete!(ImageFrame),
vec![
(concrete!(()), concrete!(DAffine2)),
(concrete!(()), concrete!(f64)),
(concrete!(()), concrete!(Option<DVec2>)),
(concrete!(()), concrete!(f64)),