Cycles:
authorThomas Dinges <blender@dingto.org>
Tue, 4 Jun 2013 17:20:00 +0000 (17:20 +0000)
committerThomas Dinges <blender@dingto.org>
Tue, 4 Jun 2013 17:20:00 +0000 (17:20 +0000)
* 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].

22 files changed:
intern/cycles/blender/blender_curves.cpp
intern/cycles/blender/blender_mesh.cpp
intern/cycles/bvh/bvh.cpp
intern/cycles/kernel/kernel_bvh.h
intern/cycles/kernel/kernel_camera.h
intern/cycles/kernel/kernel_curve.h
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_light.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_subsurface.h
intern/cycles/kernel/svm/svm_camera.h
intern/cycles/kernel/svm/svm_math.h
intern/cycles/kernel/svm/svm_texture.h
intern/cycles/kernel/svm/svm_wave.h
intern/cycles/kernel/svm/svm_wireframe.h
intern/cycles/render/light.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/object.cpp
intern/cycles/subd/subd_dice.cpp
intern/cycles/subd/subd_split.cpp
intern/cycles/util/util_math.h
intern/cycles/util/util_transform.h

index 7426471d95a81807e38dfe5a4378e02b26c0350e..56d78fb5c269f4fba2d725709a33f6356d7378fb 100644 (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]);
                                                cKey = transform_point(&itfm, cKey);
                                                if(step_no > 0)
-                                                       curve_length += length(cKey - pcKey);
+                                                       curve_length += len(cKey - pcKey);
                                                CData->curvekey_co.push_back(cKey);
                                                CData->curvekey_time.push_back(curve_length);
                                                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++) {
 
                        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);
                        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]]));
@@ -499,7 +499,7 @@ void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interp
 
                                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);
                                        break;
                                }
@@ -528,7 +528,7 @@ void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interp
 
                                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);
                                        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++) {
 
                        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);
                        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]]));
@@ -613,7 +613,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int inter
 
                                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);
                                        break;
                                }
@@ -643,7 +643,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int inter
 
                                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);
                                        firstxbasis = xbasis;
                                }
index 28d89e6fdc331e6e603ebdc46b964f7b3e047182..d628fa04f92170fb8ec772f39e26187fff25a485 100644 (file)
@@ -237,8 +237,8 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
                bool smooth = f->use_smooth();
 
                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 ||
-                               length_squared(cross(mesh->verts[vi[2]] - mesh->verts[vi[0]], mesh->verts[vi[3]] - 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 ||
+                               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[2], vi[3], vi[1], shader, smooth);
                        }
index 983d6fbce3e8f97a821a92cfe53425500d472e86..82a444bda76662c87552706abf7d0426d11bcab4 100644 (file)
@@ -287,7 +287,7 @@ void BVH::pack_curve_segment(int idx, float4 woop[3])
        float3 v1 = mesh->curve_keys[k1].co;
 
        float3 d0 = v1 - v0;
-       float l =  length(d0);
+       float l =  len(d0);
        
        /*Plan
        *Transform tfm = make_transform(
index 1b02e486b40ebdeb26236767a4d3c94a80064a34..aff9d586e7a78c065e98941813a1052ce3b5ac40 100644 (file)
@@ -64,7 +64,7 @@ __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray
        float3 dir = transform_direction(&tfm, ray->D);
 
        float len;
-       dir = normalize_length(dir, &len);
+       dir = normalize_len(dir, &len);
 
        *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) {
                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;
@@ -94,7 +94,7 @@ __device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, con
        float3 dir = transform_direction(&itfm, ray->D);
 
        float len;
-       dir = normalize_length(dir, &len);
+       dir = normalize_len(dir, &len);
 
        *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)
 {
        if(*t != FLT_MAX)
-               *t *= length(transform_direction(tfm, 1.0f/(*idir)));
+               *t *= len(transform_direction(tfm, 1.0f/(*idir)));
 
        *P = ray->P;
        *idir = bvh_inverse_direction(ray->D);
@@ -489,14 +489,14 @@ __device_inline void bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
                                t = p_curr.z;
                        }
                        else {
-                               float l = length(p_en - p_st);
+                               float l = len(p_en - p_st);
                                /*minimum width extension*/
                                float or1 = r1;
                                float or2 = r2;
                                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;
-                                       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;
                                }
                                /* --- */
@@ -611,9 +611,9 @@ __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
        float r1 = or1;
        float r2 = or2;
        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;
-               pixelsize = min(length(p2 - P) * difl, extmax);
+               pixelsize = min(len(p2 - P) * difl, extmax);
                r2 = or2 < pixelsize ? pixelsize : or2;
        }
        /* --- */
@@ -621,14 +621,14 @@ __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
        float mr = max(r1,r2);
        float3 dif = P - p1;
        float3 dir = 1.0f/idir;
-       float l = length(p2 - p1);
+       float l = len(p2 - p1);
 
        float sp_r = mr + 0.5f * l;
        float3 sphere_dif = P - ((p1 + p2) * 0.5f);
        float sphere_b = dot(dir,sphere_dif);
        sphere_dif = sphere_dif - sphere_b * dir;
        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)
                return;
 
@@ -652,8 +652,8 @@ __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
        /* test minimum separation*/
        float3 cprod = cross(tg, dir);
        float3 cprod2 = cross(tg, dif);
-       float cprodsq = length_squared(cprod);
-       float cprod2sq = length_squared(cprod2);
+       float cprodsq = len_squared(cprod);
+       float cprod2sq = len_squared(cprod2);
        float distscaled = dot(cprod,dif);
 
        if(cprodsq == 0)
@@ -1010,7 +1010,7 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, co
 
                P = transform_point(&tfm, P);
                D = transform_direction(&tfm, D*t);
-               D = normalize_length(D, &t);
+               D = normalize_len(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);
                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);
@@ -1092,7 +1092,7 @@ __device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const
        float4 P1 = kernel_tex_fetch(__curve_keys, k0);
        float4 P2 = kernel_tex_fetch(__curve_keys, k1);
        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 r2 = P2.w;
        float gd = ((r2 - r1)/l);
index 334568869900d69b097d6e7bcf724283af99913f..a23586a53a4d7bbdc3224ab17f78cd3bbc93639a 100644 (file)
@@ -255,7 +255,7 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P)
                return fabsf(dot((P - camP), camD));
        }
        else
-               return length(P - camP);
+               return len(P - camP);
 }
 
 CCL_NAMESPACE_END
index f1b9682f04f4452887cd1d65a6b6fc7f52779ad0..e065717888ca9e51ad8ef28ecb2c21c283ca790d 100644 (file)
@@ -122,7 +122,7 @@ __device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
        if(sd->segment != ~0) {
                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);
 
                /* need to find suitable scaled gd for corrected normal */
index 42e5f3961cd015bc027d784bc6f423b0ed6c918e..74f768c899cb90a57c0fbe1b70dd905305a4c219 100644 (file)
@@ -133,7 +133,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li
                else {
                        /* other lights, avoid self-intersection */
                        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;
index f5899b90b2617c6f51e156e0f09e8975040770a6..d4d78e413d21b1e7baf2b86d0ccc3bae174bff65 100644 (file)
@@ -263,7 +263,7 @@ __device void lamp_light_sample(KernelGlobals *kg, int lamp,
                                /* sphere light */
                                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;
 
                        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->Ng = D;
-                       ls->D = normalize_length(ls->P - P, &ls->t);
+                       ls->D = normalize_len(ls->P - P, &ls->t);
 
                        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 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 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);
 
                /* 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);
        }
        else {
index 5d02f059ec88a0f919829758e557c5a85434232b..d2de9ba2b440ea89ff976688f9435e8ff5a72173 100644 (file)
@@ -222,7 +222,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
 
                                ray->P = ray_offset(sd.P, -sd.Ng);
                                if(ray->t != FLT_MAX)
-                                       ray->D = normalize_length(Pend - ray->P, &ray->t);
+                                       ray->D = normalize_len(Pend - ray->P, &ray->t);
 
                                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)) {       
                                float3 pixdiff = ray.dD.dx + ray.dD.dy;
                                /*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;
@@ -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)) {       
                                float3 pixdiff = ray.dD.dx + ray.dD.dy;
                                /*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;
index f3b7c014d998a104742a4865a2ae5e558af1f6e5..f7bccf7197603a3821584a045ba1ed09f7ffd6a1 100644 (file)
@@ -201,7 +201,7 @@ __device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, int sta
                /* create ray */
                Ray ray;
                ray.P = p1;
-               ray.D = normalize_length(p2 - p1, &ray.t);
+               ray.D = normalize_len(p2 - p1, &ray.t);
                ray.dP = sd->dP;
                ray.dD = differential3_zero();
                ray.time = sd->time;
index 972d14d00e2fde4e8ed00a99a8b77b4df1e65fad..f13cefb77640797aed3a7a69bbe557102451cdfe 100644 (file)
@@ -27,7 +27,7 @@ __device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, u
        Transform tfm = kernel_data.cam.worldtocamera;
        vector = transform_point(&tfm, sd->P);
        zdepth = vector.z;
-       distance = length(vector);
+       distance = len(vector);
 
        if (stack_valid(out_vector))
                stack_store_float3(stack, out_vector, normalize(vector));
index 93d432e5954062fcafce6c8bbceab469ec357986..dbf477a0a969c94648d4918188347e75103f5921 100644 (file)
@@ -82,7 +82,7 @@ __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, f
                *Fac = average_fac(*Vector);
        }
        else if(type == NODE_VECTOR_MATH_AVERAGE) {
-               *Fac = length(Vector1 + Vector2);
+               *Fac = len(Vector1 + Vector2);
                *Vector = normalize(Vector1 + Vector2);
        }
        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) {
                float3 c = cross(Vector1, Vector2);
-               *Fac = length(c);
+               *Fac = len(c);
                *Vector = normalize(c);
        }
        else if(type == NODE_VECTOR_MATH_NORMALIZE) {
-               *Fac = length(Vector1);
+               *Fac = len(Vector1);
                *Vector = normalize(Vector1);
        }
        else {
index 67e08bad7f84494b3f480587cc0224f38fcb2e09..a4f6691435c6d500d334dc1f5fc0e4b1d6b891b8 100644 (file)
@@ -25,7 +25,7 @@ __device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, fl
        if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED)
                return dot(d, d);
        if(distance_metric == NODE_VORONOI_ACTUAL_DISTANCE)
-               return length(d);
+               return len(d);
        if(distance_metric == NODE_VORONOI_MANHATTAN)
                return fabsf(d.x) + fabsf(d.y) + fabsf(d.z);
        if(distance_metric == NODE_VORONOI_CHEBYCHEV)
index e37b07883615f18cc55d06b2563788725bdabf9a..d2d808e40631ebbc65bdf312b30df06630e67213 100644 (file)
@@ -29,7 +29,7 @@ __device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float
        if(type == NODE_WAVE_BANDS)
                n = (p.x + p.y + p.z) * 10.0f;
        else /* if(type == NODE_WAVE_RINGS) */
-               n = length(p) * 20.0f;
+               n = len(p) * 20.0f;
        
        if(distortion != 0.0f)
                n += distortion * noise_turbulence(p*dscale, NODE_NOISE_PERLIN, detail, 0);
index 24b290584403f7a34a911ac5091cd932ceb45002..9ecb81847d73c04959032a595e58ff3d7448ae4d 100644 (file)
@@ -66,8 +66,8 @@ __device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack
                if(pixel_size) {
                        // 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
-                       float pixelwidth_x = length(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_x = len(sd->dP.dx - dot(sd->dP.dx, 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
                        pixelwidth = (pixelwidth_x + pixelwidth_y) * 0.5f;
                }
index f29061299b54afa5aa742d64694ddc48337e1be0..1d2acf79b6c9447492c1fb1a76cb7fed133c955e 100644 (file)
@@ -276,7 +276,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                                                        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) {
                        float3 axisu = light->axisu*(light->sizeu*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;
 
                        if(light->use_mis && area > 0.0f)
index 8ec2514bbfe9f00c10414893b4c8ba56d4a20312..4a2a64bb0f3f6f6b49e3cf92d58c03bbfffb1f6e 100644 (file)
@@ -187,7 +187,7 @@ void Mesh::add_face_normals()
                        float3 v2 = verts_ptr[t.v[2]];
 
                        float3 norm = cross(v1 - v0, v2 - v0);
-                       float normlen = length(norm);
+                       float normlen = len(norm);
                        if(normlen == 0.0f)
                                fN[i] = make_float3(0.0f, 0.0f, 0.0f);
                        else
index cd266367b6fc25ca445227eb7058bfe9ab8fc5bc..1a2780995e3dc0b7bdb370decc1137a46e2a637a 100644 (file)
@@ -200,7 +200,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
                                                float r2 = mesh->curve_keys[first_key + i + 1].radius;
 
                                                /* 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);
 
                                        /* currently ignores segment overlaps*/
-                                       surface_area += M_PI_F *(r1 + r2) * length(p1 - p2);
+                                       surface_area += M_PI_F *(r1 + r2) * len(p1 - p2);
                                }
                        }
                }
index 0174c139b01a4b1287498db695c9b4e2fc88b3ad..48e6808bc386bedd7961a76e8d4b0870e01ecde7 100644 (file)
@@ -98,8 +98,8 @@ void EdgeDice::stitch_triangles(vector<int>& outer, vector<int>& inner)
                }
                else {
                        /* length of diagonals */
-                       float len1 = length(mesh_P[inner[i]] - mesh_P[outer[j+1]]);
-                       float len2 = length(mesh_P[outer[j]] - mesh_P[inner[i+1]]);
+                       float len1 = len(mesh_P[inner[i]] - mesh_P[outer[j+1]]);
+                       float len2 = len(mesh_P[outer[j]] - mesh_P[inner[i+1]]);
 
                        /* use smallest diagonal */
                        if(len1 < len2)
index cca64822647096cdf79312c2d4123f70c42f7d84..074c82a23481ce179cfb09c165974746fce12331 100644 (file)
@@ -74,7 +74,7 @@ int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend)
                float3 P = project(patch, Pstart + t*(Pend - Pstart));
 
                if(i > 0) {
-                       float L = length(P - Plast);
+                       float L = len(P - Plast);
                        Lsum += L;
                        Lmax = max(L, Lmax);
                }
index b7133582696a800bff952309ea5e1de2e6321dfb..6fe1b2bcf54d6f337c36184c57d65bc444343675 100644 (file)
@@ -296,19 +296,19 @@ __device_inline bool operator==(const int2 a, const int2 b)
        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));
 }
 
 __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);
 }
 
@@ -454,13 +454,14 @@ __device_inline float3 cross(const float3 a, const float3 b)
        return r;
 }
 
-__device_inline float length(const float3 a)
+#endif
+
+__device_inline float len(const float3 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);
 }
@@ -469,14 +470,14 @@ __device_inline float length_squared(const float3 a)
 
 __device_inline float3 normalize(const float3 a)
 {
-       return a/length(a);
+       return a/len(a);
 }
 
 #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);
 }
 
@@ -786,14 +787,14 @@ __device_inline float dot(const float4& a, const float4& 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));
 }
 
 __device_inline float4 normalize(const float4 a)
 {
-       return a/length(a);
+       return a/len(a);
 }
 
 __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)
 {
-       return length(cross(v3 - v2, v1 - v2))*0.5f;
+       return len(cross(v3 - v2, v1 - v2))*0.5f;
 }
 
 #endif
@@ -1211,7 +1212,7 @@ __device bool ray_aligned_disk_intersect(
 {
        /* aligned disk normal */
        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);
 
        if(div == 0.0f)
@@ -1224,7 +1225,7 @@ __device bool ray_aligned_disk_intersect(
        
        /* test if within radius */
        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;
 
        *isect_P = P;
index 53e32fcce96882d2984aeb2f3d6ec7134d4a09f9..66801e90b56d601e6759063da71d3efd924a6463 100644 (file)
@@ -268,12 +268,12 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
        Transform ttfm = transform_transpose(tfm);
        float eps = 1e-6f; 
        
-       float sx = length_squared(float4_to_float3(tfm.x));
-       float sy = length_squared(float4_to_float3(tfm.y));
-       float sz = length_squared(float4_to_float3(tfm.z));
-       float stx = length_squared(float4_to_float3(ttfm.x));
-       float sty = length_squared(float4_to_float3(ttfm.y));
-       float stz = length_squared(float4_to_float3(ttfm.z));
+       float sx = len_squared(float4_to_float3(tfm.x));
+       float sy = len_squared(float4_to_float3(tfm.y));
+       float sz = len_squared(float4_to_float3(tfm.z));
+       float stx = len_squared(float4_to_float3(ttfm.x));
+       float sty = len_squared(float4_to_float3(ttfm.y));
+       float stz = len_squared(float4_to_float3(ttfm.z));
 
        if(fabsf(sx - sy) < eps && fabsf(sx - sz) < eps &&
           fabsf(sx - stx) < eps && fabsf(sx - sty) < eps &&