[Bf-blender-cvs] [bd46a609b11] asset-metadata: Merge branch 'master' into asset-metadata

Julian Eisel noreply at git.blender.org
Mon Aug 24 19:10:59 CEST 2020


Commit: bd46a609b11c9e9e9b6549ca5cfe92155b1dc3b5
Author: Julian Eisel
Date:   Mon Aug 24 19:10:41 2020 +0200
Branches: asset-metadata
https://developer.blender.org/rBbd46a609b11c9e9e9b6549ca5cfe92155b1dc3b5

Merge branch 'master' into asset-metadata

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



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

diff --cc source/blender/blenloader/intern/writefile.c
index 6beb8c3e290,a9f9685bf75..1c1590b9a70
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@@ -658,102 -658,11 +659,27 @@@ static void writelist_id(WriteData *wd
   * These functions are used by blender's .blend system for file saving/loading.
   * \{ */
  
- void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer);
- void IDP_WriteProperty(const IDProperty *prop, BlendWriter *writer);
- 
- static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer)
- {
-   /*REMEMBER to set totalen to len in the linking code!!*/
-   if (prop->data.pointer) {
-     BLO_write_raw(writer, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
- 
-     if (prop->subtype == IDP_GROUP) {
-       IDProperty **array = prop->data.pointer;
-       int a;
- 
-       for (a = 0; a < prop->len; a++) {
-         IDP_WriteProperty(array[a], writer);
-       }
-     }
-   }
- }
- 
- static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer)
- {
-   /*REMEMBER to set totalen to len in the linking code!!*/
-   if (prop->data.pointer) {
-     const IDProperty *array = prop->data.pointer;
-     int a;
- 
-     BLO_write_struct_array(writer, IDProperty, prop->len, array);
- 
-     for (a = 0; a < prop->len; a++) {
-       IDP_WriteProperty_OnlyData(&array[a], writer);
-     }
-   }
- }
- 
- static void IDP_WriteString(const IDProperty *prop, BlendWriter *writer)
- {
-   /*REMEMBER to set totalen to len in the linking code!!*/
-   BLO_write_raw(writer, prop->len, prop->data.pointer);
- }
- 
- static void IDP_WriteGroup(const IDProperty *prop, BlendWriter *writer)
- {
-   IDProperty *loop;
- 
-   for (loop = prop->data.group.first; loop; loop = loop->next) {
-     IDP_WriteProperty(loop, writer);
-   }
- }
- 
- /* Functions to read/write ID Properties */
- void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer)
- {
-   switch (prop->type) {
-     case IDP_GROUP:
-       IDP_WriteGroup(prop, writer);
-       break;
-     case IDP_STRING:
-       IDP_WriteString(prop, writer);
-       break;
-     case IDP_ARRAY:
-       IDP_WriteArray(prop, writer);
-       break;
-     case IDP_IDPARRAY:
-       IDP_WriteIDPArray(prop, writer);
-       break;
-   }
- }
- 
- void IDP_WriteProperty(const IDProperty *prop, BlendWriter *writer)
- {
-   BLO_write_struct(writer, IDProperty, prop);
-   IDP_WriteProperty_OnlyData(prop, writer);
- }
- 
 +static void write_assetdata(BlendWriter *writer, AssetData *asset_data)
 +{
 +  BLO_write_struct(writer, AssetData, asset_data);
 +
 +  if (asset_data->description) {
 +    BLO_write_string(writer, asset_data->description);
 +  }
 +  LISTBASE_FOREACH (CustomTag *, tag, &asset_data->tags) {
 +    BLO_write_struct(writer, CustomTag, tag);
 +  }
 +}
 +
  static void write_iddata(BlendWriter *writer, ID *id)
  {
 +  if (id->asset_data) {
 +    write_assetdata(writer, id->asset_data);
 +  }
 +
    /* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
    if (id->properties && !ELEM(GS(id->name), ID_WM)) {
-     IDP_WriteProperty(id->properties, writer);
+     IDP_BlendWrite(writer, id->properties);
    }
  
    if (id->override_library) {
diff --cc source/blender/editors/space_outliner/outliner_tools.c
index c9a5fd603fd,2a13f9d6a66..55852fd161c
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@@ -719,28 -721,7 +721,28 @@@ static void outliner_object_delete_fn(b
    }
  }
  
 +static void id_make_asset_cb(bContext *C,
 +                             ReportList *UNUSED(reports),
 +                             Scene *UNUSED(scene),
 +                             TreeElement *UNUSED(te),
 +                             TreeStoreElem *UNUSED(tsep),
 +                             TreeStoreElem *tselem,
 +                             void *UNUSED(user_data))
 +{
 +  ID *id = tselem->id;
 +  PointerRNA id_ptr;
 +  PointerRNA op_ptr;
 +
 +  RNA_id_pointer_create(id, &id_ptr);
 +
 +  WM_operator_properties_create(&op_ptr, "ASSET_OT_create");
 +  RNA_pointer_set(&op_ptr, "id", id_ptr);
 +  WM_operator_name_call(C, "ASSET_OT_create", WM_OP_EXEC_DEFAULT, &op_ptr);
 +
 +  WM_operator_properties_free(&op_ptr);
 +}
 +
- static void id_local_cb(bContext *C,
+ static void id_local_fn(bContext *C,
                          ReportList *UNUSED(reports),
                          Scene *UNUSED(scene),
                          TreeElement *UNUSED(te),
@@@ -1566,10 -1666,13 +1687,14 @@@ typedef enum eOutlinerIdOpTypes 
    OUTLINER_IDOP_INVALID = 0,
  
    OUTLINER_IDOP_UNLINK,
 +  OUTLINER_IDOP_CREATE_ASSET,
    OUTLINER_IDOP_LOCAL,
-   OUTLINER_IDOP_OVERRIDE_LIBRARY,
-   OUTLINER_IDOP_OVERRIDE_LIBRARY_HIERARCHY,
+   OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE,
+   OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE_HIERARCHY,
+   OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET,
+   OUTLINER_IDOP_OVERRIDE_LIBRARY_RESET_HIERARCHY,
+   OUTLINER_IDOP_OVERRIDE_LIBRARY_RESYNC_HIERARCHY,
+   OUTLINER_IDOP_OVERRIDE_LIBRARY_DELETE_HIERARCHY,
    OUTLINER_IDOP_SINGLE,
    OUTLINER_IDOP_DELETE,
    OUTLINER_IDOP_REMAP,
@@@ -1587,18 -1690,7 +1712,8 @@@
  /* TODO: implement support for changing the ID-block used. */
  static const EnumPropertyItem prop_id_op_types[] = {
      {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""},
 +    {OUTLINER_IDOP_CREATE_ASSET, "CREATE_ASSET", 0, "Create Asset", ""},
      {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
-     {OUTLINER_IDOP_OVERRIDE_LIBRARY,
-      "OVERRIDE_LIBRARY",
-      0,
-      "Add Library Override",
-      "Add a local override of this linked data-block"},
-     {OUTLINER_IDOP_OVERRIDE_LIBRARY_HIERARCHY,
-      "OVERRIDE_LIBRARY_HIERARCHY",
-      0,
-      "Add Library Override Hierarchy",
-      "Add a local override of this linked data-block, and its hierarchy of dependencies"},
      {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
      {OUTLINER_IDOP_DELETE, "DELETE", ICON_X, "Delete", ""},
      {OUTLINER_IDOP_REMAP,
@@@ -1738,17 -1892,10 +1915,18 @@@ static int outliner_id_operation_exec(b
        }
        break;
      }
 +    case OUTLINER_IDOP_CREATE_ASSET: {
 +      outliner_do_libdata_operation(
 +          C, op->reports, scene, soops, &soops->tree, id_make_asset_cb, NULL);
 +      ED_undo_push(C, "Made Asset");
 +      /* TODO how to handle undo here? id_make_asset_cb() calls an OP. Esp. in case of multiple
 +       * data-blocks we only want a single push. */
 +      break;
 +    }
      case OUTLINER_IDOP_LOCAL: {
        /* make local */
-       outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_local_cb, NULL);
+       outliner_do_libdata_operation(
+           C, op->reports, scene, space_outliner, &space_outliner->tree, id_local_fn, NULL);
        ED_undo_push(C, "Localized Data");
        break;
      }



More information about the Bf-blender-cvs mailing list