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:
Diffstat (limited to 'intern/cycles/util/util_math_float3.h')
-rw-r--r--intern/cycles/util/util_math_float3.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index dd2010715ba..162bc900d9f 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -91,6 +91,20 @@ ccl_device_inline bool isequal_float3(const float3 a, const float3 b);
* Definition.
*/
+ccl_device_inline float3 zero_float3()
+{
+#ifdef __KERNEL_SSE__
+ return float3(_mm_setzero_ps());
+#else
+ return make_float3(0.0f, 0.0f, 0.0f);
+#endif
+}
+
+ccl_device_inline float3 one_float3()
+{
+ return make_float3(1.0f, 1.0f, 1.0f);
+}
+
#ifndef __KERNEL_OPENCL__
ccl_device_inline float3 operator-(const float3 &a)
{
@@ -373,8 +387,7 @@ ccl_device_inline float3 reflect(const float3 incident, const float3 normal)
ccl_device_inline float3 project(const float3 v, const float3 v_proj)
{
float len_squared = dot(v_proj, v_proj);
- return (len_squared != 0.0f) ? (dot(v, v_proj) / len_squared) * v_proj :
- make_float3(0.0f, 0.0f, 0.0f);
+ return (len_squared != 0.0f) ? (dot(v, v_proj) / len_squared) * v_proj : zero_float3();
}
ccl_device_inline float3 saturate3(float3 a)
@@ -410,7 +423,7 @@ ccl_device_inline float3 safe_divide_float3_float3(const float3 a, const float3
ccl_device_inline float3 safe_divide_float3_float(const float3 a, const float b)
{
- return (b != 0.0f) ? a / b : make_float3(0.0f, 0.0f, 0.0f);
+ return (b != 0.0f) ? a / b : zero_float3();
}
ccl_device_inline float3 interp(float3 a, float3 b, float t)