diff options
author | Thomas Dinges <blender@dingto.org> | 2013-06-03 00:39:32 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2013-06-03 00:39:32 +0400 |
commit | c5ed6765b9c46630579be5e43cab74965f0be9da (patch) | |
tree | 0ca3bee53bec86f5bb63a005aa4cbfb04e6735a6 /intern | |
parent | 834492489ab9cea37ff32166895b6a298d7225e9 (diff) |
Cycles / Math functions:
* Rename some math functions:
len -> length
len_squared -> length_squared
normalize_len -> normalize_length
* This way OpenCL uses its inbuilt length() function, rather than our own. The other two functions have been renamed for consistency.
* Tested CPU, CUDA and OpenCL compile, should be no functional changes.
Diffstat (limited to 'intern')
22 files changed, 74 insertions, 75 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 56d78fb5c26..7426471d95a 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -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 += len(cKey - pcKey); + curve_length += length(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(len_squared(firstxbasis)!= 0.0f) + if(length_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(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) { + if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { firstxbasis = normalize(xbasis); break; } @@ -528,7 +528,7 @@ void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interp xbasis = cross(v1,v2); - if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) { + if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_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(len_squared(firstxbasis)!= 0.0f) + if(length_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(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) { + if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { firstxbasis = normalize(xbasis); break; } @@ -643,7 +643,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int inter xbasis = cross(v1,v2); - if(len_squared(xbasis) >= 0.05f * len_squared(v1) * len_squared(v2)) { + if(length_squared(xbasis) >= 0.05f * length_squared(v1) * length_squared(v2)) { xbasis = normalize(xbasis); firstxbasis = xbasis; } diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index d628fa04f92..28d89e6fdc3 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -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(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) { + 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) { mesh->add_triangle(vi[0], vi[1], vi[3], shader, smooth); mesh->add_triangle(vi[2], vi[3], vi[1], shader, smooth); } diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 82a444bda76..983d6fbce3e 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -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 = len(d0); + float l = length(d0); /*Plan *Transform tfm = make_transform( diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h index aff9d586e7a..1b02e486b40 100644 --- a/intern/cycles/kernel/kernel_bvh.h +++ b/intern/cycles/kernel/kernel_bvh.h @@ -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_len(dir, &len); + dir = normalize_length(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 *= len(transform_direction(&tfm, 1.0f/(*idir))); + *t *= length(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_len(dir, &len); + dir = normalize_length(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 *= len(transform_direction(tfm, 1.0f/(*idir))); + *t *= length(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 = len(p_en - p_st); + float l = length(p_en - p_st); /*minimum width extension*/ float or1 = r1; float or2 = r2; if(difl != 0.0f) { - mw_extension = min(len(p_st - P) * difl, extmax); + mw_extension = min(length(p_st - P) * difl, extmax); or1 = r1 < mw_extension ? mw_extension : r1; - mw_extension = min(len(p_en - P) * difl, extmax); + mw_extension = min(length(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(len(p1 - P) * difl, extmax); + float pixelsize = min(length(p1 - P) * difl, extmax); r1 = or1 < pixelsize ? pixelsize : or1; - pixelsize = min(len(p2 - P) * difl, extmax); + pixelsize = min(length(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 = len(p2 - p1); + float l = length(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 - len_squared(sphere_dif) + sp_r * sp_r; + float sdisc = sphere_b * sphere_b - length_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 = len_squared(cprod); - float cprod2sq = len_squared(cprod2); + float cprodsq = length_squared(cprod); + float cprod2sq = length_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_len(D, &t); + D = normalize_length(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_len(D, &t); + D = normalize_length(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_len(float4_to_float3(P2 - P1),&l); + float3 tg = normalize_length(float4_to_float3(P2 - P1),&l); float r1 = P1.w; float r2 = P2.w; float gd = ((r2 - r1)/l); diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index a23586a53a4..33456886990 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -255,7 +255,7 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P) return fabsf(dot((P - camP), camD)); } else - return len(P - camP); + return length(P - camP); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_curve.h b/intern/cycles/kernel/kernel_curve.h index e065717888c..f1b9682f04f 100644 --- a/intern/cycles/kernel/kernel_curve.h +++ b/intern/cycles/kernel/kernel_curve.h @@ -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 / len_squared(sd->dPdu))); + tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) * normalmix / length_squared(sd->dPdu))); tgN = normalize(tgN); /* need to find suitable scaled gd for corrected normal */ diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 74f768c899c..42e5f3961cd 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -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_len(ray->D, &ray->t); + ray->D = normalize_length(ray->D, &ray->t); } ray->dP = sd->dP; diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index d4d78e413d2..f5899b90b26 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -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_len(ls->P - P, &ls->t); + ls->D = normalize_length(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_len(ls->P - P, &ls->t); + ls->D = normalize_length(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 = len(float4_to_float3(P2) - float4_to_float3(P1)); + float l = length(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_len(ls->P - P, &ls->t); + ls->D = normalize_length(ls->P - P, &ls->t); ls->pdf = triangle_light_pdf(kg, ls->Ng, -ls->D, ls->t); } else { diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index e96cd8a248e..3e815ffe400 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -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_len(Pend - ray->P, &ray->t); + ray->D = normalize_length(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 * len(pixdiff) * 0.5f; + difl = kernel_data.curve_kernel_data.minimum_width * length(pixdiff) * 0.5f; } extmax = kernel_data.curve_kernel_data.maximum_width; @@ -956,7 +956,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 * len(pixdiff) * 0.5f; + difl = kernel_data.curve_kernel_data.minimum_width * length(pixdiff) * 0.5f; } extmax = kernel_data.curve_kernel_data.maximum_width; diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h index f7bccf71976..f3b7c014d99 100644 --- a/intern/cycles/kernel/kernel_subsurface.h +++ b/intern/cycles/kernel/kernel_subsurface.h @@ -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_len(p2 - p1, &ray.t); + ray.D = normalize_length(p2 - p1, &ray.t); ray.dP = sd->dP; ray.dD = differential3_zero(); ray.time = sd->time; diff --git a/intern/cycles/kernel/svm/svm_camera.h b/intern/cycles/kernel/svm/svm_camera.h index f13cefb7764..972d14d00e2 100644 --- a/intern/cycles/kernel/svm/svm_camera.h +++ b/intern/cycles/kernel/svm/svm_camera.h @@ -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 = len(vector); + distance = length(vector); if (stack_valid(out_vector)) stack_store_float3(stack, out_vector, normalize(vector)); diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index dbf477a0a96..93d432e5954 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -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 = len(Vector1 + Vector2); + *Fac = length(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 = len(c); + *Fac = length(c); *Vector = normalize(c); } else if(type == NODE_VECTOR_MATH_NORMALIZE) { - *Fac = len(Vector1); + *Fac = length(Vector1); *Vector = normalize(Vector1); } else { diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h index a4f6691435c..67e08bad7f8 100644 --- a/intern/cycles/kernel/svm/svm_texture.h +++ b/intern/cycles/kernel/svm/svm_texture.h @@ -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 len(d); + return length(d); if(distance_metric == NODE_VORONOI_MANHATTAN) return fabsf(d.x) + fabsf(d.y) + fabsf(d.z); if(distance_metric == NODE_VORONOI_CHEBYCHEV) diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h index d2d808e4063..e37b0788361 100644 --- a/intern/cycles/kernel/svm/svm_wave.h +++ b/intern/cycles/kernel/svm/svm_wave.h @@ -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 = len(p) * 20.0f; + n = length(p) * 20.0f; if(distortion != 0.0f) n += distortion * noise_turbulence(p*dscale, NODE_NOISE_PERLIN, detail, 0); diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h index 9ecb81847d7..24b29058440 100644 --- a/intern/cycles/kernel/svm/svm_wireframe.h +++ b/intern/cycles/kernel/svm/svm_wireframe.h @@ -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 = 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); + 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); // Take the average of both axis' length pixelwidth = (pixelwidth_x + pixelwidth_y) * 0.5f; } diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 1d2acf79b6c..f29061299b5 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -276,7 +276,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen p2 = transform_point(&tfm, p2); } - totarea += M_PI_F * (r1 + r2) * len(p1 - p2); + totarea += M_PI_F * (r1 + r2) * length(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 = len(axisu)*len(axisv); + float area = length(axisu)*length(axisv); float invarea = (area > 0.0f)? 1.0f/area: 1.0f; if(light->use_mis && area > 0.0f) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 4a2a64bb0f3..8ec2514bbfe 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -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 = len(norm); + float normlen = length(norm); if(normlen == 0.0f) fN[i] = make_float3(0.0f, 0.0f, 0.0f); else diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 1a2780995e3..cd266367b6f 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -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) * len(p1 - p2); + surface_area += M_PI_F *(r1 + r2) * length(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) * len(p1 - p2); + surface_area += M_PI_F *(r1 + r2) * length(p1 - p2); } } } diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp index 48e6808bc38..0174c139b01 100644 --- a/intern/cycles/subd/subd_dice.cpp +++ b/intern/cycles/subd/subd_dice.cpp @@ -98,8 +98,8 @@ void EdgeDice::stitch_triangles(vector<int>& outer, vector<int>& inner) } else { /* length of diagonals */ - float len1 = len(mesh_P[inner[i]] - mesh_P[outer[j+1]]); - float len2 = len(mesh_P[outer[j]] - mesh_P[inner[i+1]]); + float len1 = length(mesh_P[inner[i]] - mesh_P[outer[j+1]]); + float len2 = length(mesh_P[outer[j]] - mesh_P[inner[i+1]]); /* use smallest diagonal */ if(len1 < len2) diff --git a/intern/cycles/subd/subd_split.cpp b/intern/cycles/subd/subd_split.cpp index 074c82a2348..cca64822647 100644 --- a/intern/cycles/subd/subd_split.cpp +++ b/intern/cycles/subd/subd_split.cpp @@ -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 = len(P - Plast); + float L = length(P - Plast); Lsum += L; Lmax = max(L, Lmax); } diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 6fe1b2bcf54..b7133582696 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -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 len(const float2 a) +__device_inline float length(const float2 a) { return sqrtf(dot(a, a)); } __device_inline float2 normalize(const float2 a) { - return a/len(a); + return a/length(a); } -__device_inline float2 normalize_len(const float2 a, float *t) +__device_inline float2 normalize_length(const float2 a, float *t) { - *t = len(a); + *t = length(a); return a/(*t); } @@ -454,14 +454,13 @@ __device_inline float3 cross(const float3 a, const float3 b) return r; } -#endif - -__device_inline float len(const float3 a) +__device_inline float length(const float3 a) { return sqrtf(dot(a, a)); } +#endif -__device_inline float len_squared(const float3 a) +__device_inline float length_squared(const float3 a) { return dot(a, a); } @@ -470,14 +469,14 @@ __device_inline float len_squared(const float3 a) __device_inline float3 normalize(const float3 a) { - return a/len(a); + return a/length(a); } #endif -__device_inline float3 normalize_len(const float3 a, float *t) +__device_inline float3 normalize_length(const float3 a, float *t) { - *t = len(a); + *t = length(a); return a/(*t); } @@ -787,14 +786,14 @@ __device_inline float dot(const float4& a, const float4& b) return reduce_add(a * b); } -__device_inline float len(const float4 a) +__device_inline float length(const float4 a) { return sqrtf(dot(a, a)); } __device_inline float4 normalize(const float4 a) { - return a/len(a); + return a/length(a); } __device_inline float4 min(float4 a, float4 b) @@ -1050,7 +1049,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 len(cross(v3 - v2, v1 - v2))*0.5f; + return length(cross(v3 - v2, v1 - v2))*0.5f; } #endif @@ -1212,7 +1211,7 @@ __device bool ray_aligned_disk_intersect( { /* aligned disk normal */ float disk_t; - float3 disk_N = normalize_len(ray_P - disk_P, &disk_t); + float3 disk_N = normalize_length(ray_P - disk_P, &disk_t); float div = dot(ray_D, disk_N); if(div == 0.0f) @@ -1225,7 +1224,7 @@ __device bool ray_aligned_disk_intersect( /* test if within radius */ float3 P = ray_P + ray_D*t; - if(len_squared(P - disk_P) > disk_radius*disk_radius) + if(length_squared(P - disk_P) > disk_radius*disk_radius) return false; *isect_P = P; diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index 66801e90b56..53e32fcce96 100644 --- a/intern/cycles/util/util_transform.h +++ b/intern/cycles/util/util_transform.h @@ -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 = 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)); + 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)); if(fabsf(sx - sy) < eps && fabsf(sx - sz) < eps && fabsf(sx - stx) < eps && fabsf(sx - sty) < eps && |