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
This commit is contained in:
Hallam Roberts 2022-03-08 14:39:58 -06:00 committed by Hans Goudey
parent d09695b4dd
commit 156e07232e
1 changed files with 1 additions and 1 deletions

View File

@ -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);