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/compositor
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/compositor')
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp3
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp13
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h6
3 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index eb6bb2caf56..0fb6933afe7 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -86,6 +86,9 @@ void MathNode::convertToOperations(NodeConverter &converter, const CompositorCon
case NODE_MATH_ABS:
operation = new MathAbsoluteOperation();
break;
+ case NODE_MATH_ATAN2:
+ operation = new MathArcTan2Operation();
+ break;
}
if (operation) {
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index 32a1e77b9a7..dbc91980acd 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -343,3 +343,16 @@ void MathAbsoluteOperation::executePixelSampled(float output[4], float x, float
clampIfNeeded(output);
}
+
+void MathArcTan2Operation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+{
+ float inputValue1[4];
+ float inputValue2[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+
+ output[0] = atan2(inputValue1[0], inputValue2[0]);
+
+ clampIfNeeded(output);
+} \ No newline at end of file
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 32cd19f1fb9..04019372711 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -169,4 +169,10 @@ public:
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
+class MathArcTan2Operation : public MathBaseOperation {
+public:
+ MathArcTan2Operation() : MathBaseOperation() {}
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+};
+
#endif