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:
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c8
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp4
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c7
3 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 8cc5c31a4c7..1dc7c21f1d4 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -387,6 +387,14 @@ MINLINE float wrapf(float value, float max, float min)
return (range != 0.0f) ? value - (range * floorf((value - min) / range)) : min;
}
+MINLINE float pingpongf(float value, float scale)
+{
+ if (scale == 0.0f) {
+ return 0.0f;
+ }
+ return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale);
+}
+
// Square.
MINLINE int square_s(short a)
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index edd5bb6d139..dbec6dd1874 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -671,9 +671,7 @@ void MathPingpongOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = fabsf(fractf((inputValue1[0] - inputValue2[0]) / (inputValue2[0] * 2.0f)) *
- inputValue2[0] * 2.0f -
- inputValue2[0]);
+ output[0] = pingpongf(inputValue1[0], inputValue2[0]);
clampIfNeeded(output);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 134a0ebb093..53022c9e120 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -282,12 +282,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_PINGPONG: {
- if (in1 == 0.0f) {
- *out = 0.0f;
- }
- else {
- *out = fabsf(fractf((in0 - in1) / (in1 * 2.0f)) * in1 * 2.0f - in1);
- }
+ *out = pingpongf(in0, in1);
break;
}