Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 29 Nov 2017 15:32:50 +0000 (16:32 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 29 Nov 2017 15:32:50 +0000 (16:32 +0100)
1  2 
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/object_update.c
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc

index e446451d9999b0e3a630748d4eb62b5c1cead0aa,4d232e9ed6ca2d8d1c10938b25117d0ff391a168..2b183906f5787de4ccbb78fdfb16d0b5cc231dbf
@@@ -183,21 -178,21 +183,21 @@@ void BKE_object_tfm_protected_restore(s
                                        const short protectflag);
  
  /* Dependency graph evaluation callbacks. */
 -void BKE_object_eval_local_transform(struct EvaluationContext *eval_ctx,
 +void BKE_object_eval_local_transform(const struct EvaluationContext *eval_ctx,
-                                      struct Scene *scene,
                                       struct Object *ob);
 -void BKE_object_eval_parent(struct EvaluationContext *eval_ctx,
 +void BKE_object_eval_parent(const struct EvaluationContext *eval_ctx,
                              struct Scene *scene,
                              struct Object *ob);
 -void BKE_object_eval_constraints(struct EvaluationContext *eval_ctx,
 +void BKE_object_eval_constraints(const struct EvaluationContext *eval_ctx,
                                   struct Scene *scene,
                                   struct Object *ob);
 -void BKE_object_eval_done(struct EvaluationContext *eval_ctx, struct Object *ob);
 +void BKE_object_eval_done(const struct EvaluationContext *eval_ctx, struct Object *ob);
  
 -bool BKE_object_eval_proxy_copy(struct EvaluationContext *eval_ctx,
++bool BKE_object_eval_proxy_copy(const struct EvaluationContext *eval_ct,
+                                 struct Object *object);
 -void BKE_object_eval_uber_transform(struct EvaluationContext *eval_ctx,
 +void BKE_object_eval_uber_transform(const struct EvaluationContext *eval_ctx,
-                                     struct Scene *scene,
                                      struct Object *ob);
 -void BKE_object_eval_uber_data(struct EvaluationContext *eval_ctx,
 +void BKE_object_eval_uber_data(const struct EvaluationContext *eval_ctx,
                                 struct Scene *scene,
                                 struct Object *ob);
  
@@@ -205,7 -200,8 +205,7 @@@ void BKE_object_eval_cloth(const struc
                             struct Scene *scene,
                             struct Object *object);
  
 -
--void BKE_object_eval_transform_all(struct EvaluationContext *eval_ctx,
++void BKE_object_eval_transform_all(const struct EvaluationContext *eval_ctx,
                                     struct Scene *scene,
                                     struct Object *object);
  
index 3795e1bbf0e84ca74e721f0ceb6c5d50386c1f81,c6b4e3fb0c752c2f80957b13a9d801758df6e598..f58a0d76b6ab7532151ede3f43760f173d44c17f
@@@ -2664,6 -2586,28 +2664,28 @@@ bool BKE_object_parent_loop_check(cons
        return BKE_object_parent_loop_check(par->parent, ob);
  }
  
 -static void object_handle_update_proxy(EvaluationContext *eval_ctx,
++static void object_handle_update_proxy(const EvaluationContext *eval_ctx,
+                                        Scene *scene,
+                                        Object *object,
+                                        const bool do_proxy_update)
+ {
+       /* The case when this is a group proxy, object_update is called in group.c */
+       if (object->proxy == NULL) {
+               return;
+       }
+       /* set pointer in library proxy target, for copying, but restore it */
+       object->proxy->proxy_from = object;
+       // printf("set proxy pointer for later group stuff %s\n", ob->id.name);
+       /* the no-group proxy case, we call update */
+       if (object->proxy_group == NULL) {
+               if (do_proxy_update) {
+                       // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
+                       BKE_object_handle_update(eval_ctx, scene, object->proxy);
+               }
+       }
+ }
  /* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
  /*           local_object->proxy      == pointer to library object, saved in files and read */
  
@@@ -2677,75 -2621,49 +2699,49 @@@ void BKE_object_handle_update_ex(const 
                                   RigidBodyWorld *rbw,
                                   const bool do_proxy_update)
  {
-       if (ob->recalc & OB_RECALC_ALL) {
-               /* speed optimization for animation lookups */
-               if (ob->pose) {
-                       BKE_pose_channels_hash_make(ob->pose);
-                       if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
-                               BKE_pose_update_constraint_flags(ob->pose);
-                       }
+       if ((ob->recalc & OB_RECALC_ALL) == 0) {
+               object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update);
+               return;
+       }
+       /* Speed optimization for animation lookups. */
+       if (ob->pose != NULL) {
+               BKE_pose_channels_hash_make(ob->pose);
+               if (ob->pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
+                       BKE_pose_update_constraint_flags(ob->pose);
                }
-               if (ob->recalc & OB_RECALC_DATA) {
-                       if (ob->type == OB_ARMATURE) {
-                               /* this happens for reading old files and to match library armatures
-                                * with poses we do it ahead of BKE_object_where_is_calc to ensure animation
-                                * is evaluated on the rebuilt pose, otherwise we get incorrect poses
-                                * on file load */
-                               if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC))
-                                       BKE_pose_rebuild(ob, ob->data);
-                       }
+       }
+       if (ob->recalc & OB_RECALC_DATA) {
+               if (ob->type == OB_ARMATURE) {
+                       /* this happens for reading old files and to match library armatures
+                        * with poses we do it ahead of BKE_object_where_is_calc to ensure animation
+                        * is evaluated on the rebuilt pose, otherwise we get incorrect poses
+                        * on file load */
+                       if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC))
+                               BKE_pose_rebuild(ob, ob->data);
                }
-               /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, 
-                * which is only in BKE_object_where_is_calc now */
-               /* XXX: should this case be OB_RECALC_OB instead? */
-               if (ob->recalc & OB_RECALC_ALL) {
-                       
-                       if (G.debug & G_DEBUG_DEPSGRAPH)
-                               printf("recalcob %s\n", ob->id.name + 2);
-                       
-                       /* handle proxy copy for target */
-                       if (ID_IS_LINKED(ob) && ob->proxy_from) {
-                               // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
-                               if (ob->proxy_from->proxy_group) { /* transform proxy into group space */
-                                       Object *obg = ob->proxy_from->proxy_group;
-                                       float imat[4][4];
-                                       invert_m4_m4(imat, obg->obmat);
-                                       mul_m4_m4m4(ob->obmat, imat, ob->proxy_from->obmat);
-                                       if (obg->dup_group) { /* should always be true */
-                                               add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
-                                       }
-                               }
-                               else
-                                       copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
-                       }
-                       else
-                               BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL);
+       }
+       /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers,
+        * which is only in BKE_object_where_is_calc now */
+       /* XXX: should this case be OB_RECALC_OB instead? */
+       if (ob->recalc & OB_RECALC_ALL) {
+               if (G.debug & G_DEBUG_DEPSGRAPH) {
+                       printf("recalcob %s\n", ob->id.name + 2);
                }
-               
-               if (ob->recalc & OB_RECALC_DATA) {
-                       BKE_object_handle_data_update(eval_ctx, scene, ob);
+               /* Handle proxy copy for target. */
+               if (!BKE_object_eval_proxy_copy(eval_ctx, ob)) {
 -                      BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
++                      BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL);
                }
+       }
  
-               ob->recalc &= ~OB_RECALC_ALL;
+       if (ob->recalc & OB_RECALC_DATA) {
+               BKE_object_handle_data_update(eval_ctx, scene, ob);
        }
  
-       /* the case when this is a group proxy, object_update is called in group.c */
-       if (ob->proxy) {
-               /* set pointer in library proxy target, for copying, but restore it */
-               ob->proxy->proxy_from = ob;
-               // printf("set proxy pointer for later group stuff %s\n", ob->id.name);
+       ob->recalc &= ~OB_RECALC_ALL;
  
-               /* the no-group proxy case, we call update */
-               if (ob->proxy_group == NULL) {
-                       if (do_proxy_update) {
-                               // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
-                               BKE_object_handle_update(eval_ctx, scene, ob->proxy);
-                       }
-               }
-       }
+       object_handle_update_proxy(eval_ctx, scene, ob, do_proxy_update);
  }
  /* WARNING: "scene" here may not be the scene object actually resides in. 
   * When dealing with background-sets, "scene" is actually the active scene.
   * e.g. "scene" <-- set 1 <-- set 2 ("ob" lives here) <-- set 3 <-- ... <-- set n
index 4d2cf0c5dc61cbb2603944afb858fdbb59cb5362,84d2f624577d1a7e6def27125a468fcae37d4ba5..f5f521e119dd7667cd83c38d36e6e23198c4b73a
  #include "BKE_pointcache.h"
  #include "BKE_scene.h"
  #include "BKE_material.h"
 +#include "BKE_mball.h"
 +#include "BKE_mesh.h"
  #include "BKE_image.h"
  
 +#include "MEM_guardedalloc.h"
  #include "DEG_depsgraph.h"
  
 -#ifdef WITH_LEGACY_DEPSGRAPH
 -#  define DEBUG_PRINT if (!DEG_depsgraph_use_legacy() && G.debug & G_DEBUG_DEPSGRAPH) printf
 -#else
 -#  define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
 -#endif
 -
 -static ThreadMutex material_lock = BLI_MUTEX_INITIALIZER;
 +#define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
  
 -void BKE_object_eval_local_transform(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_object_eval_local_transform(const EvaluationContext *UNUSED(eval_ctx),
-                                      Scene *UNUSED(scene),
                                       Object *ob)
  {
 -      DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
 +      DEBUG_PRINT("%s on %s (%p)\n", __func__, ob->id.name, ob);
  
        /* calculate local matrix */
        BKE_object_to_mat4(ob, ob->obmat);
@@@ -273,33 -295,36 +272,36 @@@ void BKE_object_handle_data_update
        /* quick cache removed */
  }
  
- void BKE_object_eval_uber_transform(const EvaluationContext *UNUSED(eval_ctx),
-                                     Scene *UNUSED(scene),
-                                     Object *ob)
 -bool BKE_object_eval_proxy_copy(EvaluationContext *UNUSED(eval_ctx),
++bool BKE_object_eval_proxy_copy(const EvaluationContext *UNUSED(eval_ctx),
+                                 Object *object)
  {
-       /* TODO(sergey): Currently it's a duplicate of logic in BKE_object_handle_update_ex(). */
-       // XXX: it's almost redundant now...
        /* Handle proxy copy for target, */
-       if (ID_IS_LINKED(ob) && ob->proxy_from) {
-               if (ob->proxy_from->proxy_group) {
+       if (ID_IS_LINKED(object) && object->proxy_from) {
+               if (object->proxy_from->proxy_group) {
                        /* Transform proxy into group space. */
-                       Object *obg = ob->proxy_from->proxy_group;
+                       Object *obg = object->proxy_from->proxy_group;
                        float imat[4][4];
                        invert_m4_m4(imat, obg->obmat);
-                       mul_m4_m4m4(ob->obmat, imat, ob->proxy_from->obmat);
+                       mul_m4_m4m4(object->obmat, imat, object->proxy_from->obmat);
                        /* Should always be true. */
                        if (obg->dup_group) {
-                               add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs);
+                               add_v3_v3(object->obmat[3], obg->dup_group->dupli_ofs);
                        }
                }
-               else
-                       copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
+               else {
+                       copy_m4_m4(object->obmat, object->proxy_from->obmat);
+               }
+               return true;
        }
+       return false;
+ }
  
-       ob->recalc &= ~(OB_RECALC_OB | OB_RECALC_TIME);
-       if (ob->data == NULL) {
-               ob->recalc &= ~OB_RECALC_DATA;
 -void BKE_object_eval_uber_transform(EvaluationContext *eval_ctx, Object *object)
++void BKE_object_eval_uber_transform(const EvaluationContext *eval_ctx, Object *object)
+ {
+       BKE_object_eval_proxy_copy(eval_ctx, object);
+       object->recalc &= ~(OB_RECALC_OB | OB_RECALC_TIME);
+       if (object->data == NULL) {
+               object->recalc &= ~OB_RECALC_DATA;
        }
  }
  
@@@ -391,7 -347,7 +393,7 @@@ void BKE_object_eval_cloth(const Evalua
        BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH);
  }
  
--void BKE_object_eval_transform_all(EvaluationContext *eval_ctx,
++void BKE_object_eval_transform_all(const EvaluationContext *eval_ctx,
                                     Scene *scene,
                                     Object *object)
  {
        if (!BLI_listbase_is_empty(&object->constraints)) {
                BKE_object_eval_constraints(eval_ctx, scene, object);
        }
-       BKE_object_eval_uber_transform(eval_ctx, scene, object);
+       BKE_object_eval_uber_transform(eval_ctx, object);
        BKE_object_eval_done(eval_ctx, object);
  }
 +
 +void BKE_object_eval_update_shading(const EvaluationContext *UNUSED(eval_ctx),
 +                                    Object *object)
 +{
 +      DEBUG_PRINT("%s on %s (%p)\n", __func__, object->id.name, object);
 +      if (object->type == OB_MESH) {
 +              BKE_mesh_batch_cache_dirty(object->data, BKE_MESH_BATCH_DIRTY_SHADING);
 +      }
 +}
 +
 +void BKE_object_data_select_update(const EvaluationContext *UNUSED(eval_ctx),
 +                                   struct ID *object_data)
 +{
 +      DEBUG_PRINT("%s on %s (%p)\n", __func__, object_data->name, object_data);
 +      switch (GS(object_data->name)) {
 +              case ID_ME:
 +                      BKE_mesh_batch_cache_dirty((Mesh *)object_data,
 +                                                 BKE_CURVE_BATCH_DIRTY_SELECT);
 +                      break;
 +              case ID_CU:
 +                      BKE_curve_batch_cache_dirty((Curve *)object_data,
 +                                                  BKE_CURVE_BATCH_DIRTY_SELECT);
 +                      break;
 +              case ID_LT:
 +                      BKE_lattice_batch_cache_dirty((struct Lattice *)object_data,
 +                                                    BKE_CURVE_BATCH_DIRTY_SELECT);
 +                      break;
 +              default:
 +                      break;
 +      }
 +}
 +
 +void BKE_object_eval_flush_base_flags(const EvaluationContext *UNUSED(eval_ctx),
 +                                      Object *object, Base *base, bool is_from_set)
 +{
 +      DEBUG_PRINT("%s on %s (%p)\n", __func__, object->id.name, object);
 +      /* Make sure we have the base collection settings is already populated.
 +       * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
 +       * Which usually means a missing call to DEG_id_tag_update(). */
 +      BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
 +      /* Copy flags and settings from base. */
 +      object->base_flag = base->flag;
 +      if (is_from_set) {
 +              object->base_flag |= BASE_FROM_SET;
 +              object->base_flag &= ~(BASE_SELECTED | BASE_SELECTABLED);
 +      }
 +      object->base_collection_properties = base->collection_properties;
 +}
index a2a0f633fd9596b0744ac9dbad840318aa752e08,7e437d97b5746d770dca11b492f90c1366431291..121db9a4c5f9deccaff3d670e83357b95dab8e36
@@@ -581,10 -437,7 +581,9 @@@ void DepsgraphNodeBuilder::build_object
  
        /* local transforms (from transform channels - loc/rot/scale + deltas) */
        op_node = add_operation_node(&object->id, DEG_NODE_TYPE_TRANSFORM,
 -                                   function_bind(BKE_object_eval_local_transform, _1, object),
 +                                   function_bind(BKE_object_eval_local_transform,
 +                                                 _1,
-                                                  scene_cow,
 +                                                 ob_cow),
                                     DEG_OPCODE_TRANSFORM_LOCAL);
        op_node->set_as_entry();
  
                build_object_constraints(object);
        }
  
 -      /* Temporary uber-update node, which does everything.
 -       * It is for the being we're porting old dependencies into the new system.
 -       * We'll get rid of this node as soon as all the granular update functions
 -       * are filled in.
 -       *
 -       * TODO(sergey): Get rid of this node.
 -       */
 +      /* Rest of transformation update. */
        add_operation_node(&object->id, DEG_NODE_TYPE_TRANSFORM,
 -                         function_bind(BKE_object_eval_uber_transform, _1, object),
 +                         function_bind(BKE_object_eval_uber_transform,
 +                                       _1,
-                                        scene_cow,
 +                                       ob_cow),
                           DEG_OPCODE_TRANSFORM_OBJECT_UBEREVAL);
  
        /* object transform is done */