Community
Bifrost Forum
Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost. You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"for_each" node data type problem

4 REPLIES 4
Reply
Message 1 of 5
mcw0
376 Views, 4 Replies

"for_each" node data type problem

Very simple test.

 

mesh > get_point_position > for_each (connect input positions to output...just passing data) > divide

 

The above graph created an error.  And the error is in the for_each node.  Input data is array<Math::float3>,  But the output data is array<array<float>>.  

I'm guessing I have to recreate my array<Math::float3> in the for_each node by converting the array<float> to Math::float3.

 

4 REPLIES 4
Message 2 of 5
mcw0
in reply to: mcw0

Sorry I was trying different things and what I said in the original post is in error.  The output data in the for_each node is array<array<Math::float3>>.  I've tried using a get_from_array on the input data to isolate one Math::float3.  And then using set_in_array to recreate the array<Math::float3> data type as the output but that also had issues.

 

While in the for_each node, it says the output is array<Math::float3>.  But once you come out of the node, it says it's array<array<Math::float3>>

Message 3 of 5
mcw0
in reply to: mcw0

It appears I don't need the set_in_array node.  I'm getting the proper output data type now with only using a get_from_array node.

Message 4 of 5
mjcg91
in reply to: mcw0

You don't necessarily have to use get from array to get each of your input array's elements. You can set your input array port as an iteration target and it will return each array elements as single values for each iterations.

 

Regarding outputs, the for-each loop only has iteration target ports for ouputs, so you can't set a value inside an existing array. Eveything you output will generate an array, so if you output an array, il will return a 2d array.

 

If you want to set values inside an existing array, use an iterate or do-while compound, and use state ports on your array. 

Maxime Jeanmougin - Technical Artist
https://maximejeanmougin.com

Join the Bifrost Addicts community on Discord:
https://discord.gg/bifrost-addicts
Message 5 of 5
mcw0
in reply to: mjcg91

Thank you Maxime for reminding me about the iteration target.  I am successful in converting my raycast node from a "do_while" approach to a "for_each" with the "do_while" inside the "for_each".  With simple geometry, it's hard to tell if it's faster.  But it was a good learning experience.  I think a lot of my issues came from copying and pasting sections of the node graph.  For example, in converting approaches, I copied my "do_while" and pasted it inside the "for_each" node.  I tried replacing connections and was getting complaints because of the data types already established.  Creating new nodes and connections kept things clean.  Still have so much to learn.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report