diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-04 02:07:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-04 02:07:58 +0400 |
commit | 1531e3677a639b9265d26d73e3bc5ee21e996af8 (patch) | |
tree | 4eaa8230aefc3a9071dc4d1359244aade8156e12 /source/blender/blenlib/intern | |
parent | 685fda4f13715ccadb32fa72af1b557cb55c9574 (diff) |
bmesh py api
* add BLI_rfindlink for reverse index lookup (used so bm.select_history[-1] doesn't have to loop the entire list twice).
* add bm.select_history.active so you can get the last selected item or None without having to check seq length.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/listbase.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index 52fd857d6e4..6155bf83a57 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -338,6 +338,21 @@ void *BLI_findlink(const ListBase *listbase, int number) return link; } +void *BLI_rfindlink(const ListBase *listbase, int number) +{ + Link *link = NULL; + + if (number >= 0) { + link = listbase->last; + while (link != NULL && number != 0) { + number--; + link = link->prev; + } + } + + return link; +} + int BLI_findindex(const ListBase *listbase, void *vlink) { Link *link= NULL; |