FOREACH_VISIBLE_OBJECT macro
Also adding a new flag value for ObjectBase to store visibility. I still need this to be synced, but the idea is to centralize the logic of tree evluation, and keep the visibility cached.
This commit is contained in:
@@ -94,6 +94,10 @@ void BKE_selected_objects_Iterator_begin(Iterator *iter, void *data_in);
|
||||
void BKE_selected_objects_Iterator_next(Iterator *iter);
|
||||
void BKE_selected_objects_Iterator_end(Iterator *iter);
|
||||
|
||||
void BKE_visible_objects_Iterator_begin(Iterator *iter, void *data_in);
|
||||
void BKE_visible_objects_Iterator_next(Iterator *iter);
|
||||
void BKE_visible_objects_Iterator_end(Iterator *iter);
|
||||
|
||||
#define FOREACH_SELECTED_OBJECT(sl, _ob) \
|
||||
ITER_BEGIN(BKE_selected_objects_Iterator_begin, \
|
||||
BKE_selected_objects_Iterator_next, \
|
||||
@@ -103,6 +107,15 @@ void BKE_selected_objects_Iterator_end(Iterator *iter);
|
||||
#define FOREACH_SELECTED_OBJECT_END \
|
||||
ITER_END
|
||||
|
||||
#define FOREACH_VISIBLE_OBJECT(sl, _ob) \
|
||||
ITER_BEGIN(BKE_visible_objects_Iterator_begin, \
|
||||
BKE_visible_objects_Iterator_next, \
|
||||
BKE_visible_objects_Iterator_end, \
|
||||
sl, _ob)
|
||||
|
||||
#define FOREACH_VISIBLE_OBJECT_END \
|
||||
ITER_END
|
||||
|
||||
#define FOREACH_OBJECT(sl, _ob) \
|
||||
{ \
|
||||
ObjectBase *base; \
|
||||
|
@@ -500,6 +500,7 @@ void BKE_collection_override_datablock_add(LayerCollection *UNUSED(lc), const ch
|
||||
TODO_LAYER_OVERRIDE;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Iterators */
|
||||
|
||||
void BKE_selected_objects_Iterator_begin(Iterator *iter, void *data_in)
|
||||
@@ -545,3 +546,47 @@ void BKE_selected_objects_Iterator_end(Iterator *UNUSED(iter))
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
void BKE_visible_objects_Iterator_begin(Iterator *iter, void *data_in)
|
||||
{
|
||||
SceneLayer *sl = data_in;
|
||||
ObjectBase *base = sl->object_bases.first;
|
||||
|
||||
/* when there are no objects */
|
||||
if (base == NULL) {
|
||||
iter->valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
iter->valid = true;
|
||||
iter->data = base;
|
||||
|
||||
if ((base->flag & BASE_VISIBLE) == 0) {
|
||||
BKE_selected_objects_Iterator_next(iter);
|
||||
}
|
||||
else {
|
||||
iter->current = base->object;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_visible_objects_Iterator_next(Iterator *iter)
|
||||
{
|
||||
ObjectBase *base = ((ObjectBase *)iter->data)->next;
|
||||
|
||||
while (base) {
|
||||
if ((base->flag & BASE_VISIBLE) != 0) {
|
||||
iter->current = base->object;
|
||||
iter->data = base;
|
||||
return;
|
||||
}
|
||||
base = base->next;
|
||||
};
|
||||
|
||||
iter->current = NULL;
|
||||
iter->valid = false;
|
||||
}
|
||||
|
||||
void BKE_visible_objects_Iterator_end(Iterator *UNUSED(iter))
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
@@ -80,6 +80,7 @@ typedef struct SceneCollection {
|
||||
/* ObjectBase->flag */
|
||||
enum {
|
||||
BASE_SELECTED = (1 << 0),
|
||||
BASE_VISIBLE = (1 << 1),
|
||||
};
|
||||
|
||||
/* LayerCollection->flag */
|
||||
|
Reference in New Issue
Block a user