diff options
| author | Mariano Javier Suligoy | 2015-07-25 21:16:07 -0300 |
|---|---|---|
| committer | Mariano Javier Suligoy | 2015-07-25 21:16:07 -0300 |
| commit | 5ffd818fb195a6e9bea48ec03ad52a77080a8d25 (patch) | |
| tree | d47010a59b24f12649b4eaafd9edca5723cd8976 /scene/resources/shader_graph.cpp | |
| parent | bdde79a3f433dbff244e544b72ac8946d8d9b44b (diff) | |
| download | godot-5ffd818fb195a6e9bea48ec03ad52a77080a8d25.tar.gz godot-5ffd818fb195a6e9bea48ec03ad52a77080a8d25.tar.zst godot-5ffd818fb195a6e9bea48ec03ad52a77080a8d25.zip | |
Diffstat (limited to 'scene/resources/shader_graph.cpp')
| -rw-r--r-- | scene/resources/shader_graph.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index a0766ff31..108aad3c5 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -824,6 +824,47 @@ float ShaderGraph::texture_node_get_filter_strength(ShaderType p_type,float p_id return arr[1]; } +void ShaderGraph::duplicate_nodes(ShaderType p_which, List<int> &p_nodes) +{ + //Create new node IDs + Map<int,int> duplicates = Map<int,int>(); + int i=1; + for(List<int>::Element *E=p_nodes.front();E; E=E->next()) { + while (shader[p_which].node_map.has(i)) + i++; + duplicates.insert(E->get(), i); + i++; + } + + for(List<int>::Element *E = p_nodes.front();E; E=E->next()) { + + const Node &n=shader[p_which].node_map[E->get()]; + Node nn=n; + nn.id=duplicates.find(n.id)->get(); + nn.pos += Vector2(0,100); + for (Map<int,SourceSlot>::Element *C=nn.connections.front();C;C=C->next()) { + SourceSlot &c=C->get(); + if (p_nodes.find(c.id)) + c.id=duplicates.find(c.id)->get(); + } + shader[p_which].node_map[nn.id]=nn; + } + _request_update(); +} + +List<int> ShaderGraph::generate_ids(ShaderType p_type, int count) +{ + List<int> ids = List<int>(); + int i=1; + while (ids.size() < count) { + while (shader[p_type].node_map.has(i)) + i++; + ids.push_back(i); + i++; + } + return ids; +} + void ShaderGraph::scalar_op_node_set_op(ShaderType p_type,float p_id,ScalarOp p_op){ |
