Commit: e3e29cad3e6deb14c51ea1f726d37b5dfe90a459 Author: Martin Felke Date: Fri Aug 10 00:44:54 2018 +0200 Branches: temp-fracture-modifier-2.8 https://developer.blender.org/rBe3e29cad3e6deb14c51ea1f726d37b5dfe90a459
cheap "storage" solution for now, just recreate on load =================================================================== M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/writefile.c M source/blender/modifiers/intern/MOD_fracture.c =================================================================== diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ff14caa0b9d..d72dbff65f8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -132,7 +132,6 @@ #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_fcurve.h" -#include "BKE_fracture.h" #include "BKE_global.h" // for G #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" @@ -183,8 +182,6 @@ #include <errno.h> -#include "BKE_cdderivedmesh.h" //for fracture meshisland handling - /** * READ * ==== @@ -1989,7 +1986,7 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname) typedef void (*link_list_cb)(FileData *fd, void *data); -static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback, bool increase_lasthit) /* only direct data */ +static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* only direct data */ { Link *ln, *prev; @@ -2002,7 +1999,7 @@ static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback, bool ln = lb->first; prev = NULL; while (ln) { - ln->next = newdataadr_ex(fd, ln->next, increase_lasthit); + ln->next = newdataadr(fd, ln->next); if (ln->next != NULL && callback != NULL) { callback(fd, ln->next); } @@ -2015,7 +2012,7 @@ static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback, bool static void link_list(FileData *fd, ListBase *lb) /* only direct data */ { - link_list_ex(fd, lb, NULL, true); + link_list_ex(fd, lb, NULL); } static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */ @@ -2324,7 +2321,7 @@ static void direct_link_id_override_property_cb(FileData *fd, void *data) IDOverrideStaticProperty *op = data; op->rna_path = newdataadr(fd, op->rna_path); - link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb, true); + link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb); } static void direct_link_id(FileData *fd, ID *id) @@ -2344,7 +2341,7 @@ static void direct_link_id(FileData *fd, ID *id) /* Link direct data of overrides. */ if (id->override_static) { id->override_static = newdataadr(fd, id->override_static); - link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb, true); + link_list_ex(fd, &id->override_static->properties, direct_link_id_override_property_cb); } DrawDataList *drawdata = DRW_drawdatalist_from_id(id); @@ -4250,7 +4247,7 @@ static void direct_link_pointcache_cb(FileData *fd, void *data) static void direct_link_pointcache(FileData *fd, PointCache *cache) { if ((cache->flag & PTCACHE_DISK_CACHE)==0) { - link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb, true); + link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb); } else BLI_listbase_clear(&cache->mem_cache); @@ -4678,50 +4675,6 @@ static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask * } } -/* used with fracture modifier */ -static void direct_link_customdata_fracture(FileData *fd, CustomData *data, int count) -{ - /*need to load the dverts here for fracture, so handle this in a special function, normally - *the dverts arent loaded here, for what reason ever.... */ - - int i = 0; - - data->layers = newdataadr(fd, data->layers); - - /* annoying workaround for bug [#31079] loading legacy files with - * no polygons _but_ have stale customdata */ - if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) { - CustomData_reset(data); - return; - } - - data->external = newdataadr(fd, data->external); - - while (i < data->totlayer) { - CustomDataLayer *layer = &data->layers[i]; - - if (layer->flag & CD_FLAG_EXTERNAL) - layer->flag &= ~CD_FLAG_IN_MEMORY; - - layer->flag &= ~CD_FLAG_NOFREE; - - if (CustomData_verify_versions(data, i)) { - layer->data = newdataadr(fd, layer->data); - if (layer->type == CD_MDISPS) - direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL); - else if (layer->type == CD_GRID_PAINT_MASK) - direct_link_grid_paint_mask(fd, count, layer->data); - else if (layer->type == CD_MDEFORMVERT) { - /* layer types that allocate own memory need special handling */ - direct_link_dverts(fd, count, layer->data); - } - i++; - } - } - - CustomData_update_typemap(data); -} - /*this isn't really a public api function, so prototyped here*/ static void direct_link_customdata(FileData *fd, CustomData *data, int count) { @@ -5143,23 +5096,6 @@ static void direct_link_pose(FileData *fd, bPose *pose) } } -static void read_shard(FileData *fd, Shard **address ) -{ - Shard* s = *address; - s->mvert = newdataadr(fd, s->mvert); - s->mpoly = newdataadr(fd, s->mpoly); - s->mloop = newdataadr(fd, s->mloop); - s->medge = newdataadr(fd, s->medge); - - direct_link_customdata_fracture(fd, &s->vertData, s->totvert); - direct_link_customdata_fracture(fd, &s->loopData, s->totloop); - direct_link_customdata_fracture(fd, &s->polyData, s->totpoly); - direct_link_customdata_fracture(fd, &s->edgeData, s->totedge); - - s->neighbor_ids = newdataadr(fd, s->neighbor_ids); - s->cluster_colors = newdataadr(fd, s->cluster_colors); -} - static void direct_link_modifiers(FileData *fd, ListBase *lb) { ModifierData *md; @@ -5483,6 +5419,18 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } } } + else if (md->type == eModifierType_Fracture) { + FractureModifierData *fmd = (FractureModifierData *)md; + + /*No storage at all as first "cheap" solution", and re-init after load */ + fmd->shared = newdataadr(fd, fmd->shared); + + if (!fmd->shared) { + fmd->shared = MEM_callocN(sizeof(FractureModifierData_Shared), "shared"); + fmd->shared->refresh = true; + fmd->shared->reset_shards = true; + } + } } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index eb6f6c6f611..f5f16980a63 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -167,7 +167,6 @@ #include "BKE_curve.h" #include "BKE_collection.h" #include "BKE_constraint.h" -#include "BKE_fracture.h" // for writing a derivedmesh as shard #include "BKE_global.h" // for G #include "BKE_gpencil_modifier.h" #include "BKE_idcode.h" @@ -1762,7 +1761,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) if (csmd->bind_coords) { writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords); - } + } } else if (md->type == eModifierType_SurfaceDeform) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c index e312e27d337..8d28f6407f1 100644 --- a/source/blender/modifiers/intern/MOD_fracture.c +++ b/source/blender/modifiers/intern/MOD_fracture.c @@ -161,7 +161,11 @@ static void initData(ModifierData *md) fmd->use_constraint_group = false; fmd->activate_broken = false; - fmd->shared = MEM_callocN(sizeof(FractureModifierData_Shared), "FractureModifierData_Shared"); + if (!fmd->shared) { + fmd->shared = MEM_callocN(sizeof(FractureModifierData_Shared), "FractureModifierData_Shared"); + fmd->shared->refresh = true; + fmd->shared->reset_shards = true; + } } static void freeData(ModifierData *md) @@ -188,6 +192,7 @@ static void copyData(ModifierData *md, ModifierData *target, const int flag) /* This is a regular copy, and not a CoW copy for depsgraph evaluation */ trmd->shared = MEM_callocN(sizeof(FractureModifierData_Shared), "FractureModifierData_Shared"); trmd->shared->refresh = true; + trmd->shared->reset_shards = true; } modifier_copyData_generic(md, target, flag); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs