Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-05-14 22:31:55 +0400
committerThomas Dinges <blender@dingto.org>2013-05-14 22:31:55 +0400
commit1f3bf34ccd8b7b29560b819c72619fce7bfc7f4c (patch)
tree58eecca0c36cd3d3822b8b04b9a89cdcacc4f82c
parent6fc51bf20e48fd0565ccce928693455f6a12551c (diff)
Cycles :
* Use is_zero(a) rather than dot(a, a) == 0, saves some calculations.
-rw-r--r--intern/cycles/bvh/bvh.cpp3
-rw-r--r--intern/cycles/kernel/kernel_camera.h2
-rw-r--r--intern/cycles/kernel/kernel_light.h2
3 files changed, 4 insertions, 3 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 5732efef357..82a444bda76 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -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);
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h
index 8bd09247339..a23586a53a4 100644
--- a/intern/cycles/kernel/kernel_camera.h
+++ b/intern/cycles/kernel/kernel_camera.h
@@ -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;
}
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index a4877acdc53..c07f1ffe5a3 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -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);