@@ -5,6 +5,7 @@ use crate::messages::portfolio::document::utility_types::network_interface::{sel
5
5
use crate :: messages:: prelude:: * ;
6
6
7
7
use bezier_rs:: Subpath ;
8
+ use graph_craft:: concrete;
8
9
use graph_craft:: document:: value:: TaggedValue ;
9
10
use graph_craft:: document:: { NodeId , NodeInput } ;
10
11
use graphene_core:: raster:: { BlendMode , ImageFrame } ;
@@ -16,6 +17,7 @@ use graphene_core::{Artboard, Color};
16
17
17
18
use glam:: { DAffine2 , DVec2 , IVec2 } ;
18
19
use graphene_std:: vector:: VectorData ;
20
+ use graphene_std:: GraphicGroup ;
19
21
20
22
#[ derive( PartialEq , Clone , Copy , Debug , serde:: Serialize , serde:: Deserialize ) ]
21
23
pub enum TransformIn {
@@ -236,11 +238,13 @@ impl<'a> ModifyInputsContext<'a> {
236
238
}
237
239
} )
238
240
}
239
- // Gets the node id of a node with a specific reference that is upstream from the layer node, and creates it if it does not exist
241
+ /// Gets the node id of a node with a specific reference that is upstream from the layer node, and creates it if it does not exist
242
+ /// The returned node is based on the selection dots in the layer. The right most dot will always insert/access the path that flows directly into the layer
243
+ /// Each dot after that represents an existing path node
244
+ /// If there is an existing upstream node, then it will always be returned first.
240
245
pub fn existing_node_id ( & mut self , reference : & ' static str ) -> Option < NodeId > {
241
246
// Start from the layer node or export
242
247
let output_layer = self . get_output_layer ( ) ?;
243
- let layer_input_type = self . network_interface . input_type ( & InputConnector :: node ( output_layer. to_node ( ) , 1 ) , & [ ] ) . 0 . nested_type ( ) ;
244
248
245
249
let upstream = self
246
250
. network_interface
@@ -249,8 +253,6 @@ impl<'a> ModifyInputsContext<'a> {
249
253
// Take until another layer node is found (but not the first layer node)
250
254
let mut existing_node_id = None ;
251
255
for upstream_node in upstream. collect :: < Vec < _ > > ( ) {
252
- let upstream_node_input_type = self . network_interface . input_type ( & InputConnector :: node ( upstream_node, 0 ) , & [ ] ) . 0 . nested_type ( ) ;
253
-
254
256
// Check if this is the node we have been searching for.
255
257
if self . network_interface . reference ( & upstream_node, & [ ] ) . is_some_and ( |node_reference| node_reference == reference) {
256
258
existing_node_id = Some ( upstream_node) ;
@@ -261,8 +263,7 @@ impl<'a> ModifyInputsContext<'a> {
261
263
self . layer_node . map ( |layer| layer. to_node ( ) ) == Some ( node_id) || self . network_interface . network ( & [ ] ) . unwrap ( ) . exports . iter ( ) . any ( |export| export. as_node ( ) == Some ( node_id) )
262
264
} ;
263
265
264
- // If the type changes then break?? This should at least be after checking if the node is correct (otherwise the brush tool breaks.)
265
- if !is_traversal_start ( upstream_node) && ( self . network_interface . is_layer ( & upstream_node, & [ ] ) || upstream_node_input_type != layer_input_type) {
266
+ if !is_traversal_start ( upstream_node) && ( self . network_interface . is_layer ( & upstream_node, & [ ] ) ) {
266
267
break ;
267
268
}
268
269
}
@@ -278,6 +279,20 @@ impl<'a> ModifyInputsContext<'a> {
278
279
log:: error!( "Node type {} does not exist in ModifyInputsContext::existing_node_id" , reference) ;
279
280
return None ;
280
281
} ;
282
+ // If inserting a path node, insert a flatten vector elements if the type is a graphic group.
283
+ // TODO: Allow the path node to operate on Graphic Group data by utilizing the reference for each vector data in a group.
284
+ if node_definition. identifier == "Path" {
285
+ let layer_input_type = self . network_interface . input_type ( & InputConnector :: node ( output_layer. to_node ( ) , 1 ) , & [ ] ) . 0 . nested_type ( ) ;
286
+ if layer_input_type == concrete ! ( GraphicGroup ) {
287
+ let Some ( flatten_vector_elements_definition) = resolve_document_node_type ( "Flatten Vector Elements" ) else {
288
+ log:: error!( "Flatten Vector Elements does not exist in ModifyInputsContext::existing_node_id" ) ;
289
+ return None ;
290
+ } ;
291
+ let node_id = NodeId :: new ( ) ;
292
+ self . network_interface . insert_node ( node_id, flatten_vector_elements_definition. default_node_template ( ) , & [ ] ) ;
293
+ self . network_interface . move_node_to_chain_start ( & node_id, output_layer, & [ ] ) ;
294
+ }
295
+ }
281
296
let node_id = NodeId :: new ( ) ;
282
297
self . network_interface . insert_node ( node_id, node_definition. default_node_template ( ) , & [ ] ) ;
283
298
self . network_interface . move_node_to_chain_start ( & node_id, output_layer, & [ ] ) ;
0 commit comments