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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-03-16 19:31:19 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-03-16 19:31:19 +0400
commit0e9084d5ece71185884d7a63b3e0617254430a29 (patch)
tree0d4571651cb6ce55f921f6194218568c17441d4e /source/blender/blenlib/intern/math_vector.c
parentcaf8684b5066720d4f4124092e23857dd462cb8b (diff)
Fix T39210: Grid Fill is generating mesh that's inconsistent with selected edge loops
Issue was in BLI's rotation_between_vecs_to_quat(), which did not handled correctly cases where both vectors are colinear. Patch by Campbell Barton and me. Issue originaly tracked down by Yan Shi, many thanks!
Diffstat (limited to 'source/blender/blenlib/intern/math_vector.c')
-rw-r--r--source/blender/blenlib/intern/math_vector.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 098272c9bc0..b189fc32284 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -514,6 +514,36 @@ void ortho_basis_v3v3_v3(float v1[3], float v2[3], const float v[3])
}
}
+/**
+ * Calculates \a p - a perpendicular vector to \a v
+ *
+ * \note return vector won't maintain same length.
+ */
+void ortho_v3_v3(float p[3], const float v[3])
+{
+ const int axis = axis_dominant_v3_single(v);
+
+ BLI_assert(p != v);
+
+ switch (axis) {
+ case 0:
+ p[0] = -v[1] - v[2];
+ p[1] = v[0];
+ p[2] = v[0];
+ break;
+ case 1:
+ p[0] = v[1];
+ p[1] = -v[0] - v[2];
+ p[2] = v[1];
+ break;
+ case 2:
+ p[0] = v[2];
+ p[1] = v[2];
+ p[2] = -v[0] - v[1];
+ break;
+ }
+}
+
/* Rotate a point p by angle theta around an arbitrary axis r
* http://local.wasp.uwa.edu.au/~pbourke/geometry/
*/