[Bf-blender-cvs] [1898c1f] master: Math Lib: add axis_dominant_v3_ortho_single
Campbell Barton
noreply at git.blender.org
Wed Dec 9 04:10:11 CET 2015
Commit: 1898c1f05cd38ea82f6da2ac3af07bab56537f3b
Author: Campbell Barton
Date: Wed Dec 9 13:57:18 2015 +1100
Branches: master
https://developer.blender.org/rB1898c1f05cd38ea82f6da2ac3af07bab56537f3b
Math Lib: add axis_dominant_v3_ortho_single
===================================================================
M source/blender/blenlib/BLI_math_geom.h
M source/blender/blenlib/intern/math_geom_inline.c
===================================================================
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index d804b57..bf48338 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -417,7 +417,8 @@ void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]);
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3]);
MINLINE float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axis[3]) ATTR_WARN_UNUSED_RESULT;
-MINLINE int axis_dominant_v3_single(const float vec[3]);
+MINLINE int axis_dominant_v3_single(const float vec[3]);
+MINLINE int axis_dominant_v3_ortho_single(const float vec[3]);
MINLINE int max_axis_v3(const float vec[3]);
MINLINE int min_axis_v3(const float vec[3]);
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 44b1768..68a2e68d 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -199,6 +199,17 @@ MINLINE int axis_dominant_v3_single(const float vec[3])
((y > z) ? 1 : 2));
}
+/* the dominant axis of an orthogonal vector */
+MINLINE int axis_dominant_v3_ortho_single(const float vec[3])
+{
+ const float x = fabsf(vec[0]);
+ const float y = fabsf(vec[1]);
+ const float z = fabsf(vec[2]);
+ return ((x < y) ?
+ ((x < z) ? 0 : 2) :
+ ((y < z) ? 1 : 2));
+}
+
MINLINE int max_axis_v3(const float vec[3])
{
const float x = vec[0];
More information about the Bf-blender-cvs
mailing list