[Bf-blender-cvs] [5627c8acea5] tmp-workbench-rewrite2: Replace sinf/cosf with math::sin/cos

Miguel Pozo noreply at git.blender.org
Tue Jan 10 15:55:19 CET 2023


Commit: 5627c8acea58e316164e39ddc883ffe8236e7599
Author: Miguel Pozo
Date:   Mon Jan 9 17:14:37 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB5627c8acea58e316164e39ddc883ffe8236e7599

Replace sinf/cosf with math::sin/cos

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

M	source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
M	source/blender/draw/engines/workbench/workbench_effect_cavity.cc
M	source/blender/draw/engines/workbench/workbench_effect_dof.cc
M	source/blender/draw/engines/workbench/workbench_resources.cc

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

diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
index 313aad6244e..94d15e7ff0f 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
@@ -82,7 +82,8 @@ static float filter_blackman_harris(float x, const float width)
     return 0.0f;
   }
   x = 2.0f * M_PI * clamp_f((x / width + 0.5f), 0.0f, 1.0f);
-  return 0.35875f - 0.48829f * cosf(x) + 0.14128f * cosf(2.0f * x) - 0.01168f * cosf(3.0f * x);
+  return 0.35875f - 0.48829f * math::cos(x) + 0.14128f * math::cos(2.0f * x) -
+         0.01168f * math::cos(3.0f * x);
 }
 
 /* Compute weights for the 3x3 neighborhood using a 1.5px filter. */
diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
index a87c0fa2ba1..31a419f733e 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
@@ -65,8 +65,8 @@ void CavityEffect::load_samples_buf(int ssao_samples)
     BLI_hammersley_1d(i, &dphi);
 
     float phi = (float)dphi * 2.0f * M_PI + it_add;
-    samples_buf[i].x = cosf(phi);
-    samples_buf[i].y = sinf(phi);
+    samples_buf[i].x = math::cos(phi);
+    samples_buf[i].y = math::sin(phi);
     /* This deliberately distribute more samples
      * at the center of the disk (and thus the shadow). */
     samples_buf[i].z = r;
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
index 11d5cd33f4c..0f80713fba9 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
@@ -75,13 +75,13 @@ void DofPass::setup_samples()
         /* Bokeh shape parameterization. */
         if (blades_ > 1.0f) {
           float denom = T - (2.0 * M_PI / blades_) * floorf((blades_ * T + M_PI) / (2.0 * M_PI));
-          r *= cosf(M_PI / blades_) / cosf(denom);
+          r *= math::cos(M_PI / blades_) / math::cos(denom);
         }
 
         T += rotation_;
 
-        sample->x = r * cosf(T) * ratio_;
-        sample->y = r * sinf(T);
+        sample->x = r * math::cos(T) * ratio_;
+        sample->y = r * math::sin(T);
         sample->w = 0;
         sample++;
       }
diff --git a/source/blender/draw/engines/workbench/workbench_resources.cc b/source/blender/draw/engines/workbench/workbench_resources.cc
index 556df6a5366..84d624d22d5 100644
--- a/source/blender/draw/engines/workbench/workbench_resources.cc
+++ b/source/blender/draw/engines/workbench/workbench_resources.cc
@@ -78,8 +78,8 @@ void SceneResources::load_jitter_tx(int total_samples)
   for (int i = 0; i < texel_count; i++) {
     float phi = blue_noise[i][0] * 2.0f * M_PI;
     /* This rotate the sample per pixels */
-    jitter[i].x = cosf(phi);
-    jitter[i].y = sinf(phi);
+    jitter[i].x = math::cos(phi);
+    jitter[i].y = math::sin(phi);
     /* This offset the sample along its direction axis (reduce banding) */
     float bn = blue_noise[i][1] - 0.5f;
     bn = clamp_f(bn, -0.499f, 0.499f); /* fix fireflies */



More information about the Bf-blender-cvs mailing list