From e5916187e808c1c22229589d103f4de4d4411b5b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 20 Oct 2015 14:44:57 +0200 Subject: First step to handle missing libs/datablocks when reading a file. Idea is, instead of ignoring completely missing linked datablocks, to create void placeholders for them. That way, you can work on your file, save it, and find again your missing data once lib becomes available again. Or you can edit missing lib's path (in Outliner), save and reload the file, and you are done. Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon. Future plans are also to be able to relocate missing libs and reload them at runtime. Code notes: - Placeholder ID is just a regular datablock of same type as expected linked one, with 'default' data, and a LIB_MISSING bitflag set. - To allow creation of such datablocks, creation of datablocks in BKE was split in two step: + Allocation of memory itself. + Setting of all internal data to default values. See also the design task (T43351). Reviewed by @campbellbarton, thanks a bunch! Differential Revision: https://developer.blender.org/D1394 --- source/blender/blenkernel/intern/material.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/material.c') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3e7e98b4a1d..a69b5fd87b5 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -78,7 +78,7 @@ Material defmaterial; /* called on startup, creator.c */ void init_def_material(void) { - init_material(&defmaterial); + BKE_material_init(&defmaterial); } /* not material itself */ @@ -122,8 +122,10 @@ void BKE_material_free_ex(Material *ma, bool do_id_user) GPU_material_free(&ma->gpumaterial); } -void init_material(Material *ma) +void BKE_material_init(Material *ma) { + BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ma, id)); + ma->r = ma->g = ma->b = ma->ref = 0.8; ma->specr = ma->specg = ma->specb = 1.0; ma->mirr = ma->mirg = ma->mirb = 1.0; @@ -221,7 +223,7 @@ Material *BKE_material_add(Main *bmain, const char *name) ma = BKE_libblock_alloc(bmain, ID_MA, name); - init_material(ma); + BKE_material_init(ma); return ma; } -- cgit v1.2.3