Depsgraph: More fixes for shape keys
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 7 Feb 2018 13:15:24 +0000 (14:15 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 7 Feb 2018 13:15:24 +0000 (14:15 +0100)
Made shape keys to work for meshes. Also added missing code for curves.

Curves and lattices will not have shape keys visible, since modifiers support
is still to be done for them.

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

index 851b666a00a724016d2d4a16fa397a429e220b83..0dc1391d3a6c019021fc2741afd26945584b0bc7 100644 (file)
 #include "BLI_task.h"
 
 extern "C" {
 #include "BLI_task.h"
 
 extern "C" {
+#include "DNA_curve_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_windowmanager_types.h"
 
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_windowmanager_types.h"
 
-
 #include "BKE_idcode.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_idcode.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -295,11 +298,50 @@ void deg_graph_id_tag_legacy_compat(Main *bmain,
                                     ID *id,
                                     eDepsgraph_Tag tag)
 {
                                     ID *id,
                                     eDepsgraph_Tag tag)
 {
-       if (tag == DEG_TAG_GEOMETRY && GS(id->name) == ID_OB) {
-               Object *object = (Object *)id;
-               ID *data_id = (ID *)object->data;
-               if (data_id != NULL) {
-                       DEG_id_tag_update_ex(bmain, data_id, 0);
+       if (tag == DEG_TAG_GEOMETRY || tag == 0) {
+               switch (GS(id->name)) {
+                       case ID_OB:
+                       {
+                               Object *object = (Object *)id;
+                               ID *data_id = (ID *)object->data;
+                               if (data_id != NULL) {
+                                       DEG_id_tag_update_ex(bmain, data_id, 0);
+                               }
+                               break;
+                       }
+                       /* TODO(sergey): Shape keys are annoying, maybe we should find a
+                        * way to chain geometry evaluation to them, so we don't need extra
+                        * tagging here.
+                        */
+                       case ID_ME:
+                       {
+                               Mesh *mesh = (Mesh *)id;
+                               ID *key_id = &mesh->key->id;
+                               if (key_id != NULL) {
+                                       DEG_id_tag_update_ex(bmain, key_id, 0);
+                               }
+                               break;
+                       }
+                       case ID_LT:
+                       {
+                               Lattice *lattice = (Lattice *)id;
+                               ID *key_id = &lattice->key->id;
+                               if (key_id != NULL) {
+                                       DEG_id_tag_update_ex(bmain, key_id, 0);
+                               }
+                               break;
+                       }
+                       case ID_CU:
+                       {
+                               Curve *curve = (Curve *)id;
+                               ID *key_id = &curve->key->id;
+                               if (key_id != NULL) {
+                                       DEG_id_tag_update_ex(bmain, key_id, 0);
+                               }
+                               break;
+                       }
+                       default:
+                               break;
                }
        }
 }
                }
        }
 }
@@ -365,6 +407,7 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
                if (id_node != NULL) {
                        id_node->tag_update(graph);
                }
                if (id_node != NULL) {
                        id_node->tag_update(graph);
                }
+               deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0);
        }
        int current_flag = flag;
        while (current_flag != 0) {
        }
        int current_flag = flag;
        while (current_flag != 0) {
index 290fb15443af0b2470d14e9495f9aaf3b1e3459d..4ccf712e7d18a52261ac9742706c18b504838a02 100644 (file)
@@ -63,6 +63,7 @@ extern "C" {
 #include "DNA_object_types.h"
 
 #ifdef NESTED_ID_NASTY_WORKAROUND
 #include "DNA_object_types.h"
 
 #ifdef NESTED_ID_NASTY_WORKAROUND
+#  include "DNA_curve_types.h"
 #  include "DNA_key_types.h"
 #  include "DNA_lamp_types.h"
 #  include "DNA_lattice_types.h"
 #  include "DNA_key_types.h"
 #  include "DNA_lamp_types.h"
 #  include "DNA_lattice_types.h"
@@ -92,6 +93,7 @@ namespace {
 
 #ifdef NESTED_ID_NASTY_WORKAROUND
 union NestedIDHackTempStorage {
 
 #ifdef NESTED_ID_NASTY_WORKAROUND
 union NestedIDHackTempStorage {
+       Curve curve;
        FreestyleLineStyle linestyle;
        Lamp lamp;
        Lattice lattice;
        FreestyleLineStyle linestyle;
        Lamp lamp;
        Lattice lattice;
@@ -120,8 +122,9 @@ void nested_id_hack_discard_pointers(ID *id_cow)
                SPECIAL_CASE(ID_TE, Tex, nodetree)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
                SPECIAL_CASE(ID_TE, Tex, nodetree)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
-               SPECIAL_CASE(ID_ME, Mesh, key)
+               SPECIAL_CASE(ID_CU, Curve, key)
                SPECIAL_CASE(ID_LT, Lattice, key)
                SPECIAL_CASE(ID_LT, Lattice, key)
+               SPECIAL_CASE(ID_ME, Mesh, key)
 
 #  undef SPECIAL_CASE
 
 
 #  undef SPECIAL_CASE
 
@@ -153,8 +156,9 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
                SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
                SPECIAL_CASE(ID_WO, World, nodetree, world)
 
                SPECIAL_CASE(ID_TE, Tex, nodetree, tex)
                SPECIAL_CASE(ID_WO, World, nodetree, world)
 
-               SPECIAL_CASE(ID_ME, Mesh, key, mesh)
+               SPECIAL_CASE(ID_CU, Curve, key, curve)
                SPECIAL_CASE(ID_LT, Lattice, key, lattice)
                SPECIAL_CASE(ID_LT, Lattice, key, lattice)
+               SPECIAL_CASE(ID_ME, Mesh, key, mesh)
 
 #  undef SPECIAL_CASE
 
 
 #  undef SPECIAL_CASE
 
@@ -186,8 +190,9 @@ void nested_id_hack_restore_pointers(const ID *old_id, ID *new_id)
                SPECIAL_CASE(ID_TE, Tex, nodetree)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
                SPECIAL_CASE(ID_TE, Tex, nodetree)
                SPECIAL_CASE(ID_WO, World, nodetree)
 
-               SPECIAL_CASE(ID_ME, Mesh, key)
+               SPECIAL_CASE(ID_CU, Curve, key)
                SPECIAL_CASE(ID_LT, Lattice, key)
                SPECIAL_CASE(ID_LT, Lattice, key)
+               SPECIAL_CASE(ID_ME, Mesh, key)
 
 #undef SPECIAL_CASE
                default:
 
 #undef SPECIAL_CASE
                default:
@@ -223,8 +228,9 @@ void ntree_hack_remap_pointers(const Depsgraph *depsgraph, ID *id_cow)
                SPECIAL_CASE(ID_TE, Tex, nodetree, bNodeTree)
                SPECIAL_CASE(ID_WO, World, nodetree, bNodeTree)
 
                SPECIAL_CASE(ID_TE, Tex, nodetree, bNodeTree)
                SPECIAL_CASE(ID_WO, World, nodetree, bNodeTree)
 
-               SPECIAL_CASE(ID_ME, Mesh, key, Key)
+               SPECIAL_CASE(ID_CU, Curve, key, Key)
                SPECIAL_CASE(ID_LT, Lattice, key, Key)
                SPECIAL_CASE(ID_LT, Lattice, key, Key)
+               SPECIAL_CASE(ID_ME, Mesh, key, Key)
 
 #undef SPECIAL_CASE
                default:
 
 #undef SPECIAL_CASE
                default: