diff options
author | Martin Poirier <theeth@yahoo.com> | 2008-11-29 23:37:10 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2008-11-29 23:37:10 +0300 |
commit | e2fb12ea18b4be8159fa14252af537d7dc01f585 (patch) | |
tree | c5eea0fac47da7b36c725c61bb87ca58b221803e /source/blender/blenlib | |
parent | d467158158b92ac9e92482db00ee51b2c16597f3 (diff) |
Step 3/3, merging subdivision/bone creation methods using iterators
This also adds a special Embedding option called "Peel Objects". This option makes the embedding snap consider objects as whole, taking the first and last hit of each of them to calculate the embedding point (instead of peeling with first/second, third/fourth and so on). This option is useful if you have mecanical pieces with lots of details (as single objects) and want to put bones in the middle (think of adding bones to a mecha, for example).
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_graph.h | 14 | ||||
-rw-r--r-- | source/blender/blenlib/intern/graph.c | 55 |
2 files changed, 66 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_graph.h b/source/blender/blenlib/BLI_graph.h index 7629dbf6ba8..f4fccfcbb2c 100644 --- a/source/blender/blenlib/BLI_graph.h +++ b/source/blender/blenlib/BLI_graph.h @@ -62,13 +62,25 @@ typedef struct BArc { struct BArcIterator; +void* IT_head(void* iter); +void* IT_tail(void* iter); +void* IT_peek(void* iter, int n); +void* IT_next(void* iter); +void* IT_nextN(void* iter, int n); +void* IT_previous(void* iter); +int IT_stopped(void* iter); + +typedef void* (*HeadFct)(void* iter); +typedef void* (*TailFct)(void* iter); typedef void* (*PeekFct)(void* iter, int n); typedef void* (*NextFct)(void* iter); typedef void* (*NextNFct)(void* iter, int n); typedef void* (*PreviousFct)(void* iter); -typedef int (*StoppedFct)(void* iter); +typedef int (*StoppedFct)(void* iter); typedef struct BArcIterator { + HeadFct head; + TailFct tail; PeekFct peek; NextFct next; NextNFct nextN; diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index e2ed8f11ee2..ca82fcac844 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -465,8 +465,6 @@ int subtreeShape(BNode *node, BArc *rootArc, int include_root) int BLI_subtreeShape(BGraph *graph, BNode *node, BArc *rootArc, int include_root) { - BNode *test_node; - BLI_flagNodes(graph, 0); return subtreeShape(node, rootArc, include_root); } @@ -1090,3 +1088,56 @@ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit) } } +void* IT_head(void* arg) +{ + BArcIterator *iter = (BArcIterator*)arg; + return iter->head(iter); +} + +void* IT_tail(void* arg) +{ + BArcIterator *iter = (BArcIterator*)arg; + return iter->tail(iter); +} + +void* IT_peek(void* arg, int n) +{ + BArcIterator *iter = (BArcIterator*)arg; + + if (iter->index + n < 0) + { + return iter->head(iter); + } + else if (iter->index + n >= iter->length) + { + return iter->tail(iter); + } + else + { + return iter->peek(iter, n); + } +} + +void* IT_next(void* arg) +{ + BArcIterator *iter = (BArcIterator*)arg; + return iter->next(iter); +} + +void* IT_nextN(void* arg, int n) +{ + BArcIterator *iter = (BArcIterator*)arg; + return iter->nextN(iter, n); +} + +void* IT_previous(void* arg) +{ + BArcIterator *iter = (BArcIterator*)arg; + return iter->previous(iter); +} + +int IT_stopped(void* arg) +{ + BArcIterator *iter = (BArcIterator*)arg; + return iter->stopped(iter); +} |