[Bf-blender-cvs] [46cd930] gooseberry: Use a dedicated input_dm pointer in the cache modifier to provide a mesh result read from the cache.
Lukas Tönne
noreply at git.blender.org
Mon Mar 23 13:02:35 CET 2015
Commit: 46cd930df7222f825b0577fa8aea5608c1c5bba5
Author: Lukas Tönne
Date: Wed Mar 4 18:01:32 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB46cd930df7222f825b0577fa8aea5608c1c5bba5
Use a dedicated input_dm pointer in the cache modifier to provide a mesh
result read from the cache.
Mixing this with the output_dm used for writing leads to undefined
situations where the DM was released but should actually be passed on.
===================================================================
M source/blender/blenkernel/intern/DerivedMesh.c
M source/blender/blenloader/intern/readfile.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/modifiers/intern/MOD_cache.c
===================================================================
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 7c4ffd3..de2cfc8 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1601,7 +1601,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
/* use the cache result as output of the modifier
* rather than as the final dm
*/
- cmd->output_dm = cachedm;
+ cmd->input_dm = cachedm;
cachedm = NULL;
}
else
@@ -1944,8 +1944,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* - If we have no DerivedMesh then we need to build one.
*/
if (cachedm) {
- finaldm = CDDM_copy(cachedm);
- cachedm->release(cachedm);
+ finaldm = cachedm;
+ cachedm = NULL;
}
else if (dm && deformedVerts) {
finaldm = CDDM_copy(dm);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 47a2b1c..965afa7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4985,6 +4985,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
CacheModifierData *cmd = (CacheModifierData *)md;
cmd->output_dm = NULL;
+ cmd->input_dm = NULL;
cmd->flag &= ~(MOD_CACHE_USE_OUTPUT_REALTIME | MOD_CACHE_USE_OUTPUT_RENDER);
}
}
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index eabb929..438bcb5 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1458,7 +1458,11 @@ typedef struct CacheModifierData {
int flag;
int pad;
+ /* DM data for writing into the cache */
struct DerivedMesh *output_dm;
+
+ /* DM data read from the cache for modifier input */
+ struct DerivedMesh *input_dm;
} CacheModifierData;
typedef enum eCacheModifier_Flag {
diff --git a/source/blender/modifiers/intern/MOD_cache.c b/source/blender/modifiers/intern/MOD_cache.c
index d65b769..70b434c 100644
--- a/source/blender/modifiers/intern/MOD_cache.c
+++ b/source/blender/modifiers/intern/MOD_cache.c
@@ -63,6 +63,7 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
tpcmd->output_dm = NULL;
+ tpcmd->input_dm = NULL;
tpcmd->flag &= ~(MOD_CACHE_USE_OUTPUT_REALTIME | MOD_CACHE_USE_OUTPUT_RENDER);
}
@@ -74,6 +75,10 @@ static void freeData(ModifierData *md)
pcmd->output_dm->release(pcmd->output_dm);
pcmd->output_dm = NULL;
}
+ if (pcmd->input_dm) {
+ pcmd->input_dm->release(pcmd->input_dm);
+ pcmd->input_dm = NULL;
+ }
}
static DerivedMesh *pointcache_do(CacheModifierData *pcmd, Object *UNUSED(ob), DerivedMesh *dm, ModifierApplyFlag flag)
@@ -87,12 +92,19 @@ static DerivedMesh *pointcache_do(CacheModifierData *pcmd, Object *UNUSED(ob), D
pcmd->output_dm = CDDM_copy(dm);
}
else {
+ /* unused cache output? clean up! */
if (pcmd->output_dm) {
- dm = pcmd->output_dm;
+ pcmd->output_dm->release(pcmd->output_dm);
pcmd->output_dm = NULL;
}
}
+ if (pcmd->input_dm) {
+ /* pass on the input DM from the cache */
+ dm = pcmd->input_dm;
+ pcmd->input_dm = NULL;
+ }
+
return dm;
}
More information about the Bf-blender-cvs
mailing list