@@ -237,15 +237,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
237237 node_template: NodeTemplate {
238238 document_node: DocumentNode {
239239 implementation: DocumentNodeImplementation :: Network ( NodeNetwork {
240- exports: vec![ NodeInput :: node( NodeId ( 3 ) , 0 ) ] ,
240+ exports: vec![ NodeInput :: node( NodeId ( 2 ) , 0 ) ] ,
241241 nodes: [
242- // Secondary (left) input type coercion
243- DocumentNode {
244- inputs: vec![ NodeInput :: network( generic!( T ) , 1 ) ] ,
245- implementation: DocumentNodeImplementation :: proto( "graphene_core::graphic_element::ToElementNode" ) ,
246- manual_composition: Some ( generic!( T ) ) ,
247- ..Default :: default ( )
248- } ,
249242 // Primary (bottom) input type coercion
250243 DocumentNode {
251244 inputs: vec![ NodeInput :: network( generic!( T ) , 0 ) ] ,
@@ -255,7 +248,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
255248 } ,
256249 // The monitor node is used to display a thumbnail in the UI
257250 DocumentNode {
258- inputs: vec![ NodeInput :: node ( NodeId ( 0 ) , 0 ) ] ,
251+ inputs: vec![ NodeInput :: network ( generic! ( T ) , 1 ) ] ,
259252 implementation: DocumentNodeImplementation :: proto( "graphene_core::memo::MonitorNode" ) ,
260253 manual_composition: Some ( generic!( T ) ) ,
261254 skip_deduplication: true ,
@@ -264,8 +257,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
264257 DocumentNode {
265258 manual_composition: Some ( generic!( T ) ) ,
266259 inputs: vec![
260+ NodeInput :: node( NodeId ( 0 ) , 0 ) ,
267261 NodeInput :: node( NodeId ( 1 ) , 0 ) ,
268- NodeInput :: node( NodeId ( 2 ) , 0 ) ,
269262 NodeInput :: Reflection ( graph_craft:: document:: DocumentNodeMetadata :: DocumentNodePath ) ,
270263 ] ,
271264 implementation: DocumentNodeImplementation :: proto( "graphene_core::graphic_element::LayerNode" ) ,
@@ -2116,217 +2109,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
21162109 } ,
21172110 ] ;
21182111
2119- <<<<<<< HEAD
2120- // Remove struct generics
2121- for DocumentNodeDefinition { node_template, .. } in custom. iter_mut( ) {
2122- let NodeTemplate {
2123- document_node: DocumentNode { implementation, .. } ,
2124- ..
2125- } = node_template;
2126- if let DocumentNodeImplementation :: ProtoNode ( ProtoNodeIdentifier { name } ) = implementation {
2127- if let Some ( ( new_name, _suffix) ) = name. rsplit_once( "<" ) {
2128- * name = Cow :: Owned ( new_name. to_string ( ) )
2129- }
2130- } ;
2131- }
2132- let node_registry = graphene_std:: registry:: NODE_REGISTRY . lock ( ) . unwrap ( ) ;
2133- ' outer: for ( id, metadata) in graphene_std:: registry:: NODE_METADATA . lock ( ) . unwrap ( ) . iter ( ) {
2134- use graphene_std:: registry:: * ;
2135- let id = id. clone ( ) ;
2136-
2137- for node in custom. iter ( ) {
2138- let DocumentNodeDefinition {
2139- node_template : NodeTemplate {
2140- document_node : DocumentNode { implementation, .. } ,
2141- ..
2142- } ,
2143- ..
2144- } = node;
2145- match implementation {
2146- DocumentNodeImplementation :: ProtoNode ( ProtoNodeIdentifier { name } ) if name == & id => continue ' outer,
2147- _ => ( ) ,
2148- }
2149- }
2150-
2151- let NodeMetadata {
2152- display_name,
2153- category,
2154- fields,
2155- description,
2156- properties,
2157- } = metadata;
2158- let Some ( implementations) = & node_registry. get ( & id) else { continue } ;
2159- let valid_inputs: HashSet < _ > = implementations. iter ( ) . map ( |( _, node_io) | node_io. call_argument . clone ( ) ) . collect ( ) ;
2160- let first_node_io = implementations. first ( ) . map ( |( _, node_io) | node_io) . unwrap_or ( const { & NodeIOTypes :: empty ( ) } ) ;
2161- let mut input_type = & first_node_io. call_argument ;
2162- if valid_inputs. len ( ) > 1 {
2163- input_type = & const { generic ! ( D ) } ;
2164- }
2165- let output_type = & first_node_io. return_value ;
2166-
2167- let inputs = fields
2168- . iter ( )
2169- . zip ( first_node_io. inputs . iter ( ) )
2170- . enumerate ( )
2171- . map ( |( index, ( field, node_io_ty) ) | {
2172- let ty = field. default_type . as_ref ( ) . unwrap_or ( node_io_ty) ;
2173- let exposed = if index == 0 { * ty != fn_type_fut ! ( Context , ( ) ) } else { field. exposed } ;
2174-
2175- match field. value_source {
2176- RegistryValueSource :: None => { }
2177- RegistryValueSource :: Default ( data) => return NodeInput :: value ( TaggedValue :: from_primitive_string ( data, ty) . unwrap_or ( TaggedValue :: None ) , exposed) ,
2178- RegistryValueSource :: Scope ( data) => return NodeInput :: scope ( Cow :: Borrowed ( data) ) ,
2179- } ;
2180-
2181- if let Some ( type_default) = TaggedValue :: from_type ( ty) {
2182- return NodeInput :: value ( type_default, exposed) ;
2183- }
2184- NodeInput :: value ( TaggedValue :: None , true )
2185- } )
2186- . collect ( ) ;
2187-
2188- let node = DocumentNodeDefinition {
2189- identifier : display_name,
2190- node_template : NodeTemplate {
2191- document_node : DocumentNode {
2192- inputs,
2193- manual_composition : Some ( input_type. clone ( ) ) ,
2194- implementation : DocumentNodeImplementation :: ProtoNode ( id. clone ( ) . into ( ) ) ,
2195- visible : true ,
2196- skip_deduplication : false ,
2197- ..Default :: default ( )
2198- } ,
2199- persistent_node_metadata : DocumentNodePersistentMetadata {
2200- // TODO: Store information for input overrides in the node macro
2201- input_properties : fields
2202- . iter ( )
2203- . map ( |f| match f. widget_override {
2204- RegistryWidgetOverride :: None => ( f. name , f. description ) . into ( ) ,
2205- RegistryWidgetOverride :: Hidden => PropertiesRow :: with_override ( f. name , f. description , WidgetOverride :: Hidden ) ,
2206- RegistryWidgetOverride :: String ( str) => PropertiesRow :: with_override ( f. name , f. description , WidgetOverride :: String ( str. to_string ( ) ) ) ,
2207- RegistryWidgetOverride :: Custom ( str) => PropertiesRow :: with_override ( f. name , f. description , WidgetOverride :: Custom ( str. to_string ( ) ) ) ,
2208- } )
2209- . collect ( ) ,
2210- output_names : vec ! [ output_type. to_string( ) ] ,
2211- has_primary_output : true ,
2212- locked : false ,
2213- ..Default :: default ( )
2214- } ,
2215- } ,
2216- category : category. unwrap_or ( "UNCATEGORIZED" ) ,
2217- description : Cow :: Borrowed ( description) ,
2218- properties : * properties,
2219- } ;
2220- custom. push ( node) ;
2221- }
2222- custom
2223- ||||||| parent of de38de1c7 ( Prototype document network level into node insertion)
2224- // Remove struct generics
2225- for DocumentNodeDefinition { node_template, .. } in custom. iter_mut( ) {
2226- let NodeTemplate {
2227- document_node : DocumentNode { implementation, .. } ,
2228- ..
2229- } = node_template;
2230- if let DocumentNodeImplementation :: ProtoNode ( ProtoNodeIdentifier { name } ) = implementation {
2231- if let Some ( ( new_name, _suffix) ) = name. rsplit_once ( "<" ) {
2232- * name = Cow :: Owned ( new_name. to_string ( ) )
2233- }
2234- } ;
2235- }
2236- let node_registry = graphene_core:: registry:: NODE_REGISTRY . lock ( ) . unwrap ( ) ;
2237- ' outer: for ( id, metadata) in graphene_core:: registry:: NODE_METADATA . lock ( ) . unwrap ( ) . iter ( ) {
2238- use graphene_core:: registry:: * ;
2239- let id = id. clone ( ) ;
2240-
2241- for node in custom. iter ( ) {
2242- let DocumentNodeDefinition {
2243- node_template : NodeTemplate {
2244- document_node : DocumentNode { implementation, .. } ,
2245- ..
2246- } ,
2247- ..
2248- } = node;
2249- match implementation {
2250- DocumentNodeImplementation :: ProtoNode ( ProtoNodeIdentifier { name } ) if name == & id => continue ' outer,
2251- _ => ( ) ,
2252- }
2253- }
2254-
2255- let NodeMetadata {
2256- display_name,
2257- category,
2258- fields,
2259- description,
2260- properties,
2261- } = metadata;
2262- let Some ( implementations) = & node_registry. get ( & id) else { continue } ;
2263- let valid_inputs: HashSet < _ > = implementations. iter ( ) . map ( |( _, node_io) | node_io. call_argument . clone ( ) ) . collect ( ) ;
2264- let first_node_io = implementations. first ( ) . map ( |( _, node_io) | node_io) . unwrap_or ( const { & NodeIOTypes :: empty ( ) } ) ;
2265- let mut input_type = & first_node_io. call_argument ;
2266- if valid_inputs. len ( ) > 1 {
2267- input_type = & const { generic ! ( D ) } ;
2268- }
2269- let output_type = & first_node_io. return_value ;
2270-
2271- let inputs = fields
2272- . iter ( )
2273- . zip ( first_node_io. inputs . iter ( ) )
2274- . enumerate ( )
2275- . map ( |( index, ( field, node_io_ty) ) | {
2276- let ty = field. default_type . as_ref ( ) . unwrap_or ( node_io_ty) ;
2277- let exposed = if index == 0 { * ty != fn_type_fut ! ( Context , ( ) ) } else { field. exposed } ;
2278-
2279- match field. value_source {
2280- RegistryValueSource :: None => { }
2281- RegistryValueSource :: Default ( data) => return NodeInput :: value ( TaggedValue :: from_primitive_string ( data, ty) . unwrap_or ( TaggedValue :: None ) , exposed) ,
2282- RegistryValueSource :: Scope ( data) => return NodeInput :: scope ( Cow :: Borrowed ( data) ) ,
2283- } ;
2284-
2285- if let Some ( type_default) = TaggedValue :: from_type ( ty) {
2286- return NodeInput :: value ( type_default, exposed) ;
2287- }
2288- NodeInput :: value ( TaggedValue :: None , true )
2289- } )
2290- . collect ( ) ;
2291-
2292- let node = DocumentNodeDefinition {
2293- identifier : display_name,
2294- node_template : NodeTemplate {
2295- document_node : DocumentNode {
2296- inputs,
2297- manual_composition : Some ( input_type. clone ( ) ) ,
2298- implementation : DocumentNodeImplementation :: ProtoNode ( id. clone ( ) . into ( ) ) ,
2299- visible : true ,
2300- skip_deduplication : false ,
2301- ..Default :: default ( )
2302- } ,
2303- persistent_node_metadata : DocumentNodePersistentMetadata {
2304- // TODO: Store information for input overrides in the node macro
2305- input_properties : fields
2306- . iter ( )
2307- . map ( |f| match f. widget_override {
2308- RegistryWidgetOverride :: None => ( f. name , f. description ) . into ( ) ,
2309- RegistryWidgetOverride :: Hidden => PropertiesRow :: with_override ( f. name , f. description , WidgetOverride :: Hidden ) ,
2310- RegistryWidgetOverride :: String ( str) => PropertiesRow :: with_override ( f. name , f. description , WidgetOverride :: String ( str. to_string ( ) ) ) ,
2311- RegistryWidgetOverride :: Custom ( str) => PropertiesRow :: with_override ( f. name , f. description , WidgetOverride :: Custom ( str. to_string ( ) ) ) ,
2312- } )
2313- . collect ( ) ,
2314- output_names : vec ! [ output_type. to_string( ) ] ,
2315- has_primary_output : true ,
2316- locked : false ,
2317- ..Default :: default ( )
2318- } ,
2319- } ,
2320- category : category. unwrap_or ( "UNCATEGORIZED" ) ,
2321- description : Cow :: Borrowed ( description) ,
2322- properties : * properties,
2323- } ;
2324- custom. push ( node) ;
2325- }
2326- custom
2327- =======
23282112 document_node_derive:: post_process_nodes ( custom)
2329- >>>>>>> de38de1c7 ( Prototype document network level into node insertion)
23302113}
23312114
23322115// pub static IMAGINATE_NODE: Lazy<DocumentNodeDefinition> = Lazy::new(|| DocumentNodeDefinition {
0 commit comments