Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2018-05-24 03:51:41 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2018-05-24 17:46:02 +0300
commit68627626854c27c2135cab72b48b648cb638c8cb (patch)
tree0add4728e9bc6d198c57721e59921844e8980f5e /source/blender/nodes
parent8d9faf840b8f99255b9989d178e5e4a6f5ec7f87 (diff)
Cycles/Compositor: Add arctan2 operation to the Math node
The Math node currently has the normal atan() function, but for actual angles this is fairly useless without additional nodes to handle the signs. Since the node has two inputs anyways, it only makes sense to add an arctan2 option. Reviewers: sergey, brecht Differential Revision: https://developer.blender.org/D3430
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c7
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c6
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index 2a1e936570d..9fa906729dc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -221,6 +221,11 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode
r = fabsf(a);
break;
}
+ case NODE_MATH_ATAN2:
+ {
+ r = atan2(a, b);
+ break;
+ }
}
if (node->custom2 & SHD_MATH_CLAMP) {
CLAMP(r, 0.0f, 1.0f);
@@ -235,6 +240,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
"math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin",
"math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max",
"math_round", "math_less_than", "math_greater_than", "math_modulo", "math_abs",
+ "math_atan2"
};
switch (node->custom1) {
@@ -249,6 +255,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(
case NODE_MATH_LESS:
case NODE_MATH_GREATER:
case NODE_MATH_MOD:
+ case NODE_MATH_ATAN2:
GPU_stack_link(mat, names[node->custom1], in, out);
break;
case NODE_MATH_SIN:
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 19bc16fb82d..d8dc2a62625 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -189,6 +189,12 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
break;
}
+ case NODE_MATH_ATAN2:
+ {
+ *out = atan2(in0, in1);
+ break;
+ }
+
default:
{
BLI_assert(0);