* Revert r57203 (len() renaming)
There seems to be a problem with nVidia OpenCL after this and I haven't figured out the real cause yet. 
Better to selectively enable native length() later, after figuring out what's wrong. 

This fixes [#35612].
This commit is contained in:
Thomas Dinges
2013-06-04 17:20:00 +00:00
parent 4a7f37f6ed
commit 9e4914e055
22 changed files with 75 additions and 74 deletions

View File

@@ -224,7 +224,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
float3 cKey = make_float3(nco[0],nco[1],nco[2]); float3 cKey = make_float3(nco[0],nco[1],nco[2]);
cKey = transform_point(&itfm, cKey); cKey = transform_point(&itfm, cKey);
if(step_no > 0) if(step_no > 0)
curve_length += length(cKey - pcKey); curve_length += len(cKey - pcKey);
CData->curvekey_co.push_back(cKey); CData->curvekey_co.push_back(cKey);
CData->curvekey_time.push_back(curve_length); CData->curvekey_time.push_back(curve_length);
pcKey = cKey; pcKey = cKey;
@@ -473,7 +473,7 @@ void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interp
for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
float3 firstxbasis = cross(make_float3(1.0f,0.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]); float3 firstxbasis = cross(make_float3(1.0f,0.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]);
if(length_squared(firstxbasis)!= 0.0f) if(len_squared(firstxbasis)!= 0.0f)
firstxbasis = normalize(firstxbasis); firstxbasis = normalize(firstxbasis);
else else
firstxbasis = normalize(cross(make_float3(0.0f,1.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]])); firstxbasis = normalize(cross(make_float3(0.0f,1.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]));
@@ -499,7 +499,7 @@ void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interp
xbasis = cross(v1,v2); xbasis = cross(v1,v2);
if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) {
firstxbasis = normalize(xbasis); firstxbasis = normalize(xbasis);
break; break;
} }
@@ -528,7 +528,7 @@ void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interp
xbasis = cross(v1,v2); xbasis = cross(v1,v2);
if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) {
xbasis = normalize(xbasis); xbasis = normalize(xbasis);
firstxbasis = xbasis; firstxbasis = xbasis;
} }
@@ -586,7 +586,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int inter
for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
float3 firstxbasis = cross(make_float3(1.0f,0.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]); float3 firstxbasis = cross(make_float3(1.0f,0.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]);
if(length_squared(firstxbasis)!= 0.0f) if(len_squared(firstxbasis)!= 0.0f)
firstxbasis = normalize(firstxbasis); firstxbasis = normalize(firstxbasis);
else else
firstxbasis = normalize(cross(make_float3(0.0f,1.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]])); firstxbasis = normalize(cross(make_float3(0.0f,1.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]));
@@ -613,7 +613,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int inter
xbasis = cross(v1,v2); xbasis = cross(v1,v2);
if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) {
firstxbasis = normalize(xbasis); firstxbasis = normalize(xbasis);
break; break;
} }
@@ -643,7 +643,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int inter
xbasis = cross(v1,v2); xbasis = cross(v1,v2);
if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) {
xbasis = normalize(xbasis); xbasis = normalize(xbasis);
firstxbasis = xbasis; firstxbasis = xbasis;
} }

View File

@@ -237,8 +237,8 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
bool smooth = f->use_smooth(); bool smooth = f->use_smooth();
if(n == 4) { if(n == 4) {
if(length_squared(cross(mesh->verts[vi[1]] - mesh->verts[vi[0]], mesh->verts[vi[2]] - mesh->verts[vi[0]])) == 0.0f || if(len_squared(cross(mesh->verts[vi[1]] - mesh->verts[vi[0]], mesh->verts[vi[2]] - mesh->verts[vi[0]])) == 0.0f ||
length_squared(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]])) == 0.0f) { len_squared(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - mesh->verts[vi[0]])) == 0.0f) {
mesh->add_triangle(vi[0], vi[1], vi[3], shader, smooth); mesh->add_triangle(vi[0], vi[1], vi[3], shader, smooth);
mesh->add_triangle(vi[2], vi[3], vi[1], shader, smooth); mesh->add_triangle(vi[2], vi[3], vi[1], shader, smooth);
} }

View File

@@ -287,7 +287,7 @@ void BVH::pack_curve_segment(int idx, float4 woop[3])
float3 v1 = mesh->curve_keys[k1].co; float3 v1 = mesh->curve_keys[k1].co;
float3 d0 = v1 - v0; float3 d0 = v1 - v0;
float l = length(d0); float l = len(d0);
/*Plan /*Plan
*Transform tfm = make_transform( *Transform tfm = make_transform(

View File

@@ -64,7 +64,7 @@ __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray
float3 dir = transform_direction(&tfm, ray->D); float3 dir = transform_direction(&tfm, ray->D);
float len; float len;
dir = normalize_length(dir, &len); dir = normalize_len(dir, &len);
*idir = bvh_inverse_direction(dir); *idir = bvh_inverse_direction(dir);
@@ -76,7 +76,7 @@ __device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *
{ {
if(*t != FLT_MAX) { if(*t != FLT_MAX) {
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
*t *= length(transform_direction(&tfm, 1.0f/(*idir))); *t *= len(transform_direction(&tfm, 1.0f/(*idir)));
} }
*P = ray->P; *P = ray->P;
@@ -94,7 +94,7 @@ __device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, con
float3 dir = transform_direction(&itfm, ray->D); float3 dir = transform_direction(&itfm, ray->D);
float len; float len;
dir = normalize_length(dir, &len); dir = normalize_len(dir, &len);
*idir = bvh_inverse_direction(dir); *idir = bvh_inverse_direction(dir);
@@ -105,7 +105,7 @@ __device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, con
__device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax) __device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
{ {
if(*t != FLT_MAX) if(*t != FLT_MAX)
*t *= length(transform_direction(tfm, 1.0f/(*idir))); *t *= len(transform_direction(tfm, 1.0f/(*idir)));
*P = ray->P; *P = ray->P;
*idir = bvh_inverse_direction(ray->D); *idir = bvh_inverse_direction(ray->D);
@@ -489,14 +489,14 @@ __device_inline void bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
t = p_curr.z; t = p_curr.z;
} }
else { else {
float l = length(p_en - p_st); float l = len(p_en - p_st);
/*minimum width extension*/ /*minimum width extension*/
float or1 = r1; float or1 = r1;
float or2 = r2; float or2 = r2;
if(difl != 0.0f) { if(difl != 0.0f) {
mw_extension = min(length(p_st - P) * difl, extmax); mw_extension = min(len(p_st - P) * difl, extmax);
or1 = r1 < mw_extension ? mw_extension : r1; or1 = r1 < mw_extension ? mw_extension : r1;
mw_extension = min(length(p_en - P) * difl, extmax); mw_extension = min(len(p_en - P) * difl, extmax);
or2 = r2 < mw_extension ? mw_extension : r2; or2 = r2 < mw_extension ? mw_extension : r2;
} }
/* --- */ /* --- */
@@ -611,9 +611,9 @@ __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
float r1 = or1; float r1 = or1;
float r2 = or2; float r2 = or2;
if(difl != 0.0f) { if(difl != 0.0f) {
float pixelsize = min(length(p1 - P) * difl, extmax); float pixelsize = min(len(p1 - P) * difl, extmax);
r1 = or1 < pixelsize ? pixelsize : or1; r1 = or1 < pixelsize ? pixelsize : or1;
pixelsize = min(length(p2 - P) * difl, extmax); pixelsize = min(len(p2 - P) * difl, extmax);
r2 = or2 < pixelsize ? pixelsize : or2; r2 = or2 < pixelsize ? pixelsize : or2;
} }
/* --- */ /* --- */
@@ -621,14 +621,14 @@ __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
float mr = max(r1,r2); float mr = max(r1,r2);
float3 dif = P - p1; float3 dif = P - p1;
float3 dir = 1.0f/idir; float3 dir = 1.0f/idir;
float l = length(p2 - p1); float l = len(p2 - p1);
float sp_r = mr + 0.5f * l; float sp_r = mr + 0.5f * l;
float3 sphere_dif = P - ((p1 + p2) * 0.5f); float3 sphere_dif = P - ((p1 + p2) * 0.5f);
float sphere_b = dot(dir,sphere_dif); float sphere_b = dot(dir,sphere_dif);
sphere_dif = sphere_dif - sphere_b * dir; sphere_dif = sphere_dif - sphere_b * dir;
sphere_b = dot(dir,sphere_dif); sphere_b = dot(dir,sphere_dif);
float sdisc = sphere_b * sphere_b - length_squared(sphere_dif) + sp_r * sp_r; float sdisc = sphere_b * sphere_b - len_squared(sphere_dif) + sp_r * sp_r;
if(sdisc < 0.0f) if(sdisc < 0.0f)
return; return;
@@ -652,8 +652,8 @@ __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
/* test minimum separation*/ /* test minimum separation*/
float3 cprod = cross(tg, dir); float3 cprod = cross(tg, dir);
float3 cprod2 = cross(tg, dif); float3 cprod2 = cross(tg, dif);
float cprodsq = length_squared(cprod); float cprodsq = len_squared(cprod);
float cprod2sq = length_squared(cprod2); float cprod2sq = len_squared(cprod2);
float distscaled = dot(cprod,dif); float distscaled = dot(cprod,dif);
if(cprodsq == 0) if(cprodsq == 0)
@@ -1010,7 +1010,7 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, co
P = transform_point(&tfm, P); P = transform_point(&tfm, P);
D = transform_direction(&tfm, D*t); D = transform_direction(&tfm, D*t);
D = normalize_length(D, &t); D = normalize_len(D, &t);
} }
P = P + D*t; P = P + D*t;
@@ -1080,7 +1080,7 @@ __device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const
P = transform_point(&tfm, P); P = transform_point(&tfm, P);
D = transform_direction(&tfm, D*t); D = transform_direction(&tfm, D*t);
D = normalize_length(D, &t); D = normalize_len(D, &t);
} }
int prim = kernel_tex_fetch(__prim_index, isect->prim); int prim = kernel_tex_fetch(__prim_index, isect->prim);
@@ -1092,7 +1092,7 @@ __device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const
float4 P1 = kernel_tex_fetch(__curve_keys, k0); float4 P1 = kernel_tex_fetch(__curve_keys, k0);
float4 P2 = kernel_tex_fetch(__curve_keys, k1); float4 P2 = kernel_tex_fetch(__curve_keys, k1);
float l = 1.0f; float l = 1.0f;
float3 tg = normalize_length(float4_to_float3(P2 - P1),&l); float3 tg = normalize_len(float4_to_float3(P2 - P1),&l);
float r1 = P1.w; float r1 = P1.w;
float r2 = P2.w; float r2 = P2.w;
float gd = ((r2 - r1)/l); float gd = ((r2 - r1)/l);

View File

@@ -255,7 +255,7 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P)
return fabsf(dot((P - camP), camD)); return fabsf(dot((P - camP), camD));
} }
else else
return length(P - camP); return len(P - camP);
} }
CCL_NAMESPACE_END CCL_NAMESPACE_END

View File

@@ -122,7 +122,7 @@ __device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
if(sd->segment != ~0) { if(sd->segment != ~0) {
float normalmix = kernel_data.curve_kernel_data.normalmix; float normalmix = kernel_data.curve_kernel_data.normalmix;
tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) * normalmix / length_squared(sd->dPdu))); tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) * normalmix / len_squared(sd->dPdu)));
tgN = normalize(tgN); tgN = normalize(tgN);
/* need to find suitable scaled gd for corrected normal */ /* need to find suitable scaled gd for corrected normal */

View File

@@ -133,7 +133,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li
else { else {
/* other lights, avoid self-intersection */ /* other lights, avoid self-intersection */
ray->D = ray_offset(ls.P, ls.Ng) - ray->P; ray->D = ray_offset(ls.P, ls.Ng) - ray->P;
ray->D = normalize_length(ray->D, &ray->t); ray->D = normalize_len(ray->D, &ray->t);
} }
ray->dP = sd->dP; ray->dP = sd->dP;

View File

@@ -263,7 +263,7 @@ __device void lamp_light_sample(KernelGlobals *kg, int lamp,
/* sphere light */ /* sphere light */
ls->P += sphere_light_sample(P, ls->P, radius, randu, randv); ls->P += sphere_light_sample(P, ls->P, radius, randu, randv);
ls->D = normalize_length(ls->P - P, &ls->t); ls->D = normalize_len(ls->P - P, &ls->t);
ls->Ng = -ls->D; ls->Ng = -ls->D;
float invarea = data1.z; float invarea = data1.z;
@@ -287,7 +287,7 @@ __device void lamp_light_sample(KernelGlobals *kg, int lamp,
ls->P += area_light_sample(axisu, axisv, randu, randv); ls->P += area_light_sample(axisu, axisv, randu, randv);
ls->Ng = D; ls->Ng = D;
ls->D = normalize_length(ls->P - P, &ls->t); ls->D = normalize_len(ls->P - P, &ls->t);
float invarea = data2.x; float invarea = data2.x;
@@ -487,7 +487,7 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object
float4 P1 = kernel_tex_fetch(__curve_keys, k0); float4 P1 = kernel_tex_fetch(__curve_keys, k0);
float4 P2 = kernel_tex_fetch(__curve_keys, k1); float4 P2 = kernel_tex_fetch(__curve_keys, k1);
float l = length(float4_to_float3(P2) - float4_to_float3(P1)); float l = len(float4_to_float3(P2) - float4_to_float3(P1));
float r1 = P1.w; float r1 = P1.w;
float r2 = P2.w; float r2 = P2.w;
@@ -569,7 +569,7 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
triangle_light_sample(kg, prim, object, randu, randv, time, ls); triangle_light_sample(kg, prim, object, randu, randv, time, ls);
/* compute incoming direction, distance and pdf */ /* compute incoming direction, distance and pdf */
ls->D = normalize_length(ls->P - P, &ls->t); ls->D = normalize_len(ls->P - P, &ls->t);
ls->pdf = triangle_light_pdf(kg, ls->Ng, -ls->D, ls->t); ls->pdf = triangle_light_pdf(kg, ls->Ng, -ls->D, ls->t);
} }
else { else {

View File

@@ -222,7 +222,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
ray->P = ray_offset(sd.P, -sd.Ng); ray->P = ray_offset(sd.P, -sd.Ng);
if(ray->t != FLT_MAX) if(ray->t != FLT_MAX)
ray->D = normalize_length(Pend - ray->P, &ray->t); ray->D = normalize_len(Pend - ray->P, &ray->t);
bounce++; bounce++;
} }
@@ -266,7 +266,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) { if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) {
float3 pixdiff = ray.dD.dx + ray.dD.dy; float3 pixdiff = ray.dD.dx + ray.dD.dy;
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/ /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
difl = kernel_data.curve_kernel_data.minimum_width * length(pixdiff) * 0.5f; difl = kernel_data.curve_kernel_data.minimum_width * len(pixdiff) * 0.5f;
} }
extmax = kernel_data.curve_kernel_data.maximum_width; extmax = kernel_data.curve_kernel_data.maximum_width;
@@ -957,7 +957,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) { if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) {
float3 pixdiff = ray.dD.dx + ray.dD.dy; float3 pixdiff = ray.dD.dx + ray.dD.dy;
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/ /*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
difl = kernel_data.curve_kernel_data.minimum_width * length(pixdiff) * 0.5f; difl = kernel_data.curve_kernel_data.minimum_width * len(pixdiff) * 0.5f;
} }
extmax = kernel_data.curve_kernel_data.maximum_width; extmax = kernel_data.curve_kernel_data.maximum_width;

View File

@@ -201,7 +201,7 @@ __device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, int sta
/* create ray */ /* create ray */
Ray ray; Ray ray;
ray.P = p1; ray.P = p1;
ray.D = normalize_length(p2 - p1, &ray.t); ray.D = normalize_len(p2 - p1, &ray.t);
ray.dP = sd->dP; ray.dP = sd->dP;
ray.dD = differential3_zero(); ray.dD = differential3_zero();
ray.time = sd->time; ray.time = sd->time;

View File

@@ -27,7 +27,7 @@ __device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, u
Transform tfm = kernel_data.cam.worldtocamera; Transform tfm = kernel_data.cam.worldtocamera;
vector = transform_point(&tfm, sd->P); vector = transform_point(&tfm, sd->P);
zdepth = vector.z; zdepth = vector.z;
distance = length(vector); distance = len(vector);
if (stack_valid(out_vector)) if (stack_valid(out_vector))
stack_store_float3(stack, out_vector, normalize(vector)); stack_store_float3(stack, out_vector, normalize(vector));

View File

@@ -82,7 +82,7 @@ __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, f
*Fac = average_fac(*Vector); *Fac = average_fac(*Vector);
} }
else if(type == NODE_VECTOR_MATH_AVERAGE) { else if(type == NODE_VECTOR_MATH_AVERAGE) {
*Fac = length(Vector1 + Vector2); *Fac = len(Vector1 + Vector2);
*Vector = normalize(Vector1 + Vector2); *Vector = normalize(Vector1 + Vector2);
} }
else if(type == NODE_VECTOR_MATH_DOT_PRODUCT) { else if(type == NODE_VECTOR_MATH_DOT_PRODUCT) {
@@ -91,11 +91,11 @@ __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, f
} }
else if(type == NODE_VECTOR_MATH_CROSS_PRODUCT) { else if(type == NODE_VECTOR_MATH_CROSS_PRODUCT) {
float3 c = cross(Vector1, Vector2); float3 c = cross(Vector1, Vector2);
*Fac = length(c); *Fac = len(c);
*Vector = normalize(c); *Vector = normalize(c);
} }
else if(type == NODE_VECTOR_MATH_NORMALIZE) { else if(type == NODE_VECTOR_MATH_NORMALIZE) {
*Fac = length(Vector1); *Fac = len(Vector1);
*Vector = normalize(Vector1); *Vector = normalize(Vector1);
} }
else { else {

View File

@@ -25,7 +25,7 @@ __device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, fl
if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED) if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED)
return dot(d, d); return dot(d, d);
if(distance_metric == NODE_VORONOI_ACTUAL_DISTANCE) if(distance_metric == NODE_VORONOI_ACTUAL_DISTANCE)
return length(d); return len(d);
if(distance_metric == NODE_VORONOI_MANHATTAN) if(distance_metric == NODE_VORONOI_MANHATTAN)
return fabsf(d.x) + fabsf(d.y) + fabsf(d.z); return fabsf(d.x) + fabsf(d.y) + fabsf(d.z);
if(distance_metric == NODE_VORONOI_CHEBYCHEV) if(distance_metric == NODE_VORONOI_CHEBYCHEV)

View File

@@ -29,7 +29,7 @@ __device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float
if(type == NODE_WAVE_BANDS) if(type == NODE_WAVE_BANDS)
n = (p.x + p.y + p.z) * 10.0f; n = (p.x + p.y + p.z) * 10.0f;
else /* if(type == NODE_WAVE_RINGS) */ else /* if(type == NODE_WAVE_RINGS) */
n = length(p) * 20.0f; n = len(p) * 20.0f;
if(distortion != 0.0f) if(distortion != 0.0f)
n += distortion * noise_turbulence(p*dscale, NODE_NOISE_PERLIN, detail, 0); n += distortion * noise_turbulence(p*dscale, NODE_NOISE_PERLIN, detail, 0);

View File

@@ -66,8 +66,8 @@ __device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack
if(pixel_size) { if(pixel_size) {
// Project the derivatives of P to the viewing plane defined // Project the derivatives of P to the viewing plane defined
// by I so we have a measure of how big is a pixel at this point // by I so we have a measure of how big is a pixel at this point
float pixelwidth_x = length(sd->dP.dx - dot(sd->dP.dx, sd->I) * sd->I); float pixelwidth_x = len(sd->dP.dx - dot(sd->dP.dx, sd->I) * sd->I);
float pixelwidth_y = length(sd->dP.dy - dot(sd->dP.dy, sd->I) * sd->I); float pixelwidth_y = len(sd->dP.dy - dot(sd->dP.dy, sd->I) * sd->I);
// Take the average of both axis' length // Take the average of both axis' length
pixelwidth = (pixelwidth_x + pixelwidth_y) * 0.5f; pixelwidth = (pixelwidth_x + pixelwidth_y) * 0.5f;
} }

View File

@@ -276,7 +276,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
p2 = transform_point(&tfm, p2); p2 = transform_point(&tfm, p2);
} }
totarea += M_PI_F * (r1 + r2) * length(p1 - p2); totarea += M_PI_F * (r1 + r2) * len(p1 - p2);
} }
} }
@@ -547,7 +547,7 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
else if(light->type == LIGHT_AREA) { else if(light->type == LIGHT_AREA) {
float3 axisu = light->axisu*(light->sizeu*light->size); float3 axisu = light->axisu*(light->sizeu*light->size);
float3 axisv = light->axisv*(light->sizev*light->size); float3 axisv = light->axisv*(light->sizev*light->size);
float area = length(axisu)*length(axisv); float area = len(axisu)*len(axisv);
float invarea = (area > 0.0f)? 1.0f/area: 1.0f; float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
if(light->use_mis && area > 0.0f) if(light->use_mis && area > 0.0f)

View File

@@ -187,7 +187,7 @@ void Mesh::add_face_normals()
float3 v2 = verts_ptr[t.v[2]]; float3 v2 = verts_ptr[t.v[2]];
float3 norm = cross(v1 - v0, v2 - v0); float3 norm = cross(v1 - v0, v2 - v0);
float normlen = length(norm); float normlen = len(norm);
if(normlen == 0.0f) if(normlen == 0.0f)
fN[i] = make_float3(0.0f, 0.0f, 0.0f); fN[i] = make_float3(0.0f, 0.0f, 0.0f);
else else

View File

@@ -200,7 +200,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
float r2 = mesh->curve_keys[first_key + i + 1].radius; float r2 = mesh->curve_keys[first_key + i + 1].radius;
/* currently ignores segment overlaps*/ /* currently ignores segment overlaps*/
surface_area += M_PI_F *(r1 + r2) * length(p1 - p2); surface_area += M_PI_F *(r1 + r2) * len(p1 - p2);
} }
} }
@@ -233,7 +233,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
p2 = transform_point(&tfm, p2); p2 = transform_point(&tfm, p2);
/* currently ignores segment overlaps*/ /* currently ignores segment overlaps*/
surface_area += M_PI_F *(r1 + r2) * length(p1 - p2); surface_area += M_PI_F *(r1 + r2) * len(p1 - p2);
} }
} }
} }

View File

@@ -98,8 +98,8 @@ void EdgeDice::stitch_triangles(vector<int>& outer, vector<int>& inner)
} }
else { else {
/* length of diagonals */ /* length of diagonals */
float len1 = length(mesh_P[inner[i]] - mesh_P[outer[j+1]]); float len1 = len(mesh_P[inner[i]] - mesh_P[outer[j+1]]);
float len2 = length(mesh_P[outer[j]] - mesh_P[inner[i+1]]); float len2 = len(mesh_P[outer[j]] - mesh_P[inner[i+1]]);
/* use smallest diagonal */ /* use smallest diagonal */
if(len1 < len2) if(len1 < len2)

View File

@@ -74,7 +74,7 @@ int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend)
float3 P = project(patch, Pstart + t*(Pend - Pstart)); float3 P = project(patch, Pstart + t*(Pend - Pstart));
if(i > 0) { if(i > 0) {
float L = length(P - Plast); float L = len(P - Plast);
Lsum += L; Lsum += L;
Lmax = max(L, Lmax); Lmax = max(L, Lmax);
} }

View File

@@ -296,19 +296,19 @@ __device_inline bool operator==(const int2 a, const int2 b)
return (a.x == b.x && a.y == b.y); return (a.x == b.x && a.y == b.y);
} }
__device_inline float length(const float2 a) __device_inline float len(const float2 a)
{ {
return sqrtf(dot(a, a)); return sqrtf(dot(a, a));
} }
__device_inline float2 normalize(const float2 a) __device_inline float2 normalize(const float2 a)
{ {
return a/length(a); return a/len(a);
} }
__device_inline float2 normalize_length(const float2 a, float *t) __device_inline float2 normalize_len(const float2 a, float *t)
{ {
*t = length(a); *t = len(a);
return a/(*t); return a/(*t);
} }
@@ -454,13 +454,14 @@ __device_inline float3 cross(const float3 a, const float3 b)
return r; return r;
} }
__device_inline float length(const float3 a) #endif
__device_inline float len(const float3 a)
{ {
return sqrtf(dot(a, a)); return sqrtf(dot(a, a));
} }
#endif
__device_inline float length_squared(const float3 a) __device_inline float len_squared(const float3 a)
{ {
return dot(a, a); return dot(a, a);
} }
@@ -469,14 +470,14 @@ __device_inline float length_squared(const float3 a)
__device_inline float3 normalize(const float3 a) __device_inline float3 normalize(const float3 a)
{ {
return a/length(a); return a/len(a);
} }
#endif #endif
__device_inline float3 normalize_length(const float3 a, float *t) __device_inline float3 normalize_len(const float3 a, float *t)
{ {
*t = length(a); *t = len(a);
return a/(*t); return a/(*t);
} }
@@ -786,14 +787,14 @@ __device_inline float dot(const float4& a, const float4& b)
return reduce_add(a * b); return reduce_add(a * b);
} }
__device_inline float length(const float4 a) __device_inline float len(const float4 a)
{ {
return sqrtf(dot(a, a)); return sqrtf(dot(a, a));
} }
__device_inline float4 normalize(const float4 a) __device_inline float4 normalize(const float4 a)
{ {
return a/length(a); return a/len(a);
} }
__device_inline float4 min(float4 a, float4 b) __device_inline float4 min(float4 a, float4 b)
@@ -1049,7 +1050,7 @@ template<class A, class B> A lerp(const A& a, const A& b, const B& t)
__device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3) __device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3)
{ {
return length(cross(v3 - v2, v1 - v2))*0.5f; return len(cross(v3 - v2, v1 - v2))*0.5f;
} }
#endif #endif
@@ -1211,7 +1212,7 @@ __device bool ray_aligned_disk_intersect(
{ {
/* aligned disk normal */ /* aligned disk normal */
float disk_t; float disk_t;
float3 disk_N = normalize_length(ray_P - disk_P, &disk_t); float3 disk_N = normalize_len(ray_P - disk_P, &disk_t);
float div = dot(ray_D, disk_N); float div = dot(ray_D, disk_N);
if(div == 0.0f) if(div == 0.0f)
@@ -1224,7 +1225,7 @@ __device bool ray_aligned_disk_intersect(
/* test if within radius */ /* test if within radius */
float3 P = ray_P + ray_D*t; float3 P = ray_P + ray_D*t;
if(length_squared(P - disk_P) > disk_radius*disk_radius) if(len_squared(P - disk_P) > disk_radius*disk_radius)
return false; return false;
*isect_P = P; *isect_P = P;

View File

@@ -268,12 +268,12 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
Transform ttfm = transform_transpose(tfm); Transform ttfm = transform_transpose(tfm);
float eps = 1e-6f; float eps = 1e-6f;
float sx = length_squared(float4_to_float3(tfm.x)); float sx = len_squared(float4_to_float3(tfm.x));
float sy = length_squared(float4_to_float3(tfm.y)); float sy = len_squared(float4_to_float3(tfm.y));
float sz = length_squared(float4_to_float3(tfm.z)); float sz = len_squared(float4_to_float3(tfm.z));
float stx = length_squared(float4_to_float3(ttfm.x)); float stx = len_squared(float4_to_float3(ttfm.x));
float sty = length_squared(float4_to_float3(ttfm.y)); float sty = len_squared(float4_to_float3(ttfm.y));
float stz = length_squared(float4_to_float3(ttfm.z)); float stz = len_squared(float4_to_float3(ttfm.z));
if(fabsf(sx - sy) < eps && fabsf(sx - sz) < eps && if(fabsf(sx - sy) < eps && fabsf(sx - sz) < eps &&
fabsf(sx - stx) < eps && fabsf(sx - sty) < eps && fabsf(sx - stx) < eps && fabsf(sx - sty) < eps &&