[Bf-blender-cvs] [cf2e35fcfe3] blender2.8: Fix T58118: Make duplicates real does nothing

Sergey Sharybin noreply at git.blender.org
Tue Dec 4 16:05:52 CET 2018


Commit: cf2e35fcfe31aa2c1836f51d1206901b4be6aeba
Author: Sergey Sharybin
Date:   Tue Dec 4 16:04:10 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBcf2e35fcfe31aa2c1836f51d1206901b4be6aeba

Fix T58118: Make duplicates real does nothing

The issue was caused by transflag set in geometry evaluation
never copied back top original object.

Now we have a dedicated operation which does all sort copy
back to original object, so we don't have to worry about
atomic assignments or what gets set where.

Still need to move boundbox to the same function, but it
needs some careful doublechecking first.

===================================================================

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph_type_defines.cc
M	source/blender/depsgraph/intern/depsgraph_types.h
M	source/blender/depsgraph/intern/nodes/deg_node_component.cc
M	source/blender/depsgraph/intern/nodes/deg_node_component.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 35de1501494..ff069bcbe79 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -247,7 +247,10 @@ void BKE_object_eval_uber_data(
         struct Scene *scene,
         struct Object *ob);
 
-void BKE_object_eval_boundbox(struct Depsgraph *depsgraph, struct Object *object);
+void BKE_object_eval_boundbox(struct Depsgraph *depsgraph,
+                              struct Object *object);
+void BKE_object_synchronize_to_original(struct Depsgraph *depsgraph,
+                                        struct Object *object);
 
 void BKE_object_eval_ptcache_reset(
         struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 2ac4c739e09..b95f1c821e2 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -142,14 +142,6 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
 	/* Set negative scale flag in object. */
 	if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
 	else ob->transflag &= ~OB_NEG_SCALE;
-
-	if (DEG_is_active(depsgraph)) {
-		Object *ob_orig = DEG_get_original_object(ob);
-		copy_m4_m4(ob_orig->obmat, ob->obmat);
-		copy_m4_m4(ob_orig->constinv, ob->constinv);
-		ob_orig->transflag = ob->transflag;
-		ob_orig->flag = ob->flag;
-	}
 }
 
 void BKE_object_handle_data_update(
@@ -271,6 +263,8 @@ void BKE_object_handle_data_update(
 	BKE_object_eval_boundbox(depsgraph, ob);
 }
 
+/* TODO(sergey): Ensure that bounding box is already calculated, and move this
+ * into BKE_object_synchronize_to_original(). */
 void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
 {
 	if (!DEG_is_active(depsgraph)) {
@@ -286,6 +280,21 @@ void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
 	}
 }
 
+void BKE_object_synchronize_to_original(Depsgraph *depsgraph, Object *object)
+{
+	if (!DEG_is_active(depsgraph)) {
+		return;
+	}
+	Object *object_orig = DEG_get_original_object(object);
+	/* Base flags. */
+	object_orig->base_flag = object->base_flag;
+	/* Transformation flags. */
+	copy_m4_m4(object_orig->obmat, object->obmat);
+	copy_m4_m4(object_orig->constinv, object->constinv);
+	object_orig->transflag = object->transflag;
+	object_orig->flag = object->flag;
+}
+
 bool BKE_object_eval_proxy_copy(Depsgraph *depsgraph,
                                 Object *object)
 {
@@ -430,12 +439,6 @@ void BKE_object_eval_flush_base_flags(Depsgraph *depsgraph,
 	}
 	object->base_local_view_bits = base->local_view_bits;
 
-	/* Copy to original object datablock if needed. */
-	if (DEG_is_active(depsgraph)) {
-		Object *object_orig = DEG_get_original_object(object);
-		object_orig->base_flag = object->base_flag;
-	}
-
 	if (object->mode == OB_MODE_PARTICLE_EDIT) {
 		for (ParticleSystem *psys = object->particlesystem.first;
 		     psys != NULL;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 8726f51012e..d1837e7a69a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -579,6 +579,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
 	}
 	/* Create ID node for object and begin init. */
 	IDDepsNode *id_node = add_id_node(&object->id);
+	Object *object_cow = get_cow_datablock(object);
 	id_node->linked_state = linked_state;
 	if (object == scene_->camera) {
 		id_node->is_directly_visible = true;
@@ -663,6 +664,13 @@ void DepsgraphNodeBuilder::build_object(int base_index,
 		                   DEG_OPCODE_PLACEHOLDER,
 		                   "Dupli");
 	}
+	/* Syncronization back to original object. */
+	add_operation_node(&object->id,
+	                   DEG_NODE_TYPE_SYNCHRONIZE,
+	                   function_bind(BKE_object_synchronize_to_original,
+	                                 _1,
+	                                 object_cow),
+	                   DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
 }
 
 void DepsgraphNodeBuilder::build_object_flags(
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 649bc1a4275..23f1d229d6a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -683,6 +683,12 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
 	}
 	/* Point caches. */
 	build_object_pointcache(object);
+	/* Syncronization back to original object. */
+	OperationKey synchronize_key(&object->id,
+	                             DEG_NODE_TYPE_SYNCHRONIZE,
+	                             DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
+	add_relation(
+	        final_transform_key, synchronize_key, "Synchronize to Original");
 }
 
 void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object)
@@ -697,6 +703,12 @@ void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object)
 	                              DEG_NODE_TYPE_OBJECT_FROM_LAYER,
 	                              DEG_OPCODE_OBJECT_BASE_FLAGS);
 	add_relation(view_layer_done_key, object_flags_key, "Base flags flush");
+	/* Syncronization back to original object. */
+	OperationKey synchronize_key(&object->id,
+	                             DEG_NODE_TYPE_SYNCHRONIZE,
+	                             DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
+	add_relation(
+	        object_flags_key, synchronize_key, "Synchronize to Original");
 }
 
 void DepsgraphRelationBuilder::build_object_data(Object *object)
@@ -2023,6 +2035,13 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
 			}
 		}
 	}
+	/* Syncronization back to original object. */
+	ComponentKey final_geometry_jey(&object->id, DEG_NODE_TYPE_GEOMETRY);
+	OperationKey synchronize_key(&object->id,
+	                             DEG_NODE_TYPE_SYNCHRONIZE,
+	                             DEG_OPCODE_SYNCHRONIZE_TO_ORIGINAL);
+	add_relation(
+	        final_geometry_jey, synchronize_key, "Synchronize to Original");
 }
 
 void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index ec1ea1e02b2..55eaf314a0a 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -421,6 +421,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx,
 		case DEG_NODE_TYPE_OBJECT_FROM_LAYER:
 		case DEG_NODE_TYPE_BATCH_CACHE:
 		case DEG_NODE_TYPE_DUPLI:
+		case DEG_NODE_TYPE_SYNCHRONIZE:
 		{
 			ComponentDepsNode *comp_node = (ComponentDepsNode *)node;
 			if (!comp_node->operations.empty()) {
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index 3f36b9f7831..d93882a7170 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -104,6 +104,8 @@ const char *nodeTypeAsString(eDepsNode_Type type)
 		STRINGIFY_TYPE(BATCH_CACHE);
 		/* Duplication. */
 		STRINGIFY_TYPE(DUPLI);
+		/* Synchronization. */
+		STRINGIFY_TYPE(SYNCHRONIZE);
 
 		/* Total number of meaningful node types. */
 		case NUM_DEG_NODE_TYPES: return "SpecialCase";
@@ -180,6 +182,8 @@ const char *operationCodeAsString(eDepsOperation_Code opcode)
 		/* Movie clip. */
 		STRINGIFY_OPCODE(MOVIECLIP_EVAL);
 		STRINGIFY_OPCODE(MOVIECLIP_SELECT_UPDATE);
+		/* Synchronization. */
+		STRINGIFY_OPCODE(SYNCHRONIZE_TO_ORIGINAL);
 
 		case DEG_NUM_OPCODES: return "SpecialCase";
 #undef STRINGIFY_OPCODE
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index f8b519cb1aa..61a91c13913 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -157,11 +157,12 @@ typedef enum eDepsNode_Type {
 	DEG_NODE_TYPE_CACHE,
 	/* Batch Cache Component - TODO (dfelinto/sergey) rename to make it more generic. */
 	DEG_NODE_TYPE_BATCH_CACHE,
-
 	/* Duplication system. Used to force duplicated objects visible when
 	 * when duplicator is visible.
 	 */
 	DEG_NODE_TYPE_DUPLI,
+	/* Synchronization back to original datablock. */
+	DEG_NODE_TYPE_SYNCHRONIZE,
 
 	/* Total number of meaningful node types. */
 	NUM_DEG_NODE_TYPES,
@@ -170,7 +171,7 @@ const char *nodeTypeAsString(eDepsNode_Type type);
 
 /* Identifiers for common operations (as an enum). */
 typedef enum eDepsOperation_Code {
-	/* Generic Operations. ------------------------------ */
+	/* Generic Operations. -------------------------------------------------- */
 
 	/* Placeholder for operations which don't need special mention */
 	DEG_OPCODE_OPERATION = 0,
@@ -182,16 +183,16 @@ typedef enum eDepsOperation_Code {
 	// XXX: Placeholder while porting depsgraph code
 	DEG_OPCODE_PLACEHOLDER,
 
-	/* Animation, Drivers, etc. ------------------------ */
+	/* Animation, Drivers, etc. --------------------------------------------- */
 	/* NLA + Action */
 	DEG_OPCODE_ANIMATION,
 	/* Driver */
 	DEG_OPCODE_DRIVER,
 
-	/* Object related. --------------------------------- */
+	/* Object related. ------------------------------------------------------ */
 	DEG_OPCODE_OBJECT_BASE_FLAGS,
 
-	/* Transform. -------------------------------------- */
+	/* Transform. ----------------------------------------------------------- */
 	/* Transform entry point - local transforms only */
 	DEG_OPCODE_TRANSFORM_LOCAL,
 	/* Parenting */
@@ -203,25 +204,25 @@ typedef enum eDepsOperation_Code {
 	/* Handle object-level updates, mainly proxies hacks and recalc flags.  */
 	DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL,
 
-	/* Rigid body. -------------------------------------- */
+	/* Rigid body. ---------------------------------------------------------- */
 	/* Perform Simulation */
 	DEG_O

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list