Skip to content

Commit

Permalink
Merge pull request #4958 from nortikin/fix_torus_mk2_performance_v001
Browse files Browse the repository at this point in the history
fix torus function torus_verts performance.
  • Loading branch information
satabol authored Jul 24, 2023
2 parents 44e611d + 897753e commit 93ebe56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nodes/generator/torus_mk2.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def torus_verts(R, r, N1, N2, rPhase, sPhase, rExponent, sExponent, sTwist, Sepa
theta = a1 + rPhase # revolution angle
sin_theta = sin(theta) # cached for performance
cos_theta = cos(theta) # cached for performance
pow_cos_theta = pow(abs(cos_theta), rExponent) * sign(cos_theta)
pow_sin_theta = pow(abs(sin_theta), rExponent) * sign(sin_theta)
cx = R * cos_theta # torus tube center
cy = R * sin_theta # torus tube center

twist_angle = da2 * n1 / N1 * sTwist

Expand All @@ -67,8 +71,6 @@ def torus_verts(R, r, N1, N2, rPhase, sPhase, rExponent, sExponent, sTwist, Sepa

pow_cos_phi = pow(abs(cos_phi), sExponent) * sign(cos_phi)
pow_sin_phi = pow(abs(sin_phi), sExponent) * sign(sin_phi)
pow_cos_theta = pow(abs(cos_theta), rExponent) * sign(cos_theta)
pow_sin_theta = pow(abs(sin_theta), rExponent) * sign(sin_theta)

x = (R + r * pow_cos_phi) * pow_cos_theta
y = (R + r * pow_cos_phi) * pow_sin_theta
Expand All @@ -78,8 +80,6 @@ def torus_verts(R, r, N1, N2, rPhase, sPhase, rExponent, sExponent, sTwist, Sepa
add_vert([x, y, z])

# append normal
cx = R * cos_theta # torus tube center
cy = R * sin_theta # torus tube center
norm = [x - cx, y - cy, z]
list_norms.append(norm)

Expand Down

0 comments on commit 93ebe56

Please sign in to comment.