aboutsummaryrefslogtreecommitdiff
path: root/scene/resources/shader_graph.cpp
diff options
context:
space:
mode:
authorMariano Javier Suligoy2015-07-25 21:16:07 -0300
committerMariano Javier Suligoy2015-07-25 21:16:07 -0300
commit5ffd818fb195a6e9bea48ec03ad52a77080a8d25 (patch)
treed47010a59b24f12649b4eaafd9edca5723cd8976 /scene/resources/shader_graph.cpp
parentbdde79a3f433dbff244e544b72ac8946d8d9b44b (diff)
downloadgodot-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.cpp41
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){