diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-14 13:13:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-14 13:13:11 +0400 |
commit | 731672fc9bbafe7dfcd0e46921276fa8f0643a5f (patch) | |
tree | d45731c4b62c97c82a9342e1019a2f0cc2e5e80c /source/blender | |
parent | 723eaa36ceea6c5305fb57473ae5e38d8b34249d (diff) |
bmesh utility functions for storing an editselection after another in the list.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 34 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.h | 4 |
2 files changed, 29 insertions, 9 deletions
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index bec301acaa9..0a6c0f4b293 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -816,6 +816,13 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) } } +static BMEditSelection *bm_select_history_create(BMHeader *ele) +{ + BMEditSelection *ese = (BMEditSelection *) MEM_callocN(sizeof(BMEditSelection), "BMEdit Selection"); + ese->htype = ele->htype; + ese->ele = (BMElem *)ele; + return ese; +} /* --- macro wrapped funcs --- */ bool _bm_select_history_check(BMesh *bm, const BMHeader *ele) @@ -837,9 +844,7 @@ bool _bm_select_history_remove(BMesh *bm, BMHeader *ele) void _bm_select_history_store_notest(BMesh *bm, BMHeader *ele) { - BMEditSelection *ese = (BMEditSelection *) MEM_callocN(sizeof(BMEditSelection), "BMEdit Selection"); - ese->htype = ele->htype; - ese->ele = (BMElem *)ele; + BMEditSelection *ese = bm_select_history_create(ele); BLI_addtail(&(bm->selected), ese); } @@ -849,6 +854,20 @@ void _bm_select_history_store(BMesh *bm, BMHeader *ele) BM_select_history_store_notest(bm, (BMElem *)ele); } } + + +void _bm_select_history_store_after_notest(BMesh *bm, BMEditSelection *ese_ref, BMHeader *ele) +{ + BMEditSelection *ese = bm_select_history_create(ele); + BLI_insertlinkafter(&(bm->selected), ese_ref, ese); +} + +void _bm_select_history_store_after(BMesh *bm, BMEditSelection *ese_ref, BMHeader *ele) +{ + if (!BM_select_history_check(bm, (BMElem *)ele)) { + BM_select_history_store_after_notest(bm, ese_ref, (BMElem *)ele); + } +} /* --- end macro wrapped funcs --- */ @@ -861,16 +880,13 @@ void BM_select_history_clear(BMesh *bm) void BM_select_history_validate(BMesh *bm) { - BMEditSelection *ese, *nextese; - - ese = bm->selected.first; + BMEditSelection *ese, *ese_next; - while (ese) { - nextese = ese->next; + for (ese = bm->selected.first; ese; ese = ese_next) { + ese_next = ese->next; if (!BM_elem_flag_test(ese->ele, BM_ELEM_SELECT)) { BLI_freelinkN(&(bm->selected), ese); } - ese = nextese; } } diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h index 062de4f69e1..f23eac61278 100644 --- a/source/blender/bmesh/intern/bmesh_marking.h +++ b/source/blender/bmesh/intern/bmesh_marking.h @@ -87,11 +87,15 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]); #define BM_select_history_remove(bm, ele) _bm_select_history_remove(bm, &(ele)->head) #define BM_select_history_store_notest(bm, ele) _bm_select_history_store_notest(bm, &(ele)->head) #define BM_select_history_store(bm, ele) _bm_select_history_store(bm, &(ele)->head) +#define BM_select_history_store_after_notest(bm, ese_ref, ele) _bm_select_history_store_after_notest(bm, ese_ref, &(ele)->head) +#define BM_select_history_store_after(bm, ese, ese_ref) _bm_select_history_store_after(bm, ese_ref, &(ele)->head) bool _bm_select_history_check(BMesh *bm, const BMHeader *ele); bool _bm_select_history_remove(BMesh *bm, BMHeader *ele); void _bm_select_history_store_notest(BMesh *bm, BMHeader *ele); void _bm_select_history_store(BMesh *bm, BMHeader *ele); +void _bm_select_history_store_after(BMesh *bm, BMEditSelection *ese_ref, BMHeader *ele); +void _bm_select_history_store_after_notest(BMesh *bm, BMEditSelection *ese_ref, BMHeader *ele); void BM_select_history_validate(BMesh *bm); void BM_select_history_clear(BMesh *em); |