[Bf-blender-cvs] [156e07232e7] master: Geometry Nodes: Tiny optimization to UV Sphere primitive

Hallam Roberts noreply at git.blender.org
Tue Mar 8 21:40:12 CET 2022


Commit: 156e07232e79d53fa3f43d4bcfc4b0c4061331e5
Author: Hallam Roberts
Date:   Tue Mar 8 14:39:58 2022 -0600
Branches: master
https://developer.blender.org/rB156e07232e79d53fa3f43d4bcfc4b0c4061331e5

Geometry Nodes: Tiny optimization to UV Sphere primitive

Prevents a few unneeded calls to `std::sin`, with an observed
performance improvement of about 1 percent.

Differential Revision: https://developer.blender.org/D14279

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

M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
index 4a09fd8d1d2..4e0e5c7c912 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
@@ -76,10 +76,10 @@ static void calculate_sphere_vertex_data(MutableSpan<MVert> verts,
   int vert_index = 1;
   for (const int ring : IndexRange(1, rings - 1)) {
     const float theta = ring * delta_theta;
+    const float sin_theta = std::sin(theta);
     const float z = std::cos(theta);
     for (const int segment : IndexRange(1, segments)) {
       const float phi = segment * delta_phi;
-      const float sin_theta = std::sin(theta);
       const float x = sin_theta * std::cos(phi);
       const float y = sin_theta * std::sin(phi);
       copy_v3_v3(verts[vert_index].co, float3(x, y, z) * radius);



More information about the Bf-blender-cvs mailing list