diff options
| author | Rémi Verschelde | 2017-03-05 16:44:50 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2017-03-05 16:44:50 +0100 |
| commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
| tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /scene/resources/shader_graph.cpp | |
| parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) | |
| download | godot-5dbf180.tar.gz godot-5dbf180.tar.zst godot-5dbf180.zip | |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'scene/resources/shader_graph.cpp')
| -rw-r--r-- | scene/resources/shader_graph.cpp | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index c21feb0bf..49e987727 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -397,7 +397,6 @@ void ShaderGraph::_bind_methods() { ADD_SIGNAL(MethodInfo("updated")); - #if 0 ClassDB::bind_method(D_METHOD("node_add"),&ShaderGraph::node_add ); ClassDB::bind_method(D_METHOD("node_remove"),&ShaderGraph::node_remove ); @@ -2076,32 +2075,32 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str const char *typestr[4]={"float","vec3","mat4","texture"}; -#define OUTNAME(id,slot) (String(typestr[get_node_output_slot_type(get_mode(),p_type,p_node->type,slot)])+" "+("nd"+itos(id)+"sl"+itos(slot))) -#define OUTVAR(id,slot) ("nd"+itos(id)+"sl"+itos(slot)) -#define DEF_VEC(slot)\ - if (p_inputs[slot].ends_with("def")){\ - Vector3 v = p_node->defaults[slot];\ - code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+v+");\n";\ +#define OUTNAME(id, slot) (String(typestr[get_node_output_slot_type(get_mode(), p_type, p_node->type, slot)]) + " " + ("nd" + itos(id) + "sl" + itos(slot))) +#define OUTVAR(id, slot) ("nd" + itos(id) + "sl" + itos(slot)) +#define DEF_VEC(slot) \ + if (p_inputs[slot].ends_with("def")) { \ + Vector3 v = p_node->defaults[slot]; \ + code += String(typestr[1]) + " " + p_inputs[slot] + "=vec3(" + v + ");\n"; \ } -#define DEF_SCALAR(slot)\ - if (p_inputs[slot].ends_with("def")){\ - double v = p_node->defaults[slot];\ - code+=String(typestr[0])+" "+p_inputs[slot]+"="+rtos(v)+";\n";\ +#define DEF_SCALAR(slot) \ + if (p_inputs[slot].ends_with("def")) { \ + double v = p_node->defaults[slot]; \ + code += String(typestr[0]) + " " + p_inputs[slot] + "=" + rtos(v) + ";\n"; \ } -#define DEF_COLOR(slot)\ - if (p_inputs[slot].ends_with("def")){\ - Color col = p_node->defaults[slot];\ - code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+rtos(col.r)+","+rtos(col.g)+","+rtos(col.b)+");\n";\ +#define DEF_COLOR(slot) \ + if (p_inputs[slot].ends_with("def")) { \ + Color col = p_node->defaults[slot]; \ + code += String(typestr[1]) + " " + p_inputs[slot] + "=vec3(" + rtos(col.r) + "," + rtos(col.g) + "," + rtos(col.b) + ");\n"; \ } -#define DEF_MATRIX(slot) \ - if (p_inputs[slot].ends_with("def")){\ - Transform xf = p_node->defaults[slot]; \ - code+=String(typestr[2])+" "+p_inputs[slot]+"=mat4(\n";\ - code+="\tvec4(vec3("+rtos(xf.basis.get_axis(0).x)+","+rtos(xf.basis.get_axis(0).y)+","+rtos(xf.basis.get_axis(0).z)+"),0),\n";\ - code+="\tvec4(vec3("+rtos(xf.basis.get_axis(1).x)+","+rtos(xf.basis.get_axis(1).y)+","+rtos(xf.basis.get_axis(1).z)+"),0),\n";\ - code+="\tvec4(vec3("+rtos(xf.basis.get_axis(2).x)+","+rtos(xf.basis.get_axis(2).y)+","+rtos(xf.basis.get_axis(2).z)+"),0),\n";\ - code+="\tvec4(vec3("+rtos(xf.origin.x)+","+rtos(xf.origin.y)+","+rtos(xf.origin.z)+"),1)\n";\ - code+=");\n";\ +#define DEF_MATRIX(slot) \ + if (p_inputs[slot].ends_with("def")) { \ + Transform xf = p_node->defaults[slot]; \ + code += String(typestr[2]) + " " + p_inputs[slot] + "=mat4(\n"; \ + code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(0).x) + "," + rtos(xf.basis.get_axis(0).y) + "," + rtos(xf.basis.get_axis(0).z) + "),0),\n"; \ + code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(1).x) + "," + rtos(xf.basis.get_axis(1).y) + "," + rtos(xf.basis.get_axis(1).z) + "),0),\n"; \ + code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(2).x) + "," + rtos(xf.basis.get_axis(2).y) + "," + rtos(xf.basis.get_axis(2).z) + "),0),\n"; \ + code += "\tvec4(vec3(" + rtos(xf.origin.x) + "," + rtos(xf.origin.y) + "," + rtos(xf.origin.z) + "),1)\n"; \ + code += ");\n"; \ } switch(p_node->type) { |
