Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-06-03 00:39:32 +0400
committerThomas Dinges <blender@dingto.org>2013-06-03 00:39:32 +0400
commitc5ed6765b9c46630579be5e43cab74965f0be9da (patch)
tree0ca3bee53bec86f5bb63a005aa4cbfb04e6735a6 /intern/cycles/util
parent834492489ab9cea37ff32166895b6a298d7225e9 (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/cycles/util')
-rw-r--r--intern/cycles/util/util_math.h31
-rw-r--r--intern/cycles/util/util_transform.h12
2 files changed, 21 insertions, 22 deletions
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 &&