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/camera.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/camera.c') diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 7e043df2808..46b74c58965 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -57,11 +57,9 @@ /****************************** Camera Datablock *****************************/ -void *BKE_camera_add(Main *bmain, const char *name) +void BKE_camera_init(Camera *cam) { - Camera *cam; - - cam = BKE_libblock_alloc(bmain, ID_CA, name); + BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cam, id)); cam->lens = 35.0f; cam->sensor_x = DEFAULT_SENSOR_WIDTH; @@ -78,6 +76,15 @@ void *BKE_camera_add(Main *bmain, const char *name) /* stereoscopy 3d */ cam->stereo.interocular_distance = 0.065f; cam->stereo.convergence_distance = 30.f * 0.065f; +} + +void *BKE_camera_add(Main *bmain, const char *name) +{ + Camera *cam; + + cam = BKE_libblock_alloc(bmain, ID_CA, name); + + BKE_camera_init(cam); return cam; } -- cgit v1.2.3