Cycles :
authorThomas Dinges <blender@dingto.org>
Tue, 14 May 2013 18:31:55 +0000 (18:31 +0000)
committerThomas Dinges <blender@dingto.org>
Tue, 14 May 2013 18:31:55 +0000 (18:31 +0000)
* Use is_zero(a) rather than dot(a, a) == 0, saves some calculations.

intern/cycles/bvh/bvh.cpp
intern/cycles/kernel/kernel_camera.h
intern/cycles/kernel/kernel_light.h

index 5732efef357a94243fe8a3c89f5f1446e4020fbb..82a444bda76662c87552706abf7d0426d11bcab4 100644 (file)
@@ -32,6 +32,7 @@
 #include "util_progress.h"
 #include "util_system.h"
 #include "util_types.h"
+#include "util_math.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -251,7 +252,7 @@ void BVH::pack_triangle(int idx, float4 woop[3])
        float3 r1 = v1 - v2;
        float3 r2 = cross(r0, r1);
 
-       if(dot(r0, r0) == 0.0f || dot(r1, r1) == 0.0f || dot(r2, r2) == 0.0f) {
+       if(is_zero(r0) || is_zero(r1) || is_zero(r2)) {
                /* degenerate */
                woop[0] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
                woop[1] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
index 8bd09247339f7c4242f78bd96d55cb0184fb44fd..a23586a53a4d7bbdc3224ab17f78cd3bbc93639a 100644 (file)
@@ -187,7 +187,7 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
        }
 
        /* indicates ray should not receive any light, outside of the lens */
-       if(len_squared(ray->D) == 0.0f) {
+       if(is_zero(ray->D)) {   
                ray->t = 0.0f;
                return;
        }
index a4877acdc535a80d2618a6428a7e44cd146a24f9..c07f1ffe5a3d12285f66110c79566d4b32c96ba1 100644 (file)
@@ -492,7 +492,7 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object
        float r2 = P2.w;
        float3 tg = (float4_to_float3(P2) - float4_to_float3(P1)) / l;
        float3 xc = make_float3(tg.x * tg.z, tg.y * tg.z, -(tg.x * tg.x + tg.y * tg.y));
-       if (dot(xc, xc) == 0.0f)
+       if (is_zero(xc))
                xc = make_float3(tg.x * tg.y, -(tg.x * tg.x + tg.z * tg.z), tg.z * tg.y);
        xc = normalize(xc);
        float3 yc = cross(tg, xc);