diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-01-11 16:35:36 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-01-11 16:35:36 +0300 |
commit | c36f4a7f7f370ebb6e944d9893d2677232d3b7f8 (patch) | |
tree | c2030541dcaae70b2892c6838e8a3e76e24843e1 /source/blender/editors/transform/transform_orientations.c | |
parent | cc63c8511cb18cc59fb2874dd5a57d89b7123bac (diff) | |
parent | b415ed55a74c51b944cd0682fc7a81679778ac8f (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenkernel/intern/blender.c
source/blender/makesdna/DNA_ID.h
Diffstat (limited to 'source/blender/editors/transform/transform_orientations.c')
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 63cd5291193..f8b11a0bcae 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -735,10 +735,19 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 SWAP(BMVert *, v_pair[0], v_pair[1]); } - add_v3_v3v3(normal, v_pair[0]->no, v_pair[1]->no); - sub_v3_v3v3(plane, v_pair[0]->co, v_pair[1]->co); - /* flip the plane normal so we point outwards */ - negate_v3(plane); + add_v3_v3v3(normal, v_pair[1]->no, v_pair[0]->no); + sub_v3_v3v3(plane, v_pair[1]->co, v_pair[0]->co); + + if (normalize_v3(plane) != 0.0f) { + /* For edges it'd important the resulting matrix can rotate around the edge, + * project onto the plane so we can use a fallback value. */ + project_plane_normalized_v3_v3v3(normal, normal, plane); + if (UNLIKELY(normalize_v3(normal) == 0.0f)) { + /* in the case the normal and plane are aligned, + * use a fallback normal which is orthogonal to the plane. */ + ortho_v3_v3(normal, plane); + } + } } result = ORIENTATION_EDGE; |