diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe3821f3..24d602d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v3 - name: 🗑 Clear wasm-bindgen cache - run: rm -r ~/.cache/.wasm-pack + run: rm -r ~/.cache/.wasm-pack || true - name: 🟢 Set up Node uses: actions/setup-node@v3 diff --git a/editor/src/dispatcher.rs b/editor/src/dispatcher.rs index a4632fc2..e98d6a4b 100644 --- a/editor/src/dispatcher.rs +++ b/editor/src/dispatcher.rs @@ -260,6 +260,7 @@ mod test { use crate::messages::prelude::*; use crate::test_utils::EditorTestUtils; + use document_legacy::document_metadata::LayerNodeIdentifier; use document_legacy::LayerId; use document_legacy::Operation; use graphene_core::raster::color::Color; diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/document_node_types.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/document_node_types.rs index 9bc972b8..fb68842f 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/document_node_types.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/document_node_types.rs @@ -2519,7 +2519,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, hash: u64) -> NodeNetwork .to_document_node(vec![input_type.unwrap()], DocumentNodeMetadata::default()); if let DocumentNodeImplementation::Network(g) = &mut begin_scope.implementation { if let Some(node) = g.nodes.get_mut(&0) { - node.hash = hash; + node.world_state_hash = hash; } } diff --git a/node-graph/graph-craft/src/document.rs b/node-graph/graph-craft/src/document.rs index 862f477f..e4fb499c 100644 --- a/node-graph/graph-craft/src/document.rs +++ b/node-graph/graph-craft/src/document.rs @@ -148,7 +148,7 @@ pub struct DocumentNode { pub skip_deduplication: bool, /// Used as a hash of the graph input where applicable. This ensures that protonodes that depend on the graph's input are always regenerated. #[serde(default)] - pub hash: u64, + pub world_state_hash: u64, /// The path to this node as of when [`NodeNetwork::generate_node_paths`] was called. /// For example if this node was ID 6 inside a node with ID 4 and with a [`DocumentNodeImplementation::Network`], the path would be [4, 6]. pub path: Option>, @@ -164,7 +164,7 @@ impl Default for DocumentNode { implementation: Default::default(), metadata: Default::default(), skip_deduplication: Default::default(), - hash: Default::default(), + world_state_hash: Default::default(), path: Default::default(), } } @@ -230,7 +230,7 @@ impl DocumentNode { construction_args: args, document_node_path: self.path.unwrap_or_default(), skip_deduplication: self.skip_deduplication, - hash: self.hash, + world_state_hash: self.world_state_hash, } } @@ -1248,8 +1248,7 @@ mod test { identifier: "graphene_core::structural::ConsNode".into(), input: ProtoNodeInput::ManualComposition(concrete!(u32)), construction_args: ConstructionArgs::Nodes(vec![(0, false)]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }; assert_eq!(proto_node, reference); } @@ -1267,7 +1266,7 @@ mod test { input: ProtoNodeInput::ManualComposition(concrete!(u32)), construction_args: ConstructionArgs::Nodes(vec![(14, false)]), document_node_path: vec![1, 0], - skip_deduplication: false, + ..Default::default() }, ), ( @@ -1277,7 +1276,7 @@ mod test { input: ProtoNodeInput::Node(10, false), construction_args: ConstructionArgs::Nodes(vec![]), document_node_path: vec![1, 1], - skip_deduplication: false, + ..Default::default() }, ), (14, ProtoNode::value(ConstructionArgs::Value(TaggedValue::U32(2)), vec![1, 4])), diff --git a/node-graph/graph-craft/src/proto.rs b/node-graph/graph-craft/src/proto.rs index 1bba0106..d1c23f83 100644 --- a/node-graph/graph-craft/src/proto.rs +++ b/node-graph/graph-craft/src/proto.rs @@ -207,7 +207,21 @@ pub struct ProtoNode { pub identifier: NodeIdentifier, pub document_node_path: Vec, pub skip_deduplication: bool, - pub hash: u64, + /// Represents a global state on which the node depends. This is a hack, TODO: figure out a proper solution + pub world_state_hash: u64, +} + +impl Default for ProtoNode { + fn default() -> Self { + Self { + identifier: NodeIdentifier::new("graphene_core::ops::IdNode"), + construction_args: ConstructionArgs::Value(value::TaggedValue::U32(0)), + input: ProtoNodeInput::None, + document_node_path: vec![], + skip_deduplication: false, + world_state_hash: 0, + } + } } /// A ProtoNodeInput represents the primary input of a node in a ProtoNetwork. @@ -253,7 +267,7 @@ impl ProtoNode { if self.skip_deduplication { self.document_node_path.hash(&mut hasher); } - self.hash.hash(&mut hasher); + self.world_state_hash.hash(&mut hasher); std::mem::discriminant(&self.input).hash(&mut hasher); match self.input { ProtoNodeInput::None => (), @@ -273,7 +287,7 @@ impl ProtoNode { input: ProtoNodeInput::None, document_node_path: path, skip_deduplication: false, - hash: 0, + world_state_hash: 0, } } @@ -386,7 +400,7 @@ impl ProtoNetwork { input, document_node_path: path, skip_deduplication: false, - hash: 0, + world_state_hash: 0, }, )); @@ -778,12 +792,12 @@ mod test { assert_eq!( ids, vec![ - 2785293541695324513, - 12994980551665119079, - 17926586814106640907, - 2523412932923113119, - 12965978620570332342, - 16191561097939296982 + 17957338642374791135, + 1303972037140595827, + 15485192931817078264, + 9739645351331265115, + 4165308598738454684, + 5557529806312473178 ] ); } @@ -799,8 +813,7 @@ mod test { identifier: "id".into(), input: ProtoNodeInput::Node(11, false), construction_args: ConstructionArgs::Nodes(vec![]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ( @@ -809,8 +822,7 @@ mod test { identifier: "id".into(), input: ProtoNodeInput::Node(11, false), construction_args: ConstructionArgs::Nodes(vec![]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ( @@ -819,8 +831,7 @@ mod test { identifier: "cons".into(), input: ProtoNodeInput::ManualComposition(concrete!(u32)), construction_args: ConstructionArgs::Nodes(vec![(14, false)]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ( @@ -829,8 +840,7 @@ mod test { identifier: "add".into(), input: ProtoNodeInput::Node(10, false), construction_args: ConstructionArgs::Nodes(vec![]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ( @@ -839,8 +849,7 @@ mod test { identifier: "value".into(), input: ProtoNodeInput::None, construction_args: ConstructionArgs::Value(value::TaggedValue::U32(2)), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ] @@ -860,8 +869,7 @@ mod test { identifier: "id".into(), input: ProtoNodeInput::Node(2, false), construction_args: ConstructionArgs::Nodes(vec![]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ( @@ -870,8 +878,7 @@ mod test { identifier: "id".into(), input: ProtoNodeInput::Node(1, false), construction_args: ConstructionArgs::Nodes(vec![]), - document_node_path: vec![], - skip_deduplication: false, + ..Default::default() }, ), ]