forked from bartvdbraak/blender
Cycles :
* Use is_zero(a) rather than dot(a, a) == 0, saves some calculations.
This commit is contained in:
parent
6fc51bf20e
commit
1f3bf34ccd
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user