From f2215d756427d530025f01a7c394c480b95a817f Mon Sep 17 00:00:00 2001 From: Weizhen Huang Date: Sat, 29 Jun 2024 07:56:46 +0200 Subject: [PATCH] Fix: `safe_normalize()` not defined for `float2` on Metal --- intern/cycles/util/math_float2.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/intern/cycles/util/math_float2.h b/intern/cycles/util/math_float2.h index b81e0b70c3b..4c1f861e3b3 100644 --- a/intern/cycles/util/math_float2.h +++ b/intern/cycles/util/math_float2.h @@ -164,6 +164,12 @@ ccl_device_inline float len_squared(const float2 a) return dot(a, a); } +ccl_device_inline float2 safe_normalize(const float2 a) +{ + float t = len(a); + return (t != 0.0f) ? a / t : a; +} + #if !defined(__KERNEL_METAL__) ccl_device_inline float distance(const float2 a, const float2 b) { @@ -186,12 +192,6 @@ ccl_device_inline float2 normalize_len(const float2 a, ccl_private float *t) return a / (*t); } -ccl_device_inline float2 safe_normalize(const float2 a) -{ - float t = len(a); - return (t != 0.0f) ? a / t : a; -} - ccl_device_inline float2 min(const float2 a, const float2 b) { return make_float2(min(a.x, b.x), min(a.y, b.y));