Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 8 Aug 2017 14:43:25 +0000 (16:43 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 8 Aug 2017 14:43:25 +0000 (16:43 +0200)
Conflicts:
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/editors/object/object_add.c
source/blender/python/intern/bpy_app_handlers.c

1  2 
intern/cycles/device/device.cpp
intern/cycles/device/device.h
intern/cycles/device/device_cuda.cpp
source/blender/blenkernel/intern/screen.c
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/object/object_add.c

Simple merge
Simple merge
Simple merge
@@@ -183,8 -180,8 +183,9 @@@ ARegion *BKE_area_region_copy(SpaceTyp
        BLI_listbase_clear(&newar->panels_category_active);
        BLI_listbase_clear(&newar->ui_lists);
        newar->swinid = 0;
 +      newar->manipulator_map = NULL;
        newar->regiontimer = NULL;
+       newar->headerstr = NULL;
        
        /* use optional regiondata callback */
        if (ar->regiondata) {
@@@ -929,23 -924,30 +929,27 @@@ void DepsgraphRelationBuilder::build_dr
                                fcu->rna_path ? fcu->rna_path : "",
                                fcu->array_index);
        bPoseChannel *pchan = NULL;
 -
        const char *rna_path = fcu->rna_path ? fcu->rna_path : "";
 +      const short id_type = GS(id->name);
  
-       /* create dependency between driver and data affected by it */
+       /* Create dependency between driver and data affected by it. */
        /* - direct property relationship... */
        //RNAPathKey affected_key(id, fcu->rna_path);
        //add_relation(driver_key, affected_key, "[Driver -> Data] DepsRel");
  
-       /* driver -> data components (for interleaved evaluation - bones/constraints/modifiers) */
-       // XXX: this probably should probably be moved out into a separate function
+       /* Driver -> data components (for interleaved evaluation
+        * bones/constraints/modifiers).
+        */
+       // XXX: this probably should probably be moved out into a separate function.
        if (strstr(rna_path, "pose.bones[") != NULL) {
                /* interleaved drivers during bone eval */
-               // TODO: ideally, if this is for a constraint, it goes to said constraint
+               /* TODO: ideally, if this is for a constraint, it goes to said
+                * constraint.
+                */
                Object *ob = (Object *)id;
 -              char *bone_name;
 -
 -              bone_name = BLI_str_quoted_substrN(rna_path, "pose.bones[");
 +              char *bone_name = BLI_str_quoted_substrN(rna_path, "pose.bones[");
                pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
 -
 -              if (bone_name) {
 +              if (bone_name != NULL) {
                        MEM_freeN(bone_name);
                        bone_name = NULL;
                }
                add_relation(driver_key, geometry_key, "[Driver -> ShapeKey Geom]");
        }
        else {
 -              if (GS(id->name) == ID_OB) {
 -                      /* assume that driver affects a transform... */
 -                      OperationKey local_transform_key(id,
 -                                                       DEG_NODE_TYPE_TRANSFORM,
 -                                                       DEG_OPCODE_TRANSFORM_LOCAL);
 -                      add_relation(driver_key,
 -                                   local_transform_key,
 -                                   "[Driver -> Transform]");
 -              }
 -              else if (GS(id->name) == ID_KE) {
 -                      ComponentKey geometry_key(id, DEG_NODE_TYPE_GEOMETRY);
 -                      add_relation(driver_key,
 -                                   geometry_key,
 -                                   "[Driver -> Shapekey Geometry]");
 +              switch (id_type) {
 +                      case ID_OB:
 +                      {
 +                              /* Assume that driver affects a transform. */
 +                              OperationKey local_transform_key(id,
 +                                                               DEG_NODE_TYPE_TRANSFORM,
 +                                                               DEG_OPCODE_TRANSFORM_LOCAL);
 +                              add_relation(driver_key,
 +                                           local_transform_key,
 +                                           "[Driver -> Transform]");
 +                              break;
 +                      }
 +                      case ID_KE:
 +                      {
 +                              ComponentKey geometry_key(id, DEG_NODE_TYPE_GEOMETRY);
 +                              add_relation(driver_key,
 +                                           geometry_key,
 +                                           "[Driver -> Shapekey Geometry]");
 +                              break;
 +                      }
 +                      case ID_NT:
 +                      {
 +                              OperationKey ntree_key(id,
 +                                                     DEG_NODE_TYPE_PARAMETERS,
 +                                                     DEG_OPCODE_PARAMETERS_EVAL);
 +                              add_relation(driver_key,
 +                                           ntree_key,
 +                                           "[Driver -> NTree Shading Update]");
 +                              break;
 +                      }
                }
        }
-       /* ensure that affected prop's update callbacks will be triggered once done */
-       // TODO: implement this once the functionality to add these links exists in RNA
-       // XXX: the data itself could also set this, if it were to be truly initialised later?
-       /* loop over variables to get the target relationships */
+       /* Ensure that affected prop's update callbacks will be triggered once
+        * done.
+        */
+       /* TODO: Implement this once the functionality to add these links exists
+        * RNA.
+        */
+       /* XXX: the data itself could also set this, if it were to be truly
+        * initialised later?
+        */
+       /* Loop over variables to get the target relationships. */
        LINKLIST_FOREACH (DriverVar *, dvar, &driver->variables) {
-               /* only used targets */
+               /* Only used targets. */
                DRIVER_TARGETS_USED_LOOPER(dvar)
                {
-                       if (dtar->id == NULL)
+                       if (dtar->id == NULL) {
                                continue;
-                       /* special handling for directly-named bones */
+                       }
+                       /* Special handling for directly-named bones. */
                        if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) {
                                Object *ob = (Object *)dtar->id;
-                               bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
+                               bPoseChannel *target_pchan =
+                                       BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
                                if (target_pchan != NULL) {
-                                       /* get node associated with bone */
+                                       /* Get node associated with bone. */
                                        // XXX: watch the space!
                                        /* Some cases can't use final bone transform, for example:
                                         * - Driving the bone with itself (addressed here)
@@@ -1426,26 -1344,23 +1426,24 @@@ static void make_object_duplilist_real(
                                         const bool use_hierarchy)
  {
        Main *bmain = CTX_data_main(C);
-       ListBase *lb;
 +      SceneLayer *sl = CTX_data_scene_layer(C);
+       ListBase *lb_duplis;
        DupliObject *dob;
-       GHash *dupli_gh = NULL, *parent_gh = NULL;
-       Object *object;
+       GHash *dupli_gh, *parent_gh = NULL;
  
-       if (!(base->object->transflag & OB_DUPLI))
+       if (!(base->object->transflag & OB_DUPLI)) {
                return;
+       }
  
-       lb = object_duplilist(bmain->eval_ctx, scene, base->object);
+       lb_duplis = object_duplilist(bmain->eval_ctx, scene, base->object);
  
-       if (use_hierarchy || use_base_parent) {
-               dupli_gh = BLI_ghash_ptr_new(__func__);
-               if (use_hierarchy) {
-                       if (base->object->transflag & OB_DUPLIGROUP) {
-                               parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__);
-                       }
-                       else {
-                               parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
-                       }
+       dupli_gh = BLI_ghash_ptr_new(__func__);
+       if (use_hierarchy) {
+               if (base->object->transflag & OB_DUPLIGROUP) {
+                       parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__);
+               }
+               else {
+                       parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
                }
        }
  
                /* font duplis can have a totcol without material, we get them from parent
                 * should be implemented better...
                 */
-               if (ob->mat == NULL) ob->totcol = 0;
+               if (ob_dst->mat == NULL) {
+                       ob_dst->totcol = 0;
+               }
  
-               BKE_collection_object_add_from(scene, dob->ob, ob);
-               basen = BKE_scene_layer_base_find(sl, ob);
 -              base_dst = MEM_dupallocN(base);
 -              base_dst->flag &= ~(OB_FROMDUPLI | OB_FROMGROUP);
 -              ob_dst->flag = base_dst->flag;
 -              base_dst->lay = base->lay;
 -              BLI_addhead(&scene->base, base_dst);   /* addhead: othwise eternal loop */
 -              base_dst->object = ob_dst;
++              BKE_collection_object_add_from(scene, ob_src, ob_dst);
++              base_dst = BKE_scene_layer_base_find(sl, ob_dst);
 +
-               BKE_scene_object_base_flag_sync_from_base(basen);
++              BKE_scene_object_base_flag_sync_from_base(base_dst);
  
                /* make sure apply works */
-               BKE_animdata_free(&ob->id, true);
-               ob->adt = NULL;
+               BKE_animdata_free(&ob_dst->id, true);
+               ob_dst->adt = NULL;
  
                /* Proxies are not to be copied. */
-               ob->proxy_from = NULL;
-               ob->proxy_group = NULL;
-               ob->proxy = NULL;
+               ob_dst->proxy_from = NULL;
+               ob_dst->proxy_group = NULL;
+               ob_dst->proxy = NULL;
  
-               ob->parent = NULL;
-               BKE_constraints_free(&ob->constraints);
-               ob->curve_cache = NULL;
-               ob->transflag &= ~OB_DUPLI;
+               ob_dst->parent = NULL;
+               BKE_constraints_free(&ob_dst->constraints);
+               ob_dst->curve_cache = NULL;
+               ob_dst->transflag &= ~OB_DUPLI;
 -              ob_dst->lay = base->lay;
  
-               copy_m4_m4(ob->obmat, dob->mat);
-               BKE_object_apply_mat4(ob, ob->obmat, false, false);
+               copy_m4_m4(ob_dst->obmat, dob->mat);
+               BKE_object_apply_mat4(ob_dst, ob_dst->obmat, false, false);
  
-               if (dupli_gh) {
-                       BLI_ghash_insert(dupli_gh, dob, ob);
-               }
+               BLI_ghash_insert(dupli_gh, dob, ob_dst);
                if (parent_gh) {
                        void **val;
                        /* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as 'the same',
                         * this avoids trying to insert same key several time and raise asserts in debug builds... */
                        if (!BLI_ghash_ensure_p(parent_gh, dob, &val)) {
-                               *val = ob;
+                               *val = ob_dst;
                        }
                }
+       }
+       for (dob = lb_duplis->first; dob; dob = dob->next) {
+               Object *ob_src = dob->ob;
+               Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
  
                /* Remap new object to itself, and clear again newid pointer of orig object. */
-               BKE_libblock_relink_to_newid(&ob->id);
-               set_sca_new_poins_ob(ob);
-               BKE_id_clear_newpoin(&dob->ob->id);
+               BKE_libblock_relink_to_newid(&ob_dst->id);
+               set_sca_new_poins_ob(ob_dst);
  
-               DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
-       }
 -              DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
++              DEG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
  
-       if (use_hierarchy) {
-               for (dob = lb->first; dob; dob = dob->next) {
+               if (use_hierarchy) {
                        /* original parents */
-                       Object *ob_src =     dob->ob;
                        Object *ob_src_par = ob_src->parent;
-                       Object *ob_dst =     BLI_ghash_lookup(dupli_gh, dob);
                        Object *ob_dst_par = NULL;
  
                        /* find parent that was also made real */
                                ob_dst->parent = base->object;
                                ob_dst->partype = PAROBJECT;
                        }
-                       if (ob_dst->parent) {
-                               /* note, this may be the parent of other objects, but it should
-                                * still work out ok */
-                               BKE_object_apply_mat4(ob_dst, dob->mat, false, true);
-                               /* to set ob_dst->orig and in case theres any other discrepicies */
-                               DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
-                       }
                }
-       }
-       else if (use_base_parent) {
-               /* since we are ignoring the internal hierarchy - parent all to the
-                * base object */
-               for (dob = lb->first; dob; dob = dob->next) {
-                       /* original parents */
-                       Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob);
+               else if (use_base_parent) {
+                       /* since we are ignoring the internal hierarchy - parent all to the
+                        * base object */
                        ob_dst->parent = base->object;
                        ob_dst->partype = PAROBJECT;
+               }
  
-                       /* similer to the code above, see comments */
+               if (ob_dst->parent) {
+                       /* note, this may be the parent of other objects, but it should
+                        * still work out ok */
                        BKE_object_apply_mat4(ob_dst, dob->mat, false, true);
 -                      DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
+                       /* to set ob_dst->orig and in case theres any other discrepicies */
 +                      DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
                }
        }
  
        if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) {
-               for (object = bmain->object.first; object; object = object->id.next) {
-                       if (object->proxy_group == base->object) {
-                               object->proxy = NULL;
-                               object->proxy_from = NULL;
-                               DEG_id_tag_update(&object->id, OB_RECALC_OB);
+               for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+                       if (ob->proxy_group == base->object) {
+                               ob->proxy = NULL;
+                               ob->proxy_from = NULL;
 -                              DAG_id_tag_update(&ob->id, OB_RECALC_OB);
++                              DEG_id_tag_update(&ob->id, OB_RECALC_OB);
                        }
                }
        }