[Bf-blender-cvs] [b2b51efc89e] soc-2019-cycles-procedural: Define distance function in terms of len

OmarSquircleArt noreply at git.blender.org
Mon Jun 24 22:55:16 CEST 2019


Commit: b2b51efc89e3c8b6893694c39b3415cd191fef6a
Author: OmarSquircleArt
Date:   Mon Jun 24 22:56:01 2019 +0200
Branches: soc-2019-cycles-procedural
https://developer.blender.org/rBb2b51efc89e3c8b6893694c39b3415cd191fef6a

Define distance function in terms of len

===================================================================

M	intern/cycles/util/util_math_float2.h
M	intern/cycles/util/util_math_float3.h
M	intern/cycles/util/util_math_float4.h

===================================================================

diff --git a/intern/cycles/util/util_math_float2.h b/intern/cycles/util/util_math_float2.h
index 7c49d8495be..4078e3be68f 100644
--- a/intern/cycles/util/util_math_float2.h
+++ b/intern/cycles/util/util_math_float2.h
@@ -155,8 +155,7 @@ ccl_device_inline bool operator!=(const float2 &a, const float2 &b)
 
 ccl_device_inline float distance(const float2 &a, const float2 &b)
 {
-  float2 difference = a - b;
-  return sqrt(dot(difference, difference));
+  return len(a - b);
 }
 
 ccl_device_inline bool is_zero(const float2 &a)
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index d4773ab7fd4..088341c3de3 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -214,8 +214,7 @@ ccl_device_inline bool operator!=(const float3 &a, const float3 &b)
 
 ccl_device_inline float distance(const float3 &a, const float3 &b)
 {
-  float3 difference = a - b;
-  return sqrt(dot(difference, difference));
+  return len(a - b);
 }
 
 ccl_device_inline float dot(const float3 &a, const float3 &b)
diff --git a/intern/cycles/util/util_math_float4.h b/intern/cycles/util/util_math_float4.h
index fcf2fb15003..1aa0196734c 100644
--- a/intern/cycles/util/util_math_float4.h
+++ b/intern/cycles/util/util_math_float4.h
@@ -219,8 +219,7 @@ ccl_device_inline bool operator==(const float4 &a, const float4 &b)
 
 ccl_device_inline float distance(const float4 &a, const float4 &b)
 {
-  float4 difference = a - b;
-  return sqrt(dot(difference, difference));
+  return len(a - b);
 }
 
 ccl_device_inline float dot(const float4 &a, const float4 &b)



More information about the Bf-blender-cvs mailing list