[Bf-blender-cvs] [a57d3f8c943] new-object-types: Merge branch 'master' into new-object-types

Brecht Van Lommel noreply at git.blender.org
Thu Feb 6 19:49:04 CET 2020


Commit: a57d3f8c943969292fcb13d7e99813459541ed03
Author: Brecht Van Lommel
Date:   Thu Feb 6 13:53:26 2020 +0100
Branches: new-object-types
https://developer.blender.org/rBa57d3f8c943969292fcb13d7e99813459541ed03

Merge branch 'master' into new-object-types

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/material.c
index 632effa3129,84b3ea27025..288959366d1
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@@ -263,10 -235,15 +238,10 @@@ void BKE_material_make_local(Main *bmai
    BKE_id_make_local_generic(bmain, &ma->id, true, lib_local);
  }
  
- Material ***give_matarar(Object *ob)
+ Material ***BKE_object_material_array(Object *ob)
  {
 -  Mesh *me;
 -  Curve *cu;
 -  MetaBall *mb;
 -  bGPdata *gpd;
 -
    if (ob->type == OB_MESH) {
 -    me = ob->data;
 +    Mesh *me = ob->data;
      return &(me->mat);
    }
    else if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
@@@ -296,10 -261,15 +271,10 @@@
    return NULL;
  }
  
- short *give_totcolp(Object *ob)
+ short *BKE_object_material_num(Object *ob)
  {
 -  Mesh *me;
 -  Curve *cu;
 -  MetaBall *mb;
 -  bGPdata *gpd;
 -
    if (ob->type == OB_MESH) {
 -    me = ob->data;
 +    Mesh *me = ob->data;
      return &(me->totcol);
    }
    else if (ELEM(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
diff --cc source/blender/blenloader/intern/readfile.c
index ef49f291395,651f390d23e..f75d9a23ce1
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -9225,117 -8820,6 +8880,89 @@@ static void direct_link_linestyle(FileD
  
  /** \} */
  
 +/* -------------------------------------------------------------------- */
 +/** \name Read ID: Hair
 + * \{ */
 +
- static void lib_link_hair(FileData *fd, Main *main)
++static void lib_link_hair(FileData *fd, Main *UNUSED(main), Hair *hair)
 +{
-   for (Hair *hair = main->hairs.first; hair; hair = hair->id.next) {
-     if (hair->id.tag & LIB_TAG_NEED_LINK) {
-       IDP_LibLinkProperty(hair->id.properties, fd);
-       lib_link_animdata(fd, &hair->id, hair->adt);
- 
-       for (int a = 0; a < hair->totcol; a++) {
-         hair->mat[a] = newlibadr_us(fd, hair->id.lib, hair->mat[a]);
-       }
- 
-       hair->id.tag &= ~LIB_TAG_NEED_LINK;
-     }
++  for (int a = 0; a < hair->totcol; a++) {
++    hair->mat[a] = newlibadr_us(fd, hair->id.lib, hair->mat[a]);
 +  }
 +}
 +
 +static void direct_link_hair(FileData *fd, Hair *hair)
 +{
 +  hair->adt = newdataadr(fd, hair->adt);
 +  direct_link_animdata(fd, hair->adt);
 +
 +  /* Geometry */
 +  direct_link_customdata(fd, &hair->pdata, hair->totpoint);
 +  direct_link_customdata(fd, &hair->cdata, hair->totcurve);
 +  BKE_hair_update_customdata_pointers(hair);
 +
 +  /* Materials */
 +  hair->mat = newdataadr(fd, hair->mat);
 +  test_pointer_array(fd, (void **)&hair->mat);
 +}
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Read ID: Point Cloud
 + * \{ */
 +
- static void lib_link_pointcloud(FileData *fd, Main *main)
++static void lib_link_pointcloud(FileData *fd, Main *UNUSED(main), PointCloud *pointcloud)
 +{
-   for (PointCloud *pointcloud = main->pointclouds.first; pointcloud;
-        pointcloud = pointcloud->id.next) {
-     if (pointcloud->id.tag & LIB_TAG_NEED_LINK) {
-       IDP_LibLinkProperty(pointcloud->id.properties, fd);
-       lib_link_animdata(fd, &pointcloud->id, pointcloud->adt);
- 
-       for (int a = 0; a < pointcloud->totcol; a++) {
-         pointcloud->mat[a] = newlibadr_us(fd, pointcloud->id.lib, pointcloud->mat[a]);
-       }
- 
-       pointcloud->id.tag &= ~LIB_TAG_NEED_LINK;
-     }
++  for (int a = 0; a < pointcloud->totcol; a++) {
++    pointcloud->mat[a] = newlibadr_us(fd, pointcloud->id.lib, pointcloud->mat[a]);
 +  }
 +}
 +
 +static void direct_link_pointcloud(FileData *fd, PointCloud *pointcloud)
 +{
 +  pointcloud->adt = newdataadr(fd, pointcloud->adt);
 +  direct_link_animdata(fd, pointcloud->adt);
 +
 +  /* Geometry */
 +  direct_link_customdata(fd, &pointcloud->pdata, pointcloud->totpoint);
 +  BKE_pointcloud_update_customdata_pointers(pointcloud);
 +
 +  /* Materials */
 +  pointcloud->mat = newdataadr(fd, pointcloud->mat);
 +  test_pointer_array(fd, (void **)&pointcloud->mat);
 +}
 +
 +/** \} */
 +
 +/* -------------------------------------------------------------------- */
 +/** \name Read ID: Volume
 + * \{ */
 +
- static void lib_link_volume(FileData *fd, Main *main)
++static void lib_link_volume(FileData *fd, Main *UNUSED(main), Volume *volume)
 +{
-   for (Volume *volume = main->volumes.first; volume; volume = volume->id.next) {
-     if (volume->id.tag & LIB_TAG_NEED_LINK) {
-       IDP_LibLinkProperty(volume->id.properties, fd);
-       lib_link_animdata(fd, &volume->id, volume->adt);
- 
-       for (int a = 0; a < volume->totcol; a++) {
-         volume->mat[a] = newlibadr_us(fd, volume->id.lib, volume->mat[a]);
-       }
- 
-       volume->id.tag &= ~LIB_TAG_NEED_LINK;
-     }
++  for (int a = 0; a < volume->totcol; a++) {
++    volume->mat[a] = newlibadr_us(fd, volume->id.lib, volume->mat[a]);
 +  }
 +}
 +
 +static void direct_link_volume(FileData *fd, Volume *volume)
 +{
 +  volume->adt = newdataadr(fd, volume->adt);
 +  direct_link_animdata(fd, volume->adt);
 +
 +  volume->packedfile = direct_link_packedfile(fd, volume->packedfile);
 +  volume->runtime.grids = (fd->volumemap) ? newvolumeadr(fd, volume->runtime.grids) : NULL;
 +  volume->runtime.frame = 0;
 +  BKE_volume_init_grids(volume);
 +
 +  /* materials */
 +  volume->mat = newdataadr(fd, volume->mat);
 +  test_pointer_array(fd, (void **)&volume->mat);
 +}
 +
 +/** \} */
 +
  /* -------------------------------------------------------------------- */
  /** \name Read Library Data Block
   * \{ */
@@@ -9945,77 -9402,165 +9560,173 @@@ static void do_versions_after_linking(M
  /** \name Read Library Data Block (all)
   * \{ */
  
- static void lib_link_all(FileData *fd, Main *main)
+ static void lib_link_all(FileData *fd, Main *bmain)
  {
-   lib_link_id(fd, main);
+   ID *id;
+   FOREACH_MAIN_ID_BEGIN (bmain, id) {
+     if ((id->tag & LIB_TAG_NEED_LINK) == 0) {
+       /* This ID does not need liblink, just skip to next one. */
+       continue;
+     }
  
-   /* No load UI for undo memfiles */
-   if (fd->memfile == NULL) {
-     lib_link_windowmanager(fd, main);
-   }
-   /* DO NOT skip screens here,
-    * 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */
-   lib_link_screen(fd, main);
-   lib_link_scene(fd, main);
-   lib_link_object(fd, main);
-   lib_link_mesh(fd, main);
-   lib_link_curve(fd, main);
-   lib_link_mball(fd, main);
-   lib_link_material(fd, main);
-   lib_link_texture(fd, main);
-   lib_link_image(fd, main);
- 
-   /* XXX deprecated... still needs to be maintained for version patches still. */
-   lib_link_ipo(fd, main);
- 
-   lib_link_key(fd, main);
-   lib_link_world(fd, main);
-   lib_link_light(fd, main);
-   lib_link_latt(fd, main);
-   lib_link_text(fd, main);
-   lib_link_camera(fd, main);
-   lib_link_speaker(fd, main);
-   lib_link_lightprobe(fd, main);
-   lib_link_sound(fd, main);
-   lib_link_collection(fd, main);
-   lib_link_armature(fd, main);
-   lib_link_action(fd, main);
-   lib_link_vfont(fd, main);
- 
-   /* Has to be done after scene/materials, this will verify group nodes. */
-   lib_link_nodetree(fd, main);
- 
-   lib_link_palette(fd, main);
-   lib_link_brush(fd, main);
-   lib_link_paint_curve(fd, main);
-   lib_link_particlesettings(fd, main);
-   lib_link_movieclip(fd, main);
-   lib_link_mask(fd, main);
-   lib_link_linestyle(fd, main);
-   lib_link_gpencil(fd, main);
-   lib_link_cachefiles(fd, main);
-   lib_link_workspaces(fd, main);
-   lib_link_hair(fd, main);
-   lib_link_pointcloud(fd, main);
-   lib_link_volume(fd, main);
- 
-   lib_link_library(fd, main); /* only init users */
+     if (fd->memfile != NULL && GS(id->name) == ID_WM) {
+       /* No load UI for undo memfiles.
+        * Only WM currently, SCR needs it still (see below), and so does WS? */
+       continue;
+     }
+ 
+     lib_link_id(fd, bmain, id);
+ 
+     /* Note: ID types are processed in reverse order as defined by INDEX_ID_XXX enums in DNA_ID.h.
+      * This ensures handling of most dependencies in proper order, as elsewhere in code.
+      * Please keep order of entries in that switch matching that order, it's easier to quickly see
+      * whether something is wrong then. */
+     switch (GS(id->name)) {
+       case ID_MSK:
+         lib_link_mask(fd, bmain, (Mask *)id);
+         break;
+       case ID_WM:
+         lib_link_windowmanager(fd, bmain, (wmWindowManager *)id);
+         break;
+       case ID_WS:
+         /* Could we skip WS in undo case? */
+         lib_link_workspaces(fd, bmain, (WorkSpace *)id);
+         break;
+       case ID_SCE:
+         lib_link_scene(fd, bmain, (Scene *)id);
+         break;
+       case ID_LS:
+         lib_link_linestyle(fd, bmain, (FreestyleLineStyle *)id);
+         break;
+       case ID_OB:
+         lib_link_object(fd, bmain, (Object *)id);
+         break;
+       case ID_SCR:
+         /* DO NOT skip screens here,
+          * 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */
+         lib_link_screen(fd, bmain, (bScreen *)id);
+         break;
+       case ID_MC:
+         lib_link_movieclip(fd, bmain, (MovieClip *)id);
+         break;
+       case ID_WO:
+         lib_link_world(fd, bmain, (World *)id);
+         break;
+       case ID_LP:
+         lib_link_lightprobe(fd, bmain, (LightProbe *)id);
+         break;
+       case ID_SPK:
+         lib_link_speaker(fd, bmain, (Speaker *)id);
+         break;
+       case ID_PA:
+         lib_link_particlesettings(fd, bmain, (ParticleSettings *)id);
+         break;
+       case ID_PC:
+         lib_link_paint_curve(fd, bmain, (PaintCurve *)id);
+         break;
+       case ID_BR:
+         lib_link_brush(fd, bmain, (Brush *)id);
+         break;
+       case ID_GR:
+         lib_link_collection(fd, bmain, (Collection *)id);
+         break;
+       case ID_SO:
+         lib_link_sound(fd, bmain, (bSound *)id);
+         break;
+       case ID_TXT:
+         lib_link_text(fd, bmain, (Text *)id);
+         break;
+       case ID_CA:
+         lib_link_camera(fd, bmain, (Camera *)id);
+         break;
+       case ID_LA:
+         lib_link_light(fd, bmain, (Light *)id);
+         break;
+       case ID_LT:
+         lib_link_la

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list