Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
DocumentNode {
inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_>"),
skip_deduplication: true,
..Default::default()
},
),
Expand Down Expand Up @@ -1986,6 +1987,7 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeTyp
name: "Frame Monitor".into(),
inputs: vec![NodeInput::Network(concrete!(ImageFrame<Color>))],
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_>"),
skip_deduplication: true,
..Default::default()
},
),
Expand Down
2 changes: 2 additions & 0 deletions node-graph/gcore/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ pub struct TypeDescriptor {
#[specta(skip)]
pub id: Option<TypeId>,
pub name: Cow<'static, str>,
#[serde(default)]
pub size: usize,
#[serde(default)]
pub align: usize,
}

Expand Down
6 changes: 6 additions & 0 deletions node-graph/graph-craft/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub struct DocumentNode {
pub inputs: Vec<NodeInput>,
pub implementation: DocumentNodeImplementation,
pub metadata: DocumentNodeMetadata,
#[serde(default)]
pub skip_deduplication: bool,
pub path: Option<Vec<NodeId>>,
}

Expand Down Expand Up @@ -97,6 +99,7 @@ impl DocumentNode {
input,
construction_args: args,
document_node_path: self.path.unwrap_or(Vec::new()),
skip_deduplication: self.skip_deduplication,
}
} else {
unreachable!("tried to resolve not flattened node on resolved node {:?}", self);
Expand Down Expand Up @@ -1063,6 +1066,7 @@ mod test {
input: ProtoNodeInput::Network(concrete!(u32)),
construction_args: ConstructionArgs::Nodes(vec![(0, false)]),
document_node_path: vec![],
skip_deduplication: false,
};
assert_eq!(proto_node, reference);
}
Expand All @@ -1080,6 +1084,7 @@ mod test {
input: ProtoNodeInput::Network(concrete!(u32)),
construction_args: ConstructionArgs::Nodes(vec![(14, false)]),
document_node_path: vec![1, 0],
skip_deduplication: false,
},
),
(
Expand All @@ -1089,6 +1094,7 @@ mod test {
input: ProtoNodeInput::Node(10, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![1, 1],
skip_deduplication: false,
},
),
(14, ProtoNode::value(ConstructionArgs::Value(TaggedValue::U32(2)), vec![1, 4])),
Expand Down
1 change: 1 addition & 0 deletions node-graph/graph-craft/src/imaginate_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub trait ImaginateTerminationHandle: Debug + Send + Sync + 'static {
#[derive(Default, Debug, specta::Type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
struct InternalImaginateControl {
#[serde(skip)]
status: Mutex<ImaginateStatus>,
trigger_regenerate: AtomicBool,
#[serde(skip)]
Expand Down
26 changes: 18 additions & 8 deletions node-graph/graph-craft/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ impl ConstructionArgs {
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Clone, Hash, Eq)]
#[derive(Debug, Clone, PartialEq, Hash, Eq)]
pub struct ProtoNode {
pub construction_args: ConstructionArgs,
pub input: ProtoNodeInput,
pub identifier: NodeIdentifier,
pub document_node_path: Vec<NodeId>,
pub skip_deduplication: bool,
}

/// A ProtoNodeInput represents the input of a node in a ProtoNetwork.
Expand Down Expand Up @@ -231,7 +232,9 @@ impl ProtoNode {

self.identifier.name.hash(&mut hasher);
self.construction_args.hash(&mut hasher);
self.document_node_path.hash(&mut hasher);
if self.skip_deduplication {
self.document_node_path.hash(&mut hasher);
}
std::mem::discriminant(&self.input).hash(&mut hasher);
match self.input {
ProtoNodeInput::None => (),
Expand All @@ -252,6 +255,7 @@ impl ProtoNode {
construction_args: value,
input: ProtoNodeInput::None,
document_node_path: path,
skip_deduplication: false,
}
}

Expand Down Expand Up @@ -359,6 +363,7 @@ impl ProtoNetwork {
construction_args: ConstructionArgs::Nodes(vec![(input_node_id, false), (node_id, true)]),
input,
document_node_path: path,
skip_deduplication: false,
},
));

Expand Down Expand Up @@ -735,12 +740,12 @@ mod test {
assert_eq!(
ids,
vec![
16203111412429166836,
8181436982058796771,
10130798762907147404,
1082623390433068677,
4567264975997576294,
8215587082195034469
2785293541695324513,
12994980551665119079,
17926586814106640907,
2523412932923113119,
12965978620570332342,
16191561097939296982
]
);
}
Expand All @@ -757,6 +762,7 @@ mod test {
input: ProtoNodeInput::Node(11, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
},
),
(
Expand All @@ -766,6 +772,7 @@ mod test {
input: ProtoNodeInput::Node(11, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
},
),
(
Expand All @@ -775,6 +782,7 @@ mod test {
input: ProtoNodeInput::Network(concrete!(u32)),
construction_args: ConstructionArgs::Nodes(vec![(14, false)]),
document_node_path: vec![],
skip_deduplication: false,
},
),
(
Expand All @@ -784,6 +792,7 @@ mod test {
input: ProtoNodeInput::Node(10, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
},
),
(
Expand All @@ -793,6 +802,7 @@ mod test {
input: ProtoNodeInput::None,
construction_args: ConstructionArgs::Value(value::TaggedValue::U32(2)),
document_node_path: vec![],
skip_deduplication: false,
},
),
]
Expand Down