Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-02-27 19:09:30 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-02-28 18:35:12 +0300
commit846d265a06e39c86574cba6722495b6373596c7a (patch)
treec8534796d130c03faa4bcdc3d7fa558f1a361113 /source/blender/blenkernel
parent7895c6b83db862b13afee1facd8b6dc5e24dbede (diff)
Split base flags on own and collection-defined
This allows to update base flags to a proper state then object's restriction flags are changed, without requiring to re-evaluate an entire tree of flags. Some old unused flags are were removed by this change, and also disabling menu items might not work the same as before. This is something we can bring back if it's really needed (the way how flags are handled did change since that interface code was done anyway, so code was looking weird anyway). Reviewers: brecht Differential Revision: https://developer.blender.org/D4420
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_layer.h2
-rw-r--r--source/blender/blenkernel/intern/layer.c83
-rw-r--r--source/blender/blenkernel/intern/object_update.c3
3 files changed, 47 insertions, 41 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index e3a182f9ec1..f10f2f44706 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -114,6 +114,8 @@ bool BKE_layer_collection_set_visible(struct ViewLayer *view_layer, struct Layer
/* evaluation */
+void BKE_base_eval_flags(struct Base *base);
+
void BKE_layer_eval_view_layer_indexed(
struct Depsgraph *depsgraph,
struct Scene *scene,
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index cf8f94abdae..2bbccec2cfe 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -54,6 +54,13 @@
#include "MEM_guardedalloc.h"
+/* Set of flags which are dependent on a collection settings. */
+static short g_base_collection_flags = (BASE_VISIBLE |
+ BASE_SELECTABLE |
+ BASE_ENABLED_VIEWPORT |
+ BASE_ENABLED_RENDER |
+ BASE_HOLDOUT |
+ BASE_INDIRECT_ONLY);
/* prototype */
static void object_bases_iterator_next(BLI_Iterator *iter, const int flag);
@@ -700,53 +707,32 @@ static short layer_collection_sync(
BLI_addtail(new_object_bases, base);
}
- int object_restrict = base->object->restrictflag;
-
- if (((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) &&
- ((object_restrict & OB_RESTRICT_VIEW) == 0))
- {
- base->flag |= BASE_ENABLED_VIEWPORT;
-
+ if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) {
+ base->flag_from_collection |= BASE_ENABLED_VIEWPORT;
if ((child_layer_restrict & LAYER_COLLECTION_RESTRICT_VIEW) == 0) {
- base->flag |= BASE_VISIBLE;
-
- if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) &&
- ((object_restrict & OB_RESTRICT_SELECT) == 0))
- {
- base->flag |= BASE_SELECTABLE;
+ base->flag_from_collection |= BASE_VISIBLE;
+ if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) {
+ base->flag_from_collection |= BASE_SELECTABLE;
}
}
}
- if (((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) &&
- ((object_restrict & OB_RESTRICT_RENDER) == 0))
- {
- base->flag |= BASE_ENABLED_RENDER;
- }
-
- /* Update runtime flags used for display and tools. */
- if (base->flag & BASE_ENABLED_VIEWPORT) {
- lc->runtime_flag |= LAYER_COLLECTION_HAS_ENABLED_OBJECTS;
- }
-
- if (base->flag & BASE_HIDDEN) {
- base->flag &= ~BASE_VISIBLE;
- view_layer->runtime_flag |= VIEW_LAYER_HAS_HIDE;
- lc->runtime_flag |= LAYER_COLLECTION_HAS_HIDDEN_OBJECTS;
- }
- else if (base->flag & BASE_VISIBLE) {
- lc->runtime_flag |= LAYER_COLLECTION_HAS_VISIBLE_OBJECTS;
+ if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) {
+ base->flag_from_collection |= BASE_ENABLED_RENDER;
}
/* Holdout and indirect only */
if (lc->flag & LAYER_COLLECTION_HOLDOUT) {
- base->flag |= BASE_HOLDOUT;
+ base->flag_from_collection |= BASE_HOLDOUT;
}
if (lc->flag & LAYER_COLLECTION_INDIRECT_ONLY) {
- base->flag |= BASE_INDIRECT_ONLY;
+ base->flag_from_collection |= BASE_INDIRECT_ONLY;
}
lc->runtime_flag |= LAYER_COLLECTION_HAS_OBJECTS;
+
+ /* Make sure flags on base are usable right away. */
+ BKE_base_eval_flags(base);
}
runtime_flag |= lc->runtime_flag;
@@ -781,16 +767,10 @@ 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_VISIBLE |
- BASE_SELECTABLE |
- BASE_ENABLED_VIEWPORT |
- BASE_ENABLED_RENDER |
- BASE_HOLDOUT |
- BASE_INDIRECT_ONLY);
+ base->flag &= ~g_base_collection_flags;
+ base->flag_from_collection &= ~g_base_collection_flags;
}
- view_layer->runtime_flag = 0;
-
/* Generate new layer connections and object bases when collections changed. */
CollectionChild child = {NULL, NULL, scene->master_collection};
const ListBase collections = {&child, &child};
@@ -1461,6 +1441,27 @@ void BKE_view_layer_bases_in_mode_iterator_end(BLI_Iterator *UNUSED(iter))
/* Evaluation */
+/* Applies object's restrict flags on top of flags coming from the collection
+ * and stores those in base->flag. */
+void BKE_base_eval_flags(Base *base)
+{
+ const int object_restrict = base->object->restrictflag;
+ base->flag &= ~g_base_collection_flags;
+ base->flag |= (base->flag_from_collection & g_base_collection_flags);
+ if (object_restrict & OB_RESTRICT_VIEW) {
+ base->flag &= ~(BASE_ENABLED_VIEWPORT | BASE_SELECTABLE);
+ }
+ if (object_restrict & OB_RESTRICT_SELECT) {
+ base->flag &= ~BASE_SELECTABLE;
+ }
+ if (object_restrict & OB_RESTRICT_RENDER) {
+ base->flag &= ~BASE_ENABLED_RENDER;
+ }
+ if (base->flag & BASE_HIDDEN) {
+ base->flag &= ~BASE_VISIBLE;
+ }
+}
+
static void layer_eval_view_layer(
struct Depsgraph *depsgraph,
struct Scene *UNUSED(scene),
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 7f66cfd5dc3..60cf4d1b1d4 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -44,6 +44,7 @@
#include "BKE_effect.h"
#include "BKE_image.h"
#include "BKE_key.h"
+#include "BKE_layer.h"
#include "BKE_light.h"
#include "BKE_lattice.h"
#include "BKE_material.h"
@@ -428,6 +429,8 @@ void BKE_object_eval_eval_base_flags(Depsgraph *depsgraph,
? BASE_ENABLED_VIEWPORT
: BASE_ENABLED_RENDER;
+ BKE_base_eval_flags(base);
+
/* Compute visibility for depsgraph evaluation mode. */
if (base->flag & base_enabled_flag) {
/* When rendering, visibility is controlled by the enable/disable option. */