Depsgraph: Fix crash with shape keys and lattices
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 7 Feb 2018 11:26:30 +0000 (12:26 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 7 Feb 2018 11:26:30 +0000 (12:26 +0100)
Only crash is fixed, still need to do something about missing recalc
or something like that.

source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/depsgraph_tag.cc
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

index 31c85a40f0ed16a7c2fe490cac68c474acec4a15..12560fa8aa123bd3072c129ef83890942557fc1c 100644 (file)
@@ -2105,6 +2105,22 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDDepsNode *id_node
                        if (op_node->inlinks.size() == 0) {
                                graph_->add_new_relation(op_cow, op_node, "CoW Dependency");
                        }
+                       else {
+                               bool has_same_id_dependency = false;
+                               foreach (DepsRelation *rel, op_node->inlinks) {
+                                       if (rel->from->type != DEG_NODE_TYPE_OPERATION) {
+                                               continue;
+                                       }
+                                       OperationDepsNode *op_node_from = (OperationDepsNode *)rel->from;
+                                       if (op_node_from->owner->owner == op_node->owner->owner) {
+                                               has_same_id_dependency = true;
+                                               break;
+                                       }
+                               }
+                               if (!has_same_id_dependency) {
+                                       graph_->add_new_relation(op_cow, op_node, "CoW Dependency");
+                               }
+                       }
                }
                GHASH_FOREACH_END();
                /* NOTE: We currently ignore implicit relations to an external
index f9d76fb6002776711fff933ec738c959af72c839..851b666a00a724016d2d4a16fa397a429e220b83 100644 (file)
@@ -92,6 +92,7 @@ void depsgraph_geometry_tag_to_component(const ID *id,
                                case OB_CURVE:
                                case OB_SURF:
                                case OB_FONT:
+                               case OB_LATTICE:
                                case OB_MBALL:
                                        *component_type = DEG_NODE_TYPE_GEOMETRY;
                                        break;
index a666820857494ded41d1221ecddad9133d62751b..290fb15443af0b2470d14e9495f9aaf3b1e3459d 100644 (file)
@@ -65,6 +65,7 @@ extern "C" {
 #ifdef NESTED_ID_NASTY_WORKAROUND
 #  include "DNA_key_types.h"
 #  include "DNA_lamp_types.h"
+#  include "DNA_lattice_types.h"
 #  include "DNA_linestyle_types.h"
 #  include "DNA_material_types.h"
 #  include "DNA_node_types.h"
@@ -93,6 +94,7 @@ namespace {
 union NestedIDHackTempStorage {
        FreestyleLineStyle linestyle;
        Lamp lamp;
+       Lattice lattice;
        Material material;
        Mesh mesh;
        Scene scene;
@@ -119,6 +121,7 @@ void nested_id_hack_discard_pointers(ID *id_cow)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
                SPECIAL_CASE(ID_ME, Mesh, key)
+               SPECIAL_CASE(ID_LT, Lattice, key)
 
 #  undef SPECIAL_CASE
 
@@ -151,6 +154,7 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
                SPECIAL_CASE(ID_WO, World, nodetree, world)
 
                SPECIAL_CASE(ID_ME, Mesh, key, mesh)
+               SPECIAL_CASE(ID_LT, Lattice, key, lattice)
 
 #  undef SPECIAL_CASE
 
@@ -183,6 +187,7 @@ void nested_id_hack_restore_pointers(const ID *old_id, ID *new_id)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
                SPECIAL_CASE(ID_ME, Mesh, key)
+               SPECIAL_CASE(ID_LT, Lattice, key)
 
 #undef SPECIAL_CASE
                default:
@@ -219,6 +224,7 @@ void ntree_hack_remap_pointers(const Depsgraph *depsgraph, ID *id_cow)
                SPECIAL_CASE(ID_WO, World, nodetree, bNodeTree)
 
                SPECIAL_CASE(ID_ME, Mesh, key, Key)
+               SPECIAL_CASE(ID_LT, Lattice, key, Key)
 
 #undef SPECIAL_CASE
                default: