[Bf-blender-cvs] [e5d4a0c5596] master: BLI: add double version of 'scaleform'

Germano Cavalcante noreply at git.blender.org
Wed Aug 4 15:47:16 CEST 2021


Commit: e5d4a0c5596daaae14251872755df1e71e54e108
Author: Germano Cavalcante
Date:   Wed Aug 4 10:38:03 2021 -0300
Branches: master
https://developer.blender.org/rBe5d4a0c5596daaae14251872755df1e71e54e108

BLI: add double version of 'scaleform'

No functional changes. New utility.

===================================================================

M	source/blender/blenlib/BLI_math_base.h
M	source/blender/blenlib/intern/math_base_inline.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 88dc20a64f2..e877503e835 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -120,6 +120,9 @@ MINLINE double interpd(double a, double b, double t);
 MINLINE float ratiof(float min, float max, float pos);
 MINLINE double ratiod(double min, double max, double pos);
 
+MINLINE float scalenorm(float a, float b, float x);
+MINLINE double scalenormd(double a, double b, double x);
+
 /* NOTE: Compilers will upcast all types smaller than int to int when performing arithmetic
  * operation. */
 MINLINE int square_s(short a);
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 6e3846e59c6..a80c495ecf3 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -199,6 +199,13 @@ MINLINE float scalenorm(float a, float b, float x)
   return (x * (b - a)) + a;
 }
 
+/* Map a normalized value, i.e. from interval [0, 1] to interval [a, b]. */
+MINLINE double scalenormd(double a, double b, double x)
+{
+  BLI_assert(x <= 1 && x >= 0);
+  return (x * (b - a)) + a;
+}
+
 /* Used for zoom values. */
 MINLINE float power_of_2(float val)
 {



More information about the Bf-blender-cvs mailing list