Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 8 Aug 2017 17:16:25 +0000 (19:16 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 8 Aug 2017 17:16:25 +0000 (19:16 +0200)
Conflicts:
source/blender/modifiers/intern/MOD_meshsequencecache.c

1  2 
source/blender/editors/interface/interface_layout.c
source/blender/modifiers/intern/MOD_meshsequencecache.c

index f2bdbe3865bdac100aa4e39203be90c4fbafc9b1,804ffec7997f05fe3ad91cc2016daa2e936b965c..d2ab88c9c070bb734519d53bfadef600c5a0f44f
@@@ -1578,6 -1578,95 +1578,6 @@@ void uiItemsEnumR(uiLayout *layout, str
  
  /* Pointer RNA button with search */
  
 -typedef struct CollItemSearch {
 -      struct CollItemSearch *next, *prev;
 -      char *name;
 -      int index;
 -      int iconid;
 -} CollItemSearch;
 -
 -static int sort_search_items_list(const void *a, const void *b)
 -{
 -      const CollItemSearch *cis1 = a;
 -      const CollItemSearch *cis2 = b;
 -      
 -      if (BLI_strcasecmp(cis1->name, cis2->name) > 0)
 -              return 1;
 -      else
 -              return 0;
 -}
 -
 -static void rna_search_cb(const struct bContext *C, void *arg_but, const char *str, uiSearchItems *items)
 -{
 -      uiBut *but = arg_but;
 -      char *name;
 -      int i = 0, iconid = 0, flag = RNA_property_flag(but->rnaprop);
 -      ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list");
 -      CollItemSearch *cis;
 -      const bool skip_filter = !but->changed;
 -
 -      /* build a temporary list of relevant items first */
 -      RNA_PROP_BEGIN (&but->rnasearchpoin, itemptr, but->rnasearchprop)
 -      {
 -              if (flag & PROP_ID_SELF_CHECK)
 -                      if (itemptr.data == but->rnapoin.id.data)
 -                              continue;
 -
 -              /* use filter */
 -              if (RNA_property_type(but->rnaprop) == PROP_POINTER) {
 -                      if (RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr) == 0)
 -                              continue;
 -              }
 -
 -              if (itemptr.type && RNA_struct_is_ID(itemptr.type)) {
 -                      ID *id = itemptr.data;
 -                      char name_ui[MAX_ID_NAME];
 -
 -#if 0       /* this name is used for a string comparison and can't be modified, TODO */
 -                      /* if ever enabled, make name_ui be MAX_ID_NAME+1 */
 -                      BKE_id_ui_prefix(name_ui, id);
 -#else
 -                      BLI_strncpy(name_ui, id->name + 2, sizeof(name_ui));
 -#endif
 -                      name = BLI_strdup(name_ui);
 -                      iconid = ui_id_icon_get(C, id, false);
 -              }
 -              else {
 -                      name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
 -                      iconid = 0;
 -              }
 -
 -              if (name) {
 -                      if (skip_filter || BLI_strcasestr(name, str)) {
 -                              cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
 -                              cis->name = MEM_dupallocN(name);
 -                              cis->index = i;
 -                              cis->iconid = iconid;
 -                              BLI_addtail(items_list, cis);
 -                      }
 -                      MEM_freeN(name);
 -              }
 -
 -              i++;
 -      }
 -      RNA_PROP_END;
 -      
 -      BLI_listbase_sort(items_list, sort_search_items_list);
 -      
 -      /* add search items from temporary list */
 -      for (cis = items_list->first; cis; cis = cis->next) {
 -              if (false == UI_search_item_add(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) {
 -                      break;
 -              }
 -      }
 -
 -      for (cis = items_list->first; cis; cis = cis->next) {
 -              MEM_freeN(cis->name);
 -      }
 -      BLI_freelistN(items_list);
 -      MEM_freeN(items_list);
 -}
 -
  static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop)
  {
        StructRNA *srna;
@@@ -1618,8 -1707,6 +1618,8 @@@ void ui_but_add_search(uiBut *but, Poin
  
        /* turn button into search button */
        if (searchprop) {
 +              uiRNACollectionSearch *coll_search = MEM_mallocN(sizeof(*coll_search), __func__);
 +
                but->type = UI_BTYPE_SEARCH_MENU;
                but->hardmax = MAX2(but->hardmax, 256.0f);
                but->rnasearchpoin = *searchptr;
                        but->flag |= UI_BUT_VALUE_CLEAR;
                }
  
 +              coll_search->target_ptr = *ptr;
 +              coll_search->target_prop = prop;
 +              coll_search->search_ptr = *searchptr;
 +              coll_search->search_prop = searchprop;
 +              coll_search->but_changed = &but->changed;
 +
                if (RNA_property_type(prop) == PROP_ENUM) {
                        /* XXX, this will have a menu string,
                         * but in this case we just want the text */
                        but->str[0] = 0;
                }
  
 -              UI_but_func_search_set(but, ui_searchbox_create_generic, rna_search_cb, but, NULL, NULL);
 +              UI_but_func_search_set(
 +                          but, ui_searchbox_create_generic, ui_rna_collection_search_cb,
 +                          coll_search, NULL, NULL);
 +              but->free_search_arg = true;
        }
  }
  
@@@ -2387,7 -2465,6 +2387,6 @@@ static void ui_litem_estimate_box(uiLay
        uiStyle *style = litem->root->style;
  
        ui_litem_estimate_column(litem, true);
-       litem->item.flag &= ~UI_ITEM_MIN;
        litem->w += 2 * style->boxspace;
        litem->h += 2 * style->boxspace;
  }
index 5d623295edf843e1b3417dcd8be666294494f369,411779c508cd41ca66efc8d676ddc296bf4dd7d9..5c2f1aba8e16e9fcdeb1e5c1265fa96e90759925
   */
  
  #include "DNA_cachefile_types.h"
+ #include "DNA_mesh_types.h"
  #include "DNA_modifier_types.h"
  #include "DNA_object_types.h"
  #include "DNA_scene_types.h"
  
  #include "BKE_cachefile.h"
  #include "BKE_DerivedMesh.h"
+ #include "BKE_cdderivedmesh.h"
  #include "BKE_global.h"
  #include "BKE_library.h"
  #include "BKE_library_query.h"
  #include "BKE_scene.h"
  
 -#include "depsgraph_private.h"
  #include "DEG_depsgraph_build.h"
  
  #include "MOD_modifiertypes.h"
@@@ -92,13 -95,17 +94,17 @@@ static bool isDisabled(ModifierData *md
        return (mcmd->cache_file == NULL) || (mcmd->object_path[0] == '\0');
  }
  
 -static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 -                                  DerivedMesh *dm,
 +static DerivedMesh *applyModifier(ModifierData *md, struct EvaluationContext *UNUSED(eval_ctx),
 +                                  Object *ob, DerivedMesh *dm,
-                                   ModifierApplyFlag flag)
+                                   ModifierApplyFlag UNUSED(flag))
  {
  #ifdef WITH_ALEMBIC
        MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
  
+       /* Only used to check wehther we are operating on org data or not... */
+       Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
+       DerivedMesh *org_dm = dm;
        Scene *scene = md->scene;
        const float frame = BKE_scene_frame_get(scene);
        const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
                }
        }
  
+       if (me != NULL) {
+               MVert *mvert = dm->getVertArray(dm);
+               MEdge *medge = dm->getEdgeArray(dm);
+               MPoly *mpoly = dm->getPolyArray(dm);
+               if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) {
+                       /* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */
+                       dm = CDDM_copy(dm);
+               }
+       }
        DerivedMesh *result = ABC_read_mesh(mcmd->reader,
                                            ob,
                                            dm,
                modifier_setError(md, "%s", err_str);
        }
  
+       if (!ELEM(result, NULL, dm) && (dm != org_dm)) {
+               dm->release(dm);
+               dm = org_dm;
+       }
        return result ? result : dm;
-       UNUSED_VARS(flag);
  #else
        return dm;
-       UNUSED_VARS(md, ob, flag);
+       UNUSED_VARS(md, ob);
  #endif
  }
  
@@@ -154,6 -175,23 +174,6 @@@ static void foreachIDLink(ModifierData 
  }
  
  
 -static void updateDepgraph(ModifierData *md, DagForest *forest,
 -                           struct Main *bmain,
 -                           struct Scene *scene,
 -                           Object *ob, DagNode *obNode)
 -{
 -      MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
 -
 -      if (mcmd->cache_file != NULL) {
 -              DagNode *curNode = dag_get_node(forest, mcmd->cache_file);
 -
 -              dag_add_relation(forest, curNode, obNode,
 -                               DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Cache File Modifier");
 -      }
 -
 -      UNUSED_VARS(bmain, scene, ob);
 -}
 -
  static void updateDepsgraph(ModifierData *md,
                              struct Main *bmain,
                              struct Scene *scene,
@@@ -187,6 -225,7 +207,6 @@@ ModifierTypeInfo modifierType_MeshSeque
      /* requiredDataMask */  NULL,
      /* freeData */          freeData,
      /* isDisabled */        isDisabled,
 -    /* updateDepgraph */    updateDepgraph,
      /* updateDepsgraph */   updateDepsgraph,
      /* dependsOnTime */     dependsOnTime,
      /* dependsOnNormals */  NULL,