Cycles:
* 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:
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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(
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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 */
|
||||
|
@@ -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;
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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));
|
||||
|
@@ -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 {
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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 &&
|
||||
|
Reference in New Issue
Block a user