Commit: cce6123911375f3a5ae6bc282ba3dbb2d6521b8b Author: Lukas Tönne Date: Thu Feb 26 17:14:46 2015 +0100 Branches: alembic_pointcache https://developer.blender.org/rBcce6123911375f3a5ae6bc282ba3dbb2d6521b8b
Fix for indirectly linked object pointers in cache libraries. These must be made "extern" to avoid losing links on loading. =================================================================== M source/blender/blenkernel/intern/cache_library.c M source/blender/blenloader/intern/readfile.c =================================================================== diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c index 5914a62..b04fd04 100644 --- a/source/blender/blenkernel/intern/cache_library.c +++ b/source/blender/blenkernel/intern/cache_library.c @@ -326,6 +326,17 @@ static bool cache_item_cmp(const void *key_a, const void *key_b) return false; } +BLI_INLINE void print_cachelib_items(CacheLibrary *cachelib) +{ + CacheItem *item; + int i; + + printf("Cache Library %s:\n", cachelib->id.name+2); + for (item = cachelib->items.first, i = 0; item; item = item->next, ++i) { + printf(" Item %d: ob=%s, type=%d, index=%d, hash=%d\n", i, item->ob ? item->ob->id.name+2 : "!!!", item->type, item->index, cache_item_hash(item)); + } +} + const char *BKE_cache_item_name_prefix(int type) { /* note: avoid underscores and the like here, @@ -411,6 +422,8 @@ CacheItem *BKE_cache_library_add_item(CacheLibrary *cachelib, struct Object *ob, BLI_addtail(&cachelib->items, item); cache_library_insert_item_hash(cachelib, item, false); + + id_lib_extern((ID *)item->ob); } return item; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a80f56d..9864ba3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -114,6 +114,7 @@ #include "BKE_armature.h" #include "BKE_brush.h" +#include "BKE_cache_library.h" #include "BKE_cloth.h" #include "BKE_constraint.h" #include "BKE_context.h" @@ -1940,7 +1941,7 @@ static void direct_link_script(FileData *UNUSED(fd), Script *script) static void lib_link_cache_library(FileData *fd, Main *main) { CacheLibrary *cachelib; - CacheItem *item; + CacheItem *item, *item_next; for (cachelib = main->cache_library.first; cachelib; cachelib = cachelib->id.next) { if (cachelib->id.flag & LIB_NEED_LINK) { @@ -1948,8 +1949,13 @@ static void lib_link_cache_library(FileData *fd, Main *main) cachelib->group = newlibadr_us(fd, cachelib->id.lib, cachelib->group); - for (item = cachelib->items.first; item; item = item->next) { + for (item = cachelib->items.first; item; item = item_next) { + item_next = item->next; + item->ob = newlibadr(fd, cachelib->id.lib, item->ob); + + if (!item->ob) + BKE_cache_library_remove_item(cachelib, item); } } } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs