[Bf-blender-cvs] [dc882a0] alembic_pointcache: New ID datablock 'CacheLibrary', for managing physical cache archives and files.

Lukas Tönne noreply at git.blender.org
Thu Feb 19 11:07:36 CET 2015


Commit: dc882a008c7f7a15e422daba60d696239eca887d
Author: Lukas Tönne
Date:   Thu Feb 19 11:01:49 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBdc882a008c7f7a15e422daba60d696239eca887d

New ID datablock 'CacheLibrary', for managing physical cache archives
and files.

At it's core this is just a file path, but many different cache users
may refer to this, so having a dedicated ID block helps. It can be
compared to Image datablocks, which also primarily are used for data
on storage, but can be packed with the blend file, and carry some
additional information that would be cumbersome to keep sync'ed
otherwise.

The name 'CacheLibrary' deliberately resembles the 'Library' datablock:
just as a Library stores ID blocks in a physical file, a CacheLibrary
stores cached data (in Alembic HDF5/Ogawa or other formats).

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

M	source/blender/blenfont/BLF_translation.h
M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/BKE_main.h
M	source/blender/blenkernel/BKE_pointcache.h
M	source/blender/blenkernel/intern/idcode.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesdna/DNA_pointcache_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_ID.c
A	source/blender/makesrna/intern/rna_cache_library.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_main.c
M	source/blender/makesrna/intern/rna_main_api.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h
index b42e6f8..0ce60c9 100644
--- a/source/blender/blenfont/BLF_translation.h
+++ b/source/blender/blenfont/BLF_translation.h
@@ -146,6 +146,7 @@ const char *BLF_translate_do_new_dataname(const char *msgctxt, const char *msgid
 #define BLF_I18NCONTEXT_ID_ACTION               "Action"
 #define BLF_I18NCONTEXT_ID_ARMATURE             "Armature"
 #define BLF_I18NCONTEXT_ID_BRUSH                "Brush"
+#define BLF_I18NCONTEXT_ID_CACHELIBRARY         "CacheLibrary"
 #define BLF_I18NCONTEXT_ID_CAMERA               "Camera"
 #define BLF_I18NCONTEXT_ID_CURVE                "Curve"
 #define BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE   "FreestyleLineStyle"
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index e88a4e8..d137718 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -71,7 +71,7 @@ void id_clear_lib_data(struct Main *bmain, struct ID *id);
 
 struct ListBase *which_libbase(struct Main *mainlib, short type);
 
-#define MAX_LIBARRAY    35
+#define MAX_LIBARRAY    36
 int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
 
 void BKE_libblock_free(struct Main *bmain, void *idv);
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index ec654ea..a0c67e0 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -94,6 +94,7 @@ typedef struct Main {
 	ListBase movieclip;
 	ListBase mask;
 	ListBase linestyle;
+	ListBase cache_library;
 
 	char id_tag_update[256];
 
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index d863f75..3a9340f 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -38,6 +38,9 @@
 #include "DNA_boid_types.h"
 #include <stdio.h> /* for FILE */
 
+CacheLibrary *BKE_cache_library_add(struct Main *bmain, const char *name);
+void BKE_cache_library_free(CacheLibrary *cache);
+
 /* Point cache reset options */
 typedef enum ePointCache_ResetMode {
 	PTCACHE_RESET_DEPSGRAPH     = 0,
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 1b7a03e..fbd2359 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -53,6 +53,7 @@ static IDType idtypes[] = {
 	{ ID_AC,     "Action",           "actions",         IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_AR,     "Armature",         "armatures",       IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_BR,     "Brush",            "brushes",         IDTYPE_FLAGS_ISLINKABLE },
+	{ ID_CL,     "CacheLibrary",     "cache_libraries", 0                       },
 	{ ID_CA,     "Camera",           "cameras",         IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_CU,     "Curve",            "curves",          IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_GD,     "GPencil",          "grease_pencil",   IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index fa4f9c6..ccf4693 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -59,6 +59,7 @@
 #include "DNA_movieclip_types.h"
 #include "DNA_mask_types.h"
 #include "DNA_node_types.h"
+#include "DNA_pointcache_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_speaker_types.h"
@@ -107,6 +108,7 @@
 #include "BKE_paint.h"
 #include "BKE_particle.h"
 #include "BKE_packedFile.h"
+#include "BKE_pointcache.h"
 #include "BKE_speaker.h"
 #include "BKE_sound.h"
 #include "BKE_screen.h"
@@ -521,6 +523,8 @@ ListBase *which_libbase(Main *mainlib, short type)
 			return &(mainlib->palettes);
 		case ID_PC:
 			return &(mainlib->paintcurves);
+		case ID_CL:
+			return &(mainlib->cache_library);
 	}
 	return NULL;
 }
@@ -615,6 +619,7 @@ int set_listbasepointers(Main *main, ListBase **lb)
 	lb[a++] = &(main->linestyle); /* referenced by scenes */
 	lb[a++] = &(main->scene);
 	lb[a++] = &(main->library);
+	lb[a++] = &(main->cache_library);
 	lb[a++] = &(main->wm);
 	lb[a++] = &(main->movieclip);
 	lb[a++] = &(main->mask);
@@ -747,6 +752,9 @@ static ID *alloc_libblock_notest(short type)
 		case ID_PC:
 			id = MEM_callocN(sizeof(PaintCurve), "Paint Curve");
 			break;
+		case ID_CL:
+			id = MEM_callocN(sizeof(CacheLibrary), "Cache Library");
+			break;
 	}
 	return id;
 }
@@ -1029,6 +1037,9 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, bool do_id_user)
 		case ID_PC:
 			BKE_paint_curve_free((PaintCurve *)id);
 			break;
+		case ID_CL:
+			BKE_cache_library_free((CacheLibrary *)id);
+			break;
 	}
 
 	/* avoid notifying on removed data */
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index cb72192..9846a48 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -63,6 +63,7 @@
 #include "BKE_cloth.h"
 #include "BKE_dynamicpaint.h"
 #include "BKE_global.h"
+#include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
@@ -105,6 +106,20 @@
 #endif
 
 
+void BKE_cache_library_free(CacheLibrary *UNUSED(cache))
+{
+}
+
+CacheLibrary *BKE_cache_library_add(Main *bmain, const char *name)
+{
+	CacheLibrary *cachelib;
+
+	cachelib = BKE_libblock_alloc(bmain, ID_CL, name);
+
+	return cachelib;
+}
+
+
 /* File open options, for BKE_ptcache_file_open */
 typedef enum ePointCache_FileMode {
 	PTCACHE_FILE_READ   = 0,
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index ee2a758..9560df0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1929,7 +1929,6 @@ static void direct_link_paint_curve(FileData *fd, PaintCurve *pc)
 	pc->points = newdataadr(fd, pc->points);
 }
 
-
 static void direct_link_script(FileData *UNUSED(fd), Script *script)
 {
 	script->id.us = 1;
@@ -1937,6 +1936,21 @@ static void direct_link_script(FileData *UNUSED(fd), Script *script)
 }
 
 
+/* ************ READ CacheLibrary *************** */
+
+static void lib_link_cache_library(FileData *UNUSED(fd), Main *main)
+{
+	CacheLibrary *cachelib;
+	for (cachelib = main->cache_library.first; cachelib; cachelib = cachelib->id.next) {
+		cachelib->id.us = 1;
+	}
+}
+
+static void direct_link_cache_library(FileData *UNUSED(fd), CacheLibrary *UNUSED(cachelib))
+{
+}
+
+
 /* ************ READ PACKEDFILE *************** */
 
 static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
@@ -7356,6 +7370,7 @@ static const char *dataname(short id_code)
 		case ID_MC: return "Data from MC";
 		case ID_MSK: return "Data from MSK";
 		case ID_LS: return "Data from LS";
+		case ID_CL: return "Data from CL";
 	}
 	return "Data from Lib Block";
 	
@@ -7542,6 +7557,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
 		case ID_PC:
 			direct_link_paint_curve(fd, (PaintCurve *)id);
 			break;
+		case ID_CL:
+			direct_link_cache_library(fd, (CacheLibrary *)id);
+			break;
 	}
 	
 	oldnewmap_free_unused(fd->datamap);
@@ -7736,6 +7754,7 @@ static void lib_link_all(FileData *fd, Main *main)
 	lib_link_mask(fd, main);
 	lib_link_linestyle(fd, main);
 	lib_link_gpencil(fd, main);
+	lib_link_cache_library(fd, main);
 
 	lib_link_mesh(fd, main);		/* as last: tpage images with users at zero */
 	
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index be9b279..7129444 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3429,6 +3429,19 @@ static void write_linestyles(WriteData *wd, ListBase *idbase)
 	}
 }
 
+static void write_cachelibraries(WriteData *wd, ListBase *idbase)
+{
+	CacheLibrary *cachelib;
+
+	for (cachelib = idbase->first; cachelib; cachelib = cachelib->id.next) {
+		if (cachelib->id.us > 0 || wd->current) {
+			writestruct(wd, ID_CL, "CacheLibrary", 1, cachelib);
+			if (cachelib->id.properties)
+				IDP_WriteProperty(cachelib->id.properties, wd);
+		}
+	}
+}
+
 /* context is usually defined by WM, two cases where no WM is available:
  * - for forward compatibility, curscreen has to be saved
  * - for undofile, curscene needs to be saved */
@@ -3557,6 +3570,7 @@ static int write_file_handle(
 	write_scripts  (wd, &mainvar->script);
 	write_gpencils (wd, &mainvar->gpencil);
 	write_linestyles(wd, &mainvar->linestyle);
+	write_cachelibraries(wd, &mainvar->cache_library);
 	write_libraries(wd,  mainvar->next);
 
 	if (write_user_block) {
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index b3c31a1..d44f8b1 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -354,6 +354,7 @@ static const char *template_id_browse_tip(StructRNA *type)
 			case ID_MSK: return N_("Browse Mask to be linked");
 			case ID_PAL: return N_("Browse Palette Data to be linked");
 			case ID_PC:  return N_("Browse Paint Curve Data to be linked");
+			case ID_CL:  return N_("Browse Cache Library Data to be linked");
 		}
 	}
 	return N_("Browse ID data to be linked");
@@ -394,6 +395,7 @@ static const char *template_id_context(StructRNA *type)
 			case ID_MSK: return BLF_I18NCONTEXT_ID_MASK;
 			case ID_PAL: return BLF_I18NCONTEXT_ID_PALETTE;
 			case ID_PC:  return BLF_I18NCONTEXT_ID_PAINTCURVE;
+			case ID_CL:  return BLF_I18NCONTEXT_ID_CACHELIBRARY;
 		}
 	}
 	return BLF_I18NCONTEXT_DEFAULT;
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index b51b53c..06229c9 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -222,6 +222,7 @@ typedef struct PreviewImage {
 #define ID_LS		MAKE_ID2('L', 'S') /* FreestyleLineStyle */
 #define ID_PAL		MAKE_ID2('P', 'L') /* Palette */
 #define ID_PC		MAKE_ID2('P', 'C') /* PaintCurve  */
+#define ID_CL		MAKE_ID2('C', 'L') /* CacheLibrary */
 
 	/* NOTE! Fake IDs, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list