Merge branch 'master' into blender2.8
[blender.git] / source / blender / bmesh / intern / bmesh_marking.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Joseph Eagar.
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 #ifndef __BMESH_MARKING_H__
24 #define __BMESH_MARKING_H__
25
26 /** \file blender/bmesh/intern/bmesh_marking.h
27  *  \ingroup bmesh
28  */
29
30 typedef struct BMEditSelection {
31         struct BMEditSelection *next, *prev;
32         BMElem *ele;
33         char htype;
34 } BMEditSelection;
35
36 /* geometry hiding code */
37 #define BM_elem_hide_set(bm, ele, hide) _bm_elem_hide_set(bm, &(ele)->head, hide)
38 void _bm_elem_hide_set(BMesh *bm, BMHeader *ele, const bool hide);
39 void BM_vert_hide_set(BMVert *v, const bool hide);
40 void BM_edge_hide_set(BMEdge *e, const bool hide);
41 void BM_face_hide_set(BMFace *f, const bool hide);
42
43 /* Selection code */
44 void BM_elem_select_set(BMesh *bm, BMElem *ele, const bool select);
45
46 void BM_mesh_elem_hflag_enable_test(
47         BMesh *bm, const char htype, const char hflag,
48         const bool respecthide, const bool overwrite, const char hflag_test);
49 void BM_mesh_elem_hflag_disable_test(
50         BMesh *bm, const char htype, const char hflag,
51         const bool respecthide, const bool overwrite, const char hflag_test);
52
53 void BM_mesh_elem_hflag_enable_all(
54         BMesh *bm, const char htype, const char hflag,
55         const bool respecthide);
56 void BM_mesh_elem_hflag_disable_all(
57         BMesh *bm, const char htype, const char hflag,
58         const bool respecthide);
59
60 /* individual element select functions, BM_elem_select_set is a shortcut for these
61  * that automatically detects which one to use*/
62 void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select);
63 void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select);
64 void BM_face_select_set(BMesh *bm, BMFace *f, const bool select);
65
66 /* lower level functions which don't do flushing */
67 void BM_edge_select_set_noflush(BMesh *bm, BMEdge *e, const bool select);
68 void BM_face_select_set_noflush(BMesh *bm, BMFace *e, const bool select);
69
70 void BM_mesh_select_mode_clean_ex(BMesh *bm, const short selectmode);
71 void BM_mesh_select_mode_clean(BMesh *bm);
72
73 void BM_mesh_select_mode_set(BMesh *bm, int selectmode);
74 void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode);
75 void BM_mesh_select_mode_flush(BMesh *bm);
76
77 void BM_mesh_deselect_flush(BMesh *bm);
78 void BM_mesh_select_flush(BMesh *bm);
79
80 int BM_mesh_elem_hflag_count_enabled(BMesh *bm, const char htype, const char hflag, const bool respecthide);
81 int BM_mesh_elem_hflag_count_disabled(BMesh *bm, const char htype, const char hflag, const bool respecthide);
82
83 /* edit selection stuff */
84 void    BM_mesh_active_face_set(BMesh *bm, BMFace *f);
85 BMFace *BM_mesh_active_face_get(BMesh *bm, const bool is_sloppy, const bool is_selected);
86 BMEdge *BM_mesh_active_edge_get(BMesh *bm);
87 BMVert *BM_mesh_active_vert_get(BMesh *bm);
88 BMElem *BM_mesh_active_elem_get(BMesh *bm);
89
90 void    BM_editselection_center(BMEditSelection *ese, float r_center[3]);
91 void    BM_editselection_normal(BMEditSelection *ese, float r_normal[3]);
92 void    BM_editselection_plane(BMEditSelection *ese,  float r_plane[3]);
93
94 #define BM_select_history_check(bm, ele)        _bm_select_history_check(bm,        &(ele)->head)
95 #define BM_select_history_remove(bm, ele)       _bm_select_history_remove(bm,       &(ele)->head)
96 #define BM_select_history_store_notest(bm, ele) _bm_select_history_store_notest(bm, &(ele)->head)
97 #define BM_select_history_store(bm, ele)        _bm_select_history_store(bm,        &(ele)->head)
98 #define BM_select_history_store_head_notest(bm, ele) _bm_select_history_store_head_notest(bm, &(ele)->head)
99 #define BM_select_history_store_head(bm, ele)        _bm_select_history_store_head(bm,        &(ele)->head)
100 #define BM_select_history_store_after_notest(bm, ese_ref, ele) _bm_select_history_store_after_notest(bm, ese_ref, &(ele)->head)
101 #define BM_select_history_store_after(bm, ese, ese_ref)        _bm_select_history_store_after(bm,        ese_ref, &(ele)->head)
102
103 bool _bm_select_history_check(BMesh *bm,  const BMHeader *ele);
104 bool _bm_select_history_remove(BMesh *bm,       BMHeader *ele);
105 void _bm_select_history_store_notest(BMesh *bm, BMHeader *ele);
106 void _bm_select_history_store(BMesh *bm,        BMHeader *ele);
107 void _bm_select_history_store_head_notest(BMesh *bm, BMHeader *ele);
108 void _bm_select_history_store_head(BMesh *bm,        BMHeader *ele);
109 void _bm_select_history_store_after(BMesh *bm,  BMEditSelection *ese_ref, BMHeader *ele);
110 void _bm_select_history_store_after_notest(BMesh *bm,  BMEditSelection *ese_ref, BMHeader *ele);
111
112 void BM_select_history_validate(BMesh *bm);
113 void BM_select_history_clear(BMesh *bm);
114 bool BM_select_history_active_get(BMesh *bm, struct BMEditSelection *ese);
115 struct GHash *BM_select_history_map_create(BMesh *bm);
116
117 #define BM_SELECT_HISTORY_BACKUP(bm) { \
118         ListBase _bm_prev_selected = (bm)->selected; BLI_listbase_clear(&(bm)->selected)
119
120 #define BM_SELECT_HISTORY_RESTORE(bm) \
121         (bm)->selected = _bm_prev_selected; } (void)0
122
123 #endif /* __BMESH_MARKING_H__ */