diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-09-14 19:30:26 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-09-14 19:32:04 +0300 |
commit | b62d140be9319ecb1e8f38228f0f22926d7a8880 (patch) | |
tree | 92fec4b6d3307b82cc6925dcbd616452385ef3c2 /source/blender/draw/intern/draw_common.c | |
parent | 5feb03c3ae3353f1a616412f7384511f693ebc33 (diff) |
Object Mode: Make Flat object outline visible in orthographic view
Diffstat (limited to 'source/blender/draw/intern/draw_common.c')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 3d6b2015e49..876f4401927 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -30,6 +30,7 @@ #include "UI_resources.h" +#include "BKE_object.h" #include "BKE_global.h" #include "BKE_colorband.h" @@ -882,3 +883,42 @@ float *DRW_color_background_blend_get(int theme_id) return ret; } + + +bool DRW_object_is_flat(Object *ob, int *axis) +{ + float dim[3]; + + if (!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { + /* Non-meshes object cannot be considered as flat. */ + return false; + } + + BKE_object_dimensions_get(ob, dim); + if (dim[0] == 0.0f) { + *axis = 0; + return true; + } + else if (dim[1] == 0.0f) { + *axis = 1; + return true; + } + else if (dim[2] == 0.0f) { + *axis = 2; + return true; + } + return false; +} + +bool DRW_object_axis_orthogonal_to_view(Object *ob, int axis) +{ + float ob_rot[3][3], invviewmat[4][4]; + DRW_viewport_matrix_get(invviewmat, DRW_MAT_VIEWINV); + BKE_object_rot_to_mat3(ob, ob_rot, true); + float dot = dot_v3v3(ob_rot[axis], invviewmat[2]); + if (fabsf(dot) < 1e-3) { + return true; + } + + return false; +} |