From cd5e1ff74e4f6443f3e4b836dd23fe46b56cb7ed Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 13 Jun 2014 21:13:18 +0200 Subject: Cycles Refactor: Add SSE Utility code from Embree for cleaner SSE code. This makes the code a bit easier to understand, and might come in handy if we want to reuse more Embree code. Differential Revision: https://developer.blender.org/D482 Code by Brecht, with fixes by Lockal, Sergey and myself. --- intern/cycles/render/curves.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'intern/cycles/render/curves.cpp') diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp index 2c96ffa655e..dc7665fe144 100644 --- a/intern/cycles/render/curves.cpp +++ b/intern/cycles/render/curves.cpp @@ -46,8 +46,9 @@ void curvebounds(float *lower, float *upper, float3 *p, int dim) float discroot = curve_coef[2] * curve_coef[2] - 3 * curve_coef[3] * curve_coef[1]; float ta = -1.0f; float tb = -1.0f; + if(discroot >= 0) { - discroot = sqrt(discroot); + discroot = sqrtf(discroot); ta = (-curve_coef[2] - discroot) / (3 * curve_coef[3]); tb = (-curve_coef[2] + discroot) / (3 * curve_coef[3]); ta = (ta > 1.0f || ta < 0.0f) ? -1.0f : ta; @@ -56,20 +57,21 @@ void curvebounds(float *lower, float *upper, float3 *p, int dim) *upper = max(p1[dim],p2[dim]); *lower = min(p1[dim],p2[dim]); + float exa = p1[dim]; float exb = p2[dim]; - float t2; - float t3; + if(ta >= 0.0f) { - t2 = ta * ta; - t3 = t2 * ta; + float t2 = ta * ta; + float t3 = t2 * ta; exa = curve_coef[3] * t3 + curve_coef[2] * t2 + curve_coef[1] * ta + curve_coef[0]; } if(tb >= 0.0f) { - t2 = tb * tb; - t3 = t2 * tb; + float t2 = tb * tb; + float t3 = t2 * tb; exb = curve_coef[3] * t3 + curve_coef[2] * t2 + curve_coef[1] * tb + curve_coef[0]; } + *upper = max(*upper, max(exa,exb)); *lower = min(*lower, min(exa,exb)); } -- cgit v1.2.3