[Bf-blender-cvs] [7a197680593] temp-fracture-modifier-2.8: seems dynamic cache behavior is fixed, tests looked good .

Martin Felke noreply at git.blender.org
Thu Nov 22 22:03:48 CET 2018


Commit: 7a197680593bef7fda67fb430fd0170a7bf9810b
Author: Martin Felke
Date:   Thu Nov 22 22:03:24 2018 +0100
Branches: temp-fracture-modifier-2.8
https://developer.blender.org/rB7a197680593bef7fda67fb430fd0170a7bf9810b

seems dynamic cache behavior is fixed, tests looked good .

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

M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/fracture_prefractured.c
M	source/blender/blenkernel/intern/fracture_rigidbody.c
M	source/blender/blenkernel/intern/rigidbody.c

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

diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index d030d4a3764..c8ac80be273 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1296,14 +1296,23 @@ void BKE_fracture_copy_customdata(CustomData* src, CustomData* dst,CustomDataMas
 void BKE_fracture_clear_cache(FractureModifierData* fmd, Object* ob, Scene *scene)
 {
 	RigidBodyWorld *rbw = scene->rigidbody_world;
-	int startframe = rbw->shared->pointcache->startframe;
-	int endframe = rbw->shared->pointcache->endframe;
+	int startframe = 1;
+	int endframe = 250;
 	int frame = 0;
 	MeshIsland *mi, *next;
 
+	if (rbw && rbw->shared) {
+		startframe = rbw->shared->pointcache->startframe;
+		endframe = rbw->shared->pointcache->endframe;
+	}
+	else {
+		return;
+	}
+
 	mi = fmd->shared->mesh_islands.first;
 	while (mi) {
-		if ((fmd->shared->refresh && fmd->use_dynamic && mi->startframe > startframe) || (!fmd->use_dynamic && mi->id == 0))
+		/*delete non-initial shards on dynamic refresh, or the non-intial prefracture shards*/
+		if ((fmd->use_dynamic && mi->startframe > startframe) || (!fmd->use_dynamic && mi->id == 0))
 		{
 			next = mi->next;
 			BLI_remlink(&fmd->shared->mesh_islands, mi);
@@ -1351,13 +1360,18 @@ Mesh* BKE_fracture_assemble_mesh_from_islands(FractureModifierData* fmd, Scene *
 	Mesh *mesh = NULL;
 	int vertstart, polystart, loopstart, edgestart, num_verts, num_polys, num_loops, num_edges;
 	vertstart = polystart = loopstart = edgestart = num_verts = num_polys = num_loops = num_edges = 0;
+	RigidBodyWorld *rbw = scene->rigidbody_world;
+	int startframe = 1;
+
+	if (rbw && rbw->shared)
+		startframe = rbw->shared->pointcache->startframe;
 
 	for (mi = fmd->shared->mesh_islands.first; mi; mi = mi->next)
 	{
 		RigidBodyOb *rbo = mi->rigidbody;
 
 		if (BKE_fracture_meshisland_check_frame(fmd, mi, (int)ctime)) {
-			if (scene && mi->rigidbody->shared->physics_object) {
+			if (scene && mi->rigidbody->shared->physics_object && (mi->startframe <= (int)ctime)) {
 				BKE_rigidbody_remove_shard(scene, mi);
 				mi->rigidbody->shared->physics_object = NULL;
 			}
diff --git a/source/blender/blenkernel/intern/fracture_prefractured.c b/source/blender/blenkernel/intern/fracture_prefractured.c
index 4dca334ed2c..51d15bc1027 100644
--- a/source/blender/blenkernel/intern/fracture_prefractured.c
+++ b/source/blender/blenkernel/intern/fracture_prefractured.c
@@ -198,7 +198,8 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
 		/*free old stuff here */
 		BKE_fracture_constraints_free(fmd, scene);
 
-		if ((fmd->dm_group || !fmd->shared->refresh))
+		/*keep shards at packing and at dynamic refresh */
+		if (fmd->dm_group)
 		{
 			if (!handle_initial_shards(fmd, ob, depsgraph, bmain, scene, frame))
 			{
@@ -206,7 +207,10 @@ Mesh* BKE_fracture_apply(FractureModifierData *fmd, Object *ob, Mesh *me_orig, D
 			}
 		}
 		else {
-			do_initial_prefracture(fmd, ob, depsgraph, bmain, scene, frame, me);
+			if (BLI_listbase_is_empty(&fmd->shared->mesh_islands) || !fmd->use_dynamic) {
+				/*rebuild shards after loading and prefracture refresh*/
+				do_initial_prefracture(fmd, ob, depsgraph, bmain, scene, frame, me);
+			}
 		}
 
 		fmd->shared->refresh_constraints = true;
diff --git a/source/blender/blenkernel/intern/fracture_rigidbody.c b/source/blender/blenkernel/intern/fracture_rigidbody.c
index e81c65036f5..3318c03e74b 100644
--- a/source/blender/blenkernel/intern/fracture_rigidbody.c
+++ b/source/blender/blenkernel/intern/fracture_rigidbody.c
@@ -607,12 +607,6 @@ void BKE_rigidbody_validate_sim_shard(RigidBodyWorld *rbw, MeshIsland *mi, Objec
 			RB_dworld_remove_body(rbw->shared->physics_world, rbo->shared->physics_object);
 	}
 
-#if 0
-	if (BKE_fracture_meshisland_check_frame(fmd, mi, (int)ctime)) {
-		return;
-	}
-#endif
-
 	if (!rbo->shared->physics_object || rebuild /*|| (fmd->use_animated_mesh && fmd->anim_mesh_ob)*/) {
 		float size[3];
 
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index eb8a2fb01aa..384f92ff72f 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -2070,10 +2070,10 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
 		}
 	}
 
-	//if we destroy the cache, also reset dynamic data (if not baked)
-	if ((frame == startframe) && (rbw->ltime == startframe) && !(cache->flag & PTCACHE_BAKED))
+	//if we destroy the cache, also reset dynamic data (if not baked, when jumping back)
+	if ((frame == startframe && rbw->ltime == frame) && !(cache->flag & PTCACHE_BAKED))
 	{
-		//BKE_rigidbody_cache_reset(scene);
+		BKE_rigidbody_cache_reset(scene);
 	}
 }



More information about the Bf-blender-cvs mailing list