Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_math.h
| Show First 20 Lines • Show All 551 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| ccl_device_inline float3 safe_normalize(const float3 a) | ccl_device_inline float3 safe_normalize(const float3 a) | ||||
| { | { | ||||
| float t = len(a); | float t = len(a); | ||||
| return (t != 0.0f)? a/t: a; | return (t != 0.0f)? a/t: a; | ||||
| } | } | ||||
| #ifndef __KERNEL_OPENCL__ | #ifdef __KERNEL_OPENCL__ | ||||
| ccl_device_inline bool float3_equals(const float3 a, const float3 b) | |||||
| { | |||||
| int3 result = a == b; | |||||
| return result.x && result.y && result.z; | |||||
| } | |||||
| #else | |||||
| ccl_device_inline bool operator==(const float3 a, const float3 b) | ccl_device_inline bool operator==(const float3 a, const float3 b) | ||||
| { | { | ||||
| #ifdef __KERNEL_SSE__ | #ifdef __KERNEL_SSE__ | ||||
| return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7; | return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7; | ||||
| #else | #else | ||||
| return (a.x == b.x && a.y == b.y && a.z == b.z); | return (a.x == b.x && a.y == b.y && a.z == b.z); | ||||
| #endif | #endif | ||||
| } | } | ||||
| ccl_device_inline bool float3_equals(const float3 a, const float3 b) | |||||
| { | |||||
| return a == b; | |||||
| } | |||||
| ccl_device_inline bool operator!=(const float3 a, const float3 b) | ccl_device_inline bool operator!=(const float3 a, const float3 b) | ||||
| { | { | ||||
| return !(a == b); | return !(a == b); | ||||
| } | } | ||||
| ccl_device_inline float3 min(float3 a, float3 b) | ccl_device_inline float3 min(float3 a, float3 b) | ||||
| { | { | ||||
| #ifdef __KERNEL_SSE__ | #ifdef __KERNEL_SSE__ | ||||
| ▲ Show 20 Lines • Show All 974 Lines • Show Last 20 Lines | |||||