Fix T62768: Softbody cache still not updated correctly
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 21 Mar 2019 13:38:35 +0000 (14:38 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 21 Mar 2019 13:41:41 +0000 (14:41 +0100)
There was missing flush from transform update to the point cache
reset. Caused by the fact that when update happens in the "middle"
of component all the component operations will be tagged for update
(since the intermediate state is not stored), but that will not
flush updates to other operations since that would cause too much
of updates.

This now we tag point cache for reset after evaluation operation
but before final transform and before rigid body world.

source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc

index 39806d22071d25337d6d915bb27178624290aed3..f0d0656f254fe4921f599db387ea2bb63f07f147 100644 (file)
@@ -778,6 +778,11 @@ void DepsgraphNodeBuilder::build_object_transform(Object *object)
                           function_bind(BKE_object_eval_uber_transform,
                                         _1,
                                         ob_cow));
+       /* Operation to take of rigid body simulation. soft bodies and other firends
+        * in the context of point cache invalidation. */
+       add_operation_node(&object->id,
+                          NodeType::TRANSFORM,
+                          OperationCode::TRANSFORM_SIMULATION_INIT);
        /* Object transform is done. */
        op_node = add_operation_node(&object->id, NodeType::TRANSFORM,
                                     OperationCode::TRANSFORM_FINAL,
@@ -1072,9 +1077,6 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
                        if (object->type != OB_MESH) {
                                continue;
                        }
-                       add_operation_node(&object->id,
-                                          NodeType::TRANSFORM,
-                                          OperationCode::TRANSFORM_SIMULATION_INIT);
                        /* Create operation for flushing results. */
                        /* Object's transform component - where the rigidbody operation
                         * lives. */
index 38f54c70874461881394a0f3af29cfeebaef60d4..49f1f93ed6cdc5e629827854c7ca81582d10e4b8 100644 (file)
@@ -636,6 +636,10 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
                BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
        }
        /* Object constraints. */
+       OperationKey object_transform_simulation_init_key(
+               &object->id,
+               NodeType::TRANSFORM,
+               OperationCode::TRANSFORM_SIMULATION_INIT);
        if (object->constraints.first != NULL) {
                OperationKey constraint_key(&object->id,
                                            NodeType::TRANSFORM,
@@ -649,12 +653,22 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
                /* operation order */
                add_relation(base_op_key, constraint_key, "ObBase-> Constraint Stack");
                add_relation(constraint_key, final_transform_key, "ObConstraints -> Done");
-               add_relation(constraint_key, ob_eval_key, "Eval");
-               add_relation(ob_eval_key, final_transform_key, "Eval");
+               add_relation(constraint_key, ob_eval_key, "Constraint -> Transform Eval");
+               add_relation(ob_eval_key,
+                            object_transform_simulation_init_key,
+                            "Transform Eval -> Simulation Init");
+               add_relation(object_transform_simulation_init_key,
+                            final_transform_key,
+                            "Simulation -> Final Transform");
        }
        else {
                add_relation(base_op_key, ob_eval_key, "Eval");
-               add_relation(ob_eval_key, final_transform_key, "Eval");
+               add_relation(ob_eval_key,
+                            object_transform_simulation_init_key,
+                            "Transform Eval -> Simulation Init");
+               add_relation(object_transform_simulation_init_key,
+                            final_transform_key,
+                            "Simulation -> Final Transform");
        }
        /* Animation data */
        build_animdata(&object->id);
@@ -959,15 +973,16 @@ void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
        }
        /* Manual edits to any dependency (or self) should reset the point cache. */
        if (!BLI_listbase_is_empty(&ptcache_id_list)) {
-               OperationKey transform_init_key(&object->id,
-                                               NodeType::TRANSFORM,
-                                               OperationCode::TRANSFORM_INIT);
+               OperationKey transform_simulation_init_key(
+                       &object->id,
+                       NodeType::TRANSFORM,
+                       OperationCode::TRANSFORM_SIMULATION_INIT);
                OperationKey geometry_init_key(&object->id,
                                               NodeType::GEOMETRY,
                                               OperationCode::GEOMETRY_EVAL_INIT);
-               add_relation(transform_init_key,
+               add_relation(transform_simulation_init_key,
                             point_cache_key,
-                            "Transform Local -> Point Cache",
+                            "Transform Simulation -> Point Cache",
                             RELATION_FLAG_FLUSH_USER_EDIT_ONLY);
                add_relation(geometry_init_key,
                             point_cache_key,
@@ -1740,10 +1755,6 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
                                &object->id,
                                NodeType::TRANSFORM,
                                OperationCode::TRANSFORM_EVAL);
-
-                       add_relation(object_transform_eval_key,
-                                    object_transform_simulation_init_key,
-                                    "Object Transform -> Simulation Init");
                        add_relation(object_transform_simulation_init_key,
                                     rb_simulate_key,
                                     "Object Transform -> Rigidbody Sim Eval");