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:
authorJacques Lucke <jacques@blender.org>2020-11-25 14:24:32 +0300
committerJacques Lucke <jacques@blender.org>2020-11-25 14:24:44 +0300
commit1c86d32fa7d4c367370d06b7983410f4c33d58a2 (patch)
treecdf9c9eb7de3b3e03da649f0be07026670837fa0 /source/blender/blenlib
parent9e77fc533c1387776900fcc91ed9591f33dd8bf2 (diff)
Nodes: deduplicate ping pong math operation
The formula did not change. The only side effect of this change should be that the compositor node now does not divide by zero in some cases.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c8
1 files changed, 8 insertions, 0 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)