Cleanup: simplify some view layer code.
This commit is contained in:
parent
0365079676
commit
7c836ac30a
|
@ -1225,6 +1225,16 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
|
|||
|
||||
/** \} */
|
||||
|
||||
static bool base_is_visible(Base *base, eEvaluationMode mode)
|
||||
{
|
||||
if (mode == DAG_EVAL_VIEWPORT) {
|
||||
return ((base->flag & BASE_VISIBLE_VIEWPORT) != 0);
|
||||
}
|
||||
else {
|
||||
return ((base->flag & BASE_VISIBLE_RENDER) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Evaluation */
|
||||
|
||||
void BKE_layer_eval_view_layer(
|
||||
|
@ -1234,21 +1244,8 @@ void BKE_layer_eval_view_layer(
|
|||
{
|
||||
DEG_debug_print_eval(depsgraph, __func__, view_layer->name, view_layer);
|
||||
|
||||
/* Set visibility based on depsgraph mode. */
|
||||
/* Visibility based on depsgraph mode. */
|
||||
const eEvaluationMode mode = DEG_get_mode(depsgraph);
|
||||
const int base_flag = (mode == DAG_EVAL_VIEWPORT) ? BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER;
|
||||
|
||||
for (Base *base = view_layer->object_bases.first; base != NULL; base = base->next) {
|
||||
if (base->flag & base_flag) {
|
||||
base->flag |= BASE_VISIBLED;
|
||||
}
|
||||
else {
|
||||
base->flag &= ~BASE_VISIBLED;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO(sergey): Is it always required? */
|
||||
view_layer->flag |= VIEW_LAYER_ENGINE_DIRTY;
|
||||
|
||||
/* Create array of bases, for fast index-based lookup. */
|
||||
const int num_object_bases = BLI_listbase_count(&view_layer->object_bases);
|
||||
|
@ -1257,13 +1254,23 @@ void BKE_layer_eval_view_layer(
|
|||
num_object_bases, sizeof(Base *), "view_layer->object_bases_array");
|
||||
int base_index = 0;
|
||||
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
|
||||
/* if base is not selectabled, clear select. */
|
||||
/* Set visibility. */
|
||||
if (base_is_visible(base, mode)) {
|
||||
base->flag |= BASE_VISIBLED;
|
||||
}
|
||||
else {
|
||||
base->flag &= ~(BASE_VISIBLED | BASE_SELECTABLED);
|
||||
}
|
||||
|
||||
/* If base is not selectabled, clear select. */
|
||||
if ((base->flag & BASE_SELECTABLED) == 0) {
|
||||
base->flag &= ~BASE_SELECTED;
|
||||
}
|
||||
/* Store base in the array. */
|
||||
|
||||
view_layer->object_bases_array[base_index++] = base;
|
||||
}
|
||||
|
||||
/* Flush back base flag to the original view layer for editing. */
|
||||
if (view_layer == DEG_get_evaluated_view_layer(depsgraph)) {
|
||||
ViewLayer *view_layer_orig = DEG_get_input_view_layer(depsgraph);
|
||||
Base *base_orig = view_layer_orig->object_bases.first;
|
||||
|
|
|
@ -5613,9 +5613,6 @@ static void lib_link_layer_collection(FileData *fd, Library *lib, LayerCollectio
|
|||
|
||||
static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer)
|
||||
{
|
||||
/* tag scene layer to update for collection tree evaluation */
|
||||
view_layer->flag |= VIEW_LAYER_ENGINE_DIRTY;
|
||||
|
||||
for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; fmc = fmc->next) {
|
||||
fmc->script = newlibadr(fd, lib, fmc->script);
|
||||
}
|
||||
|
@ -5630,7 +5627,6 @@ static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_laye
|
|||
|
||||
/* we only bump the use count for the collection objects */
|
||||
base->object = newlibadr(fd, lib, base->object);
|
||||
base->flag |= BASE_DIRTY_ENGINE_SETTINGS;
|
||||
|
||||
if (base->object == NULL) {
|
||||
/* Free in case linked object got lost. */
|
||||
|
|
|
@ -93,7 +93,7 @@ enum {
|
|||
BASE_VISIBLED = (1 << 1),
|
||||
BASE_SELECTABLED = (1 << 2),
|
||||
BASE_FROMDUPLI = (1 << 3),
|
||||
BASE_DIRTY_ENGINE_SETTINGS = (1 << 4),
|
||||
/* BASE_DEPRECATED = (1 << 4), */
|
||||
BASE_FROM_SET = (1 << 5), /* To be set only by the depsgraph */
|
||||
BASE_VISIBLE_VIEWPORT = (1 << 6),
|
||||
BASE_VISIBLE_RENDER = (1 << 7),
|
||||
|
@ -111,7 +111,7 @@ enum {
|
|||
/* ViewLayer->flag */
|
||||
enum {
|
||||
VIEW_LAYER_RENDER = (1 << 0),
|
||||
VIEW_LAYER_ENGINE_DIRTY = (1 << 1),
|
||||
/* VIEW_LAYER_DEPRECATED = (1 << 1), */
|
||||
VIEW_LAYER_FREESTYLE = (1 << 2),
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue