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.h')
-rw-r--r--intern/cycles/util/util_math.h46
1 files changed, 39 insertions, 7 deletions
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 7d6dfd34e0e..32924f9a8c2 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -24,10 +24,6 @@
#ifndef __KERNEL_OPENCL__
-#ifdef _MSC_VER
-# define _USE_MATH_DEFINES
-#endif
-
#include <float.h>
#include <math.h>
#include <stdio.h>
@@ -101,6 +97,11 @@ ccl_device_inline float fminf(float a, float b)
#ifndef __KERNEL_GPU__
+ccl_device_inline int abs(int x)
+{
+ return (x > 0)? x: -x;
+}
+
ccl_device_inline int max(int a, int b)
{
return (a > b)? a: b;
@@ -351,7 +352,7 @@ ccl_device_inline float2 normalize_len(const float2 a, float *t)
ccl_device_inline float2 safe_normalize(const float2 a)
{
float t = len(a);
- return (t)? a/t: a;
+ return (t != 0.0f)? a/t: a;
}
ccl_device_inline bool operator==(const float2 a, const float2 b)
@@ -553,7 +554,7 @@ ccl_device_inline float3 normalize_len(const float3 a, float *t)
ccl_device_inline float3 safe_normalize(const float3 a)
{
float t = len(a);
- return (t)? a/t: a;
+ return (t != 0.0f)? a/t: a;
}
#ifndef __KERNEL_OPENCL__
@@ -866,7 +867,7 @@ ccl_device_inline float4 normalize(const float4 a)
ccl_device_inline float4 safe_normalize(const float4 a)
{
float t = len(a);
- return (t)? a/t: a;
+ return (t != 0.0f)? a/t: a;
}
ccl_device_inline float4 min(float4 a, float4 b)
@@ -939,6 +940,37 @@ ccl_device_inline void print_float4(const char *label, const float4& a)
#endif
+/* Int2 */
+
+#ifndef __KERNEL_OPENCL__
+
+ccl_device_inline int2 operator+(const int2 &a, const int2 &b)
+{
+ return make_int2(a.x + b.x, a.y + b.y);
+}
+
+ccl_device_inline int2 operator+=(int2 &a, const int2 &b)
+{
+ return a = a + b;
+}
+
+ccl_device_inline int2 operator-(const int2 &a, const int2 &b)
+{
+ return make_int2(a.x - b.x, a.y - b.y);
+}
+
+ccl_device_inline int2 operator*(const int2 &a, const int2 &b)
+{
+ return make_int2(a.x * b.x, a.y * b.y);
+}
+
+ccl_device_inline int2 operator/(const int2 &a, const int2 &b)
+{
+ return make_int2(a.x / b.x, a.y / b.y);
+}
+
+#endif
+
/* Int3 */
#ifndef __KERNEL_OPENCL__