diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-21 09:07:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-21 09:07:26 +0400 |
commit | b2c66e268f68ee406e5e05a65d9d1609b65d20c4 (patch) | |
tree | 722192b9fe1d7af57695860fc3639781bedf5f2b /source/blender/blenlib/intern | |
parent | e09ddf0d4ba6f6d1e8963d41eef153dadce482f8 (diff) |
replace MIN/MAX 3,4 with inline functions
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_base_inline.c | 36 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 10 |
3 files changed, 43 insertions, 7 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index b9866f9c6e6..8eb6561003b 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -175,6 +175,42 @@ MINLINE int max_ii(int a, int b) return (b < a) ? a : b; } +MINLINE float min_fff(float a, float b, float c) +{ + return min_ff(min_ff(a, b), c); +} +MINLINE float max_fff(float a, float b, float c) +{ + return max_ff(max_ff(a, b), c); +} + +MINLINE int min_iii(int a, int b, int c) +{ + return min_ii(min_ii(a, b), c); +} +MINLINE int max_iii(int a, int b, int c) +{ + return max_ii(max_ii(a, b), c); +} + +MINLINE float min_ffff(float a, float b, float c, float d) +{ + return min_ff(min_fff(a, b, c), d); +} +MINLINE float max_ffff(float a, float b, float c, float d) +{ + return max_ff(max_fff(a, b, c), d); +} + +MINLINE int min_iiii(int a, int b, int c, int d) +{ + return min_ii(min_iii(a, b, c), d); +} +MINLINE int max_iiii(int a, int b, int c, int d) +{ + return max_ii(max_iii(a, b, c), d); +} + MINLINE float signf(float f) { return (f < 0.f) ? -1.f : 1.f; diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 64851dbf12c..07cd85c4107 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -266,8 +266,8 @@ void rgb_to_hsv_v(const float rgb[3], float r_hsv[3]) void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll) { - float cmax = MAX3(r, g, b); - float cmin = MIN3(r, g, b); + const float cmax = max_fff(r, g, b); + const float cmin = min_fff(r, g, b); float h, s, l = (cmax + cmin) / 2.0f; if (cmax == cmin) { diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 931025606db..10a9a2df9f5 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -140,7 +140,7 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3]) x = fabsf(normal[0]); y = fabsf(normal[1]); z = fabsf(normal[2]); - max = MAX3(x, y, z); + max = max_fff(x, y, z); if (max == y) py = 2; else if (max == x) { px = 1; @@ -1198,10 +1198,10 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); /* first a simple bounding box test */ - if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; - if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; - if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; - if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; + if (min_fff(v0[a1], v1[a1], v2[a1]) > p1[a1]) return 0; + if (min_fff(v0[a2], v1[a2], v2[a2]) > p1[a2]) return 0; + if (max_fff(v0[a1], v1[a1], v2[a1]) < p1[a1]) return 0; + if (max_fff(v0[a2], v1[a2], v2[a2]) < p1[a2]) return 0; /* then a full intersection test */ #endif |