Cleanup: rename object base flags to be more clear.
This commit is contained in:
@@ -335,7 +335,7 @@ void BKE_view_layer_base_deselect_all(ViewLayer *view_layer)
|
||||
void BKE_view_layer_base_select(struct ViewLayer *view_layer, Base *selbase)
|
||||
{
|
||||
view_layer->basact = selbase;
|
||||
if ((selbase->flag & BASE_SELECTABLED) != 0) {
|
||||
if ((selbase->flag & BASE_SELECTABLE) != 0) {
|
||||
selbase->flag |= BASE_SELECTED;
|
||||
}
|
||||
}
|
||||
@@ -659,12 +659,12 @@ static int layer_collection_sync(
|
||||
if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) &&
|
||||
((object_restrict & OB_RESTRICT_VIEW) == 0))
|
||||
{
|
||||
base->flag |= BASE_VISIBLED | BASE_VISIBLE_VIEWPORT;
|
||||
base->flag |= BASE_VISIBLE | BASE_ENABLED | BASE_ENABLED_VIEWPORT;
|
||||
|
||||
if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) &&
|
||||
((object_restrict & OB_RESTRICT_SELECT) == 0))
|
||||
{
|
||||
base->flag |= BASE_SELECTABLED;
|
||||
base->flag |= BASE_SELECTABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,18 +672,18 @@ static int layer_collection_sync(
|
||||
((object_restrict & OB_RESTRICT_RENDER) == 0))
|
||||
|
||||
{
|
||||
base->flag |= BASE_VISIBLE_RENDER;
|
||||
base->flag |= BASE_ENABLED_RENDER;
|
||||
}
|
||||
|
||||
/* Update runtime flags used for display and tools. */
|
||||
if (base->flag & BASE_VISIBLED) {
|
||||
if (base->flag & BASE_VISIBLE) {
|
||||
lc->runtime_flag |= LAYER_COLLECTION_HAS_ENABLED_OBJECTS;
|
||||
}
|
||||
|
||||
if (base->flag & BASE_HIDE) {
|
||||
if (base->flag & BASE_HIDDEN) {
|
||||
view_layer->runtime_flag |= VIEW_LAYER_HAS_HIDE;
|
||||
}
|
||||
else if (base->flag & BASE_VISIBLED) {
|
||||
else if (base->flag & BASE_VISIBLE) {
|
||||
lc->runtime_flag |= LAYER_COLLECTION_HAS_VISIBLE_OBJECTS;
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
|
||||
|
||||
/* Clear visible and selectable flags to be reset. */
|
||||
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
|
||||
base->flag &= ~(BASE_VISIBLED | BASE_SELECTABLED | BASE_VISIBLE_VIEWPORT | BASE_VISIBLE_RENDER);
|
||||
base->flag &= ~(BASE_VISIBLE | BASE_ENABLED | BASE_SELECTABLE | BASE_ENABLED_VIEWPORT | BASE_ENABLED_RENDER);
|
||||
}
|
||||
|
||||
view_layer->runtime_flag = 0;
|
||||
@@ -832,7 +832,7 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((base->flag & BASE_SELECTABLED) && !(base->flag & BASE_SELECTED)) {
|
||||
if ((base->flag & BASE_SELECTABLE) && !(base->flag & BASE_SELECTED)) {
|
||||
base->flag |= BASE_SELECTED;
|
||||
changed = true;
|
||||
}
|
||||
@@ -875,32 +875,20 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/* Test base visibility when BASE_VISIBLED has not been set yet. */
|
||||
static bool base_is_visible(Base *base, eEvaluationMode mode)
|
||||
{
|
||||
if (mode == DAG_EVAL_VIEWPORT) {
|
||||
return ((base->flag & BASE_VISIBLE_VIEWPORT) != 0) &&
|
||||
((base->flag & BASE_HIDE) == 0);
|
||||
}
|
||||
else {
|
||||
return ((base->flag & BASE_VISIBLE_RENDER) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update after toggling visibility of an object base. */
|
||||
void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool extend)
|
||||
{
|
||||
if (!extend) {
|
||||
/* Make only one base visible. */
|
||||
for (Base *other = view_layer->object_bases.first; other; other = other->next) {
|
||||
other->flag |= BASE_HIDE;
|
||||
other->flag |= BASE_HIDDEN;
|
||||
}
|
||||
|
||||
base->flag &= ~BASE_HIDE;
|
||||
base->flag &= ~BASE_HIDDEN;
|
||||
}
|
||||
else {
|
||||
/* Toggle visibility of one base. */
|
||||
base->flag ^= BASE_HIDE;
|
||||
base->flag ^= BASE_HIDDEN;
|
||||
}
|
||||
|
||||
BKE_layer_collection_sync(scene, view_layer);
|
||||
@@ -911,7 +899,7 @@ void BKE_layer_collection_set_visible(Scene *scene, ViewLayer *view_layer, Layer
|
||||
if (!extend) {
|
||||
/* Make only objects from one collection visible. */
|
||||
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
|
||||
base->flag |= BASE_HIDE;
|
||||
base->flag |= BASE_HIDDEN;
|
||||
}
|
||||
|
||||
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(lc->collection, ob)
|
||||
@@ -919,7 +907,7 @@ void BKE_layer_collection_set_visible(Scene *scene, ViewLayer *view_layer, Layer
|
||||
Base *base = BLI_ghash_lookup(view_layer->object_bases_hash, ob);
|
||||
|
||||
if (base) {
|
||||
base->flag &= ~BASE_HIDE;
|
||||
base->flag &= ~BASE_HIDDEN;
|
||||
}
|
||||
}
|
||||
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
||||
@@ -936,10 +924,10 @@ void BKE_layer_collection_set_visible(Scene *scene, ViewLayer *view_layer, Layer
|
||||
|
||||
if (base) {
|
||||
if (hide) {
|
||||
base->flag |= BASE_HIDE;
|
||||
base->flag |= BASE_HIDDEN;
|
||||
}
|
||||
else {
|
||||
base->flag &= ~BASE_HIDE;
|
||||
base->flag &= ~BASE_HIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1130,12 +1118,12 @@ void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *UNUSED(iter))
|
||||
|
||||
void BKE_view_layer_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
|
||||
{
|
||||
objects_iterator_begin(iter, data_in, BASE_VISIBLED);
|
||||
objects_iterator_begin(iter, data_in, BASE_VISIBLE);
|
||||
}
|
||||
|
||||
void BKE_view_layer_visible_objects_iterator_next(BLI_Iterator *iter)
|
||||
{
|
||||
objects_iterator_next(iter, BASE_VISIBLED);
|
||||
objects_iterator_next(iter, BASE_VISIBLE);
|
||||
}
|
||||
|
||||
void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *UNUSED(iter))
|
||||
@@ -1206,12 +1194,12 @@ void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *UNUSED(iter))
|
||||
|
||||
void BKE_view_layer_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
|
||||
{
|
||||
object_bases_iterator_begin(iter, data_in, BASE_VISIBLED);
|
||||
object_bases_iterator_begin(iter, data_in, BASE_VISIBLE);
|
||||
}
|
||||
|
||||
void BKE_view_layer_visible_bases_iterator_next(BLI_Iterator *iter)
|
||||
{
|
||||
object_bases_iterator_next(iter, BASE_VISIBLED);
|
||||
object_bases_iterator_next(iter, BASE_VISIBLE);
|
||||
}
|
||||
|
||||
void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *UNUSED(iter))
|
||||
@@ -1269,7 +1257,7 @@ void BKE_view_layer_renderable_objects_iterator_next(BLI_Iterator *iter)
|
||||
if (ob->id.flag & LIB_TAG_DOIT) {
|
||||
ob->id.flag &= ~LIB_TAG_DOIT;
|
||||
|
||||
if ((base->flag & BASE_VISIBLED) != 0) {
|
||||
if ((base->flag & BASE_VISIBLE) != 0) {
|
||||
iter->skip = false;
|
||||
iter->current = ob;
|
||||
}
|
||||
@@ -1377,6 +1365,7 @@ void BKE_layer_eval_view_layer(
|
||||
|
||||
/* Visibility based on depsgraph mode. */
|
||||
const eEvaluationMode mode = DEG_get_mode(depsgraph);
|
||||
const int base_flag = (mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT : BASE_ENABLED_RENDER;
|
||||
|
||||
/* Create array of bases, for fast index-based lookup. */
|
||||
const int num_object_bases = BLI_listbase_count(&view_layer->object_bases);
|
||||
@@ -1385,16 +1374,20 @@ 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) {
|
||||
/* Set visibility. */
|
||||
if (base_is_visible(base, mode)) {
|
||||
base->flag |= BASE_VISIBLED;
|
||||
/* Compute visibility for depsgraph evaluation mode. */
|
||||
if (base->flag & base_flag) {
|
||||
base->flag |= BASE_ENABLED | BASE_VISIBLE;
|
||||
|
||||
if (mode == DAG_EVAL_VIEWPORT && (base->flag & BASE_HIDDEN)) {
|
||||
base->flag &= ~BASE_VISIBLE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
base->flag &= ~(BASE_VISIBLED | BASE_SELECTABLED);
|
||||
base->flag &= ~(BASE_ENABLED | BASE_VISIBLE | BASE_SELECTABLE);
|
||||
}
|
||||
|
||||
/* If base is not selectabled, clear select. */
|
||||
if ((base->flag & BASE_SELECTABLED) == 0) {
|
||||
if ((base->flag & BASE_SELECTABLE) == 0) {
|
||||
base->flag &= ~BASE_SELECTED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user