[Bf-blender-cvs] [a7706b3] alembic_pointcache: Removed current implementation of cache reading from various parts of BKE (DerivedMesh, particles, cloth).

Lukas Tönne noreply at git.blender.org
Thu Mar 12 12:24:04 CET 2015


Commit: a7706b3642679629a418d0688d570737266f2559
Author: Lukas Tönne
Date:   Wed Mar 11 13:38:11 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBa7706b3642679629a418d0688d570737266f2559

Removed current implementation of cache reading from various parts of
BKE (DerivedMesh, particles, cloth).

The new cache implementation will be used for constructing dupli data
instead, bypassing the complexities of the modifier stack.

===================================================================

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/BKE_pointcache.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_legacy.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_cloth.c
M	source/blender/pointcache/intern/export.cpp

===================================================================

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index c473dc4..0425164 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -659,8 +659,6 @@ DMCoNo *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
 #endif
 void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int totcos);
 
-struct ModifierData *mesh_find_cache_modifier(struct Scene *scene, struct Object *ob, int required_mode);
-
 /* */
 DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,
                                     CustomDataMask dataMask);
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 89f1f8a..a7fad85 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -232,7 +232,7 @@ void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
 void cloth_free_modifier_extern (struct ClothModifierData *clmd );
 void cloth_free_modifier (struct ClothModifierData *clmd );
 void cloth_init (struct ClothModifierData *clmd );
-void clothModifier_do (struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], bool use_render);
+void clothModifier_do (struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
 
 int cloth_uses_vgroup(struct ClothModifierData *clmd);
 
@@ -240,6 +240,9 @@ int cloth_uses_vgroup(struct ClothModifierData *clmd);
 void bvhtree_update_from_cloth (struct ClothModifierData *clmd, int moving );
 void bvhselftree_update_from_cloth (struct ClothModifierData *clmd, int moving );
 
+// needed for button_object.c
+void cloth_clear_cache (struct Object *ob, struct ClothModifierData *clmd, float framenr );
+
 // needed for cloth.c
 int cloth_add_spring (struct ClothModifierData *clmd, unsigned int indexA, unsigned int indexB, float restlength, int spring_type);
 
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index cf0513d..e18e9d4 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -260,6 +260,7 @@ void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **da
 /**************** Creating ID's ****************************/
 void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb);
 void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
+void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd);
 void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
 void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, struct Object *ob, struct DynamicPaintSurface *surface);
 void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, struct Object *ob, struct RigidBodyWorld *rbw);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index ec22dd4..870b020 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -49,7 +49,6 @@
 #include "BLI_utildefines.h"
 #include "BLI_linklist.h"
 
-#include "BKE_cache_library.h"
 #include "BKE_cdderivedmesh.h"
 #include "BKE_editmesh.h"
 #include "BKE_key.h"
@@ -66,8 +65,6 @@
 #include "BKE_deform.h"
 #include "BKE_global.h" /* For debug flag, DM_update_tessface_data() func. */
 
-#include "PTC_api.h"
-
 #ifdef WITH_GAMEENGINE
 #include "BKE_navmesh_conversion.h"
 static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
@@ -1464,45 +1461,6 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
 		CDDM_calc_normals_mapping_ex(dm, (dm->dirty & DM_DIRTY_NORMALS) ? false : true);
 	}
 }
-
-/* Look for last active cache modifier.
- * This will then be used as the input for remaining modifiers,
- * or as the final result if no other modifiers follow.
- */
-ModifierData *mesh_find_cache_modifier(Scene *scene, Object *ob, int required_mode)
-{
-	ModifierData *md;
-	
-	for (md = ob->modifiers.last; md; md = md->prev) {
-		if (md->type == eModifierType_Cache) {
-			if (modifier_isEnabled(scene, md, required_mode))
-				break;
-		}
-	}
-	return md;
-}
-
-static ModifierData *mesh_find_start_modifier(Scene *UNUSED(scene), Object *ob, VirtualModifierData *virtual_modifiers, int UNUSED(required_mode), bool useDeform)
-{
-	const bool skipVirtualArmature = (useDeform < 0);
-	
-	ModifierData *md = NULL;
-	
-	/* take virtual modifiers at list start into account */
-	
-	if (!skipVirtualArmature) {
-		md = modifiers_getVirtualModifierList(ob, virtual_modifiers);
-	}
-	else {
-		/* game engine exception */
-		md = ob->modifiers.first;
-		if (md && md->type == eModifierType_Armature)
-			md = md->next;
-	}
-	
-	return md;
-}
-
 /* new value for useDeform -1  (hack for the gameengine):
  * - apply only the modifier stack of the object, skipping the virtual modifiers,
  * - don't apply the key
@@ -1520,10 +1478,11 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 	/* XXX Always copying POLYINDEX, else tessellated data are no more valid! */
 	CustomDataMask mask, nextmask, previewmask = 0, append_mask = CD_MASK_ORIGINDEX;
 	float (*deformedVerts)[3] = NULL;
-	DerivedMesh *dm = NULL, *cachedm = NULL, *orcodm, *clothorcodm, *finaldm;
+	DerivedMesh *dm = NULL, *orcodm, *clothorcodm, *finaldm;
 	int numVerts = me->totvert;
-	int required_mode, cache_eval_mode;
+	int required_mode;
 	bool isPrevDeform = false;
+	const bool skipVirtualArmature = (useDeform < 0);
 	MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
 	const bool has_multires = (mmd && mmd->sculptlvl != 0);
 	bool multires_applied = false;
@@ -1552,42 +1511,24 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 		app_flags |= MOD_APPLY_USECACHE;
 	if (useDeform)
 		deform_app_flags |= MOD_APPLY_USECACHE;
-	
-	if (useRenderParams) {
-		required_mode = eModifierMode_Render;
-		cache_eval_mode = CACHE_LIBRARY_EVAL_RENDER;
-	}
-	else {
-		required_mode = eModifierMode_Realtime;
-		cache_eval_mode = CACHE_LIBRARY_EVAL_VIEWPORT;
-	}
-	
-	modifiers_clearErrors(ob);
-	
-	/* XXX it would be nicer to treat caching as a virtual modifier (when no actual cache modifier is used).
-	 * However, the virtual modifiers work by setting their own 'next' pointers without touching actual
-	 * modifier DNA. This is possible only for prepending at the beginning, but not for appending
-	 * at the end of the modifier stack.
-	 */
-	if (BKE_cache_read_derived_mesh(G.main, scene, scene->r.cfra, cache_eval_mode, ob, &cachedm)) {
-		CacheModifierData *cmd = (CacheModifierData *)mesh_find_cache_modifier(scene, ob, required_mode);
-		if (cmd) {
-			firstmd = &cmd->modifier;
-			
-			/* use the cache result as output of the modifier
-			 * rather than as the final dm
-			 */
-			cmd->input_dm = cachedm;
-			cachedm = NULL;
-		}
-		else
-			firstmd = NULL;
+
+	if (!skipVirtualArmature) {
+		firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
 	}
 	else {
-		firstmd = mesh_find_start_modifier(scene, ob, &virtualModifierData, required_mode, useDeform);
+		/* game engine exception */
+		firstmd = ob->modifiers.first;
+		if (firstmd && firstmd->type == eModifierType_Armature)
+			firstmd = firstmd->next;
 	}
+
 	md = firstmd;
 
+	modifiers_clearErrors(ob);
+
+	if (useRenderParams) required_mode = eModifierMode_Render;
+	else required_mode = eModifierMode_Realtime;
+
 	if (do_mod_wmcol || do_mod_mcol) {
 		/* Find the last active modifier generating a preview, or NULL if none. */
 		/* XXX Currently, DPaint modifier just ignores this.
@@ -1913,17 +1854,11 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 	for (md = firstmd; md; md = md->next)
 		modifier_freeTemporaryData(md);
 
-	/* Yay, we are done.
-	 * - If we have a cached DerivedMesh, use it
-	 * - If we have a DerivedMesh and deformed vertices
-	 *   need to apply these back onto the DerivedMesh.
-	 * - If we have no DerivedMesh then we need to build one.
+	/* Yay, we are done. If we have a DerivedMesh and deformed vertices
+	 * need to apply these back onto the DerivedMesh. If we have no
+	 * DerivedMesh then we need to build one.
 	 */
-	if (cachedm) {
-		finaldm = cachedm;
-		cachedm = NULL;
-	}
-	else if (dm && deformedVerts) {
+	if (dm && deformedVerts) {
 		finaldm = CDDM_copy(dm);
 
 		dm->release(dm);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index c7deffb..3b3fe32 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -34,19 +34,18 @@
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
 #include "DNA_meshdata_types.h"
-#include "DNA_particle_types.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
 #include "BLI_edgehash.h"
 #include "BLI_linklist.h"
 
-#include "BKE_cache_library.h"
 #include "BKE_cdderivedmesh.h"
 #include "BKE_cloth.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_modifier.h"
+#include "BKE_pointcache.h"
 
 #include "BPH_mass_spring.h"
 
@@ -127,6 +126,9 @@ void cloth_init(ClothModifierData *clmd )
 
 	if (!clmd->sim_parms->effector_weights)
 		clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
+
+	if (clmd->point_cache)
+		clmd->point_cache->step = 1;
 }
 
 static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float epsilon)
@@ -302,16 +304,35 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving)
 	}
 }
 
+void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
+{
+	PTCacheID pid;
+	
+	BKE_ptcache_id_from_cloth(&pid, ob, clmd);
+
+	// don't do anything as long as we're in editmode!
+	if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
+		return;
+	
+	BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
+}
+
 static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
 {
+	PointC

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list