[Bf-blender-cvs] [4f79d68c03e] id_override_static: Remove override update from DEG, simply do it on undo push.
Bastien Montagne
noreply at git.blender.org
Fri Nov 24 17:07:48 CET 2017
Commit: 4f79d68c03e5cfd706c50babff5d479f51d538b8
Author: Bastien Montagne
Date: Fri Nov 24 16:48:31 2017 +0100
Branches: id_override_static
https://developer.blender.org/rB4f79d68c03e5cfd706c50babff5d479f51d538b8
Remove override update from DEG, simply do it on undo push.
===================================================================
M source/blender/blenkernel/BKE_library_override.h
M source/blender/blenkernel/intern/library_override.c
M source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M source/blender/editors/util/undo.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h
index bbc1cd962e1..ebb1e9d80a7 100644
--- a/source/blender/blenkernel/BKE_library_override.h
+++ b/source/blender/blenkernel/BKE_library_override.h
@@ -65,6 +65,7 @@ bool BKE_override_status_check_local(struct ID *local);
bool BKE_override_status_check_reference(struct ID *local);
bool BKE_override_operations_create(struct ID *local, const bool no_skip);
+void BKE_main_override_operations_create(struct Main *bmain);
void BKE_override_update(struct Main *bmain, struct ID *local);
void BKE_main_override_update(struct Main *bmain);
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 934d4da08ff..d2c55decb19 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -169,7 +169,7 @@ ID *BKE_override_create_from(Main *bmain, ID *reference_id)
*/
IDOverrideProperty *BKE_override_property_find(IDOverride *override, const char *rna_path)
{
- /* XXX TODO we'll most likely want a runtime ghash to store taht mapping at some point. */
+ /* XXX TODO we'll most likely want a runtime ghash to store that mapping at some point. */
return BLI_findstring_ptr(&override->properties, rna_path, offsetof(IDOverrideProperty, rna_path));
}
@@ -477,6 +477,27 @@ bool BKE_override_operations_create(ID *local, const bool no_skip)
return ret;
}
+/** Check all overrides from given \a bmain and create/update overriding operations as needed. */
+void BKE_main_override_operations_create(Main *bmain)
+{
+ ListBase *lbarray[MAX_LIBARRAY];
+ int base_count, i;
+
+ base_count = set_listbasepointers(bmain, lbarray);
+
+ for (i = 0; i < base_count; i++) {
+ ListBase *lb = lbarray[i];
+ ID *id;
+
+ for (id = lb->first; id; id = id->next) {
+ /* TODO Maybe we could also add an 'override update' tag e.g. when tagging for DEG update? */
+ if (id->lib == NULL && id->override != NULL && id->override->reference != NULL && (id->flag & LIB_AUTOOVERRIDE)) {
+ BKE_override_operations_create(id, true);
+ }
+ }
+ }
+}
+
/** Update given override from its reference (re-applying overriden properties). */
void BKE_override_update(Main *bmain, ID *local)
{
@@ -597,7 +618,7 @@ ID *BKE_override_operations_store_start(OverrideStorage *override_storage, ID *l
return NULL;
}
- /* Forcefully ensure we now about all needed override operations. */
+ /* Forcefully ensure we know about all needed override operations. */
BKE_override_operations_create(local, true);
ID *storage_id;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index bf38e5e26b2..221fcea5498 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -80,7 +80,6 @@ extern "C" {
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
-#include "BKE_library_override.h"
#include "BKE_main.h"
#include "BKE_mask.h"
#include "BKE_material.h"
@@ -180,55 +179,31 @@ DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id, bool do_tag)
{
- IDDepsNode *id_node = NULL;
- bool is_idnode_created = false;
-
if (!DEG_depsgraph_use_copy_on_write()) {
- id_node = graph_->add_id_node(id);
-
- /* Zero number of components indicates that ID node was just created. */
- is_idnode_created = (BLI_ghash_size(id_node->components) == 0);
+ return graph_->add_id_node(id);
}
- else {
- ID *id_cow = (ID *)BLI_ghash_lookup(cow_id_hash_, id);
- if (id_cow != NULL) {
- /* TODO(sergey): Is it possible to lookup and pop element from GHash
- * at the same time?
- */
- BLI_ghash_remove(cow_id_hash_, id, NULL, NULL);
- }
- id_node = graph_->add_id_node(id, do_tag, id_cow);
-
- /* Zero number of components indicates that ID node was just created. */
- is_idnode_created = (BLI_ghash_size(id_node->components) == 0);
-
- /* Currently all ID nodes are supposed to have copy-on-write logic. */
- if (is_idnode_created) {
- ComponentDepsNode *comp_cow =
- id_node->add_component(DEG_NODE_TYPE_COPY_ON_WRITE);
- OperationDepsNode *op_cow = comp_cow->add_operation(
- function_bind(deg_evaluate_copy_on_write, _1, graph_, id_node),
- DEG_OPCODE_COPY_ON_WRITE,
- "", -1);
- graph_->operations.push_back(op_cow);
- }
+ IDDepsNode *id_node = NULL;
+ ID *id_cow = (ID *)BLI_ghash_lookup(cow_id_hash_, id);
+ if (id_cow != NULL) {
+ /* TODO(sergey): Is it possible to lookup and pop element from GHash
+ * at the same time?
+ */
+ BLI_ghash_remove(cow_id_hash_, id, NULL, NULL);
}
-
- if (is_idnode_created) {
- if (id->override != NULL && (id->flag & LIB_AUTOOVERRIDE) != 0) {
- printf("new idnode for overriding ID %s, adding overide_generator component...\n", id->name);
- ComponentDepsNode *comp_node = id_node->add_component(DEG_NODE_TYPE_PARAMETERS, "override_generator");
-
- /* TODO We most certainly do not want to run this on every deg evaluation! Especially not during animation? */
- /* Ideally, putting this in some kind of queue (only one entry per ID in whole queue) and consuming it in a
- * low-priority background thread would be ideal, but we need to ensure IDs remain valid for the thread? */
- /* However currently, operation is essentially a NOP most of the time
- * (uses a delay to only actually run at most every 200ms or so). */
- add_operation_node(comp_node, function_bind(BKE_override_operations_create, id, false),
- DEG_OPCODE_PARAMETERS_EVAL, "override_generator", -1);
- }
+ id_node = graph_->add_id_node(id, do_tag, id_cow);
+ /* Currently all ID nodes are supposed to have copy-on-write logic.
+ *
+ * NOTE: Zero number of components indicates that ID node was just created.
+ */
+ if (BLI_ghash_size(id_node->components) == 0) {
+ ComponentDepsNode *comp_cow =
+ id_node->add_component(DEG_NODE_TYPE_COPY_ON_WRITE);
+ OperationDepsNode *op_cow = comp_cow->add_operation(
+ function_bind(deg_evaluate_copy_on_write, _1, graph_, id_node),
+ DEG_OPCODE_COPY_ON_WRITE,
+ "", -1);
+ graph_->operations.push_back(op_cow);
}
-
return id_node;
}
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 1ee1430d9f0..fb875b91614 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -45,6 +45,7 @@
#include "BKE_blender_undo.h"
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_library_override.h"
#include "BKE_main.h"
#include "BKE_screen.h"
@@ -82,6 +83,9 @@ void ED_undo_push(bContext *C, const char *str)
if (G.debug & G_DEBUG)
printf("%s: %s\n", __func__, str);
+ /* Always do it for now, this might need to be refined... */
+ BKE_main_override_operations_create(CTX_data_main(C));
+
if (obedit) {
if (U.undosteps == 0) return;
More information about the Bf-blender-cvs
mailing list