[Bf-blender-cvs] [0d27ecd] fracture_modifier: hrm, now somethings with caching is broken... need to investigate

Martin Felke noreply at git.blender.org
Mon Jun 1 21:29:24 CEST 2015


Commit: 0d27ecdc04d9997ae17f230bd28a7f4735217f98
Author: Martin Felke
Date:   Tue May 19 16:35:45 2015 +0200
Branches: fracture_modifier
https://developer.blender.org/rB0d27ecdc04d9997ae17f230bd28a7f4735217f98

hrm, now somethings with caching is broken... need to investigate

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

M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 8f117ed..95d1adb 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -697,7 +697,6 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 	fm->shard_count = 0; /* may be not matching with expected shards, so reset... did increment this for
 	                      *progressbar only */
 
-#if 0
 	if (mode == MOD_FRACTURE_DYNAMIC)
 	{
 		Shard *t;
@@ -721,6 +720,8 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 			}
 		}
 	}
+
+#if 0
 	//keep empty ids... need to catch this later
 	if (mode == MOD_FRACTURE_DYNAMIC)
 	{
@@ -732,17 +733,15 @@ static void parse_cells(cell *cells, int expected_shards, ShardID parent_id, Fra
 	}
 #endif
 
-	//j = 0;
-
+	j = 0;
 	for (i = 0; i < expected_shards; i++) {
 		Shard *s = tempresults[i];
 		Shard *t = tempshards[i];
 
 		if (s != NULL) {
 			add_shard(fm, s, mat);
-			//s->shard_id += j;
-			//s->parent_id = parent_id;
-			//j++;
+			s->shard_id = j;
+			j++;
 		}
 
 		if (t != NULL) {
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index e26ada5..991e858 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1821,13 +1821,9 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 static bool check_shard_size(FractureModifierData *fmd, int id)
 {
 	FractureID *fid;
-	float size = 0.1f;
-	//Shard *s = BLI_findlink(&fmd->frac_mesh->shard_map, id);
+	float size = 0.01f;
+	Shard *s = BLI_findlink(&fmd->frac_mesh->shard_map, id);
 
-	return true;
-#if 0
-
-	printf("FRACTURE : %d\n", id);
 	if (s == NULL || s->flag & SHARD_FRACTURED)
 	{
 		return false;
@@ -1842,6 +1838,7 @@ static bool check_shard_size(FractureModifierData *fmd, int id)
 		return false;
 	}
 
+#if 0
 	for (fid = fmd->fracture_ids.first; fid; fid = fid->next)
 	{
 		if (fid->shardID == id)
@@ -1849,9 +1846,11 @@ static bool check_shard_size(FractureModifierData *fmd, int id)
 			return false;
 		}
 	}
+#endif
+
+	printf("FRACTURE : %d\n", id);
 
 	return true;
-#endif
 }
 
 static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
@@ -1883,7 +1882,7 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
 
 		if (fmd1 && fmd1->fracture_mode == MOD_FRACTURE_DYNAMIC) {
 			if (force > fmd1->dynamic_force) {
-				//if (fmd1->current_shard_entry && fmd1->current_shard_entry->is_new)
+				if (fmd1->current_shard_entry && fmd1->current_shard_entry->is_new)
 				{
 					/*only fracture on new entries, this is necessary because after loading a file
 					 *the pointcache thinks it is empty and a fracture is attempted ! */
@@ -1909,7 +1908,7 @@ static void check_fracture(rbContactPoint* cp, RigidBodyWorld *rbw)
 
 		if (fmd2 && fmd2->fracture_mode == MOD_FRACTURE_DYNAMIC) {
 			if (force > fmd2->dynamic_force){
-				//if (fmd2->current_shard_entry && fmd2->current_shard_entry->is_new)
+				if (fmd2->current_shard_entry && fmd2->current_shard_entry->is_new)
 				{
 					int id = rbw->cache_index_map[linear_index2]->meshisland_index;
 					if(check_shard_size(fmd2, id))
@@ -2554,7 +2553,7 @@ static void rigidbody_update_ob_array(RigidBodyWorld *rbw)
 			if (md->type == eModifierType_Fracture) {
 				rmd = (FractureModifierData *)md;
 				if (isModifierActive(rmd)) {
-					for (mi = rmd->meshIslands.first; mi; mi = mi->next) {
+					for (mi = rmd->meshIslands.first; j = 0, mi; mi = mi->next) {
 						rbw->cache_index_map[counter] = mi->rigidbody; /* map all shards of an object to this object index*/
 						rbw->cache_offset_map[counter] = i;
 						mi->linear_index = counter;
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index b319e22..0748609 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -99,8 +99,8 @@ static FracMesh* copy_fracmesh(FracMesh* fm)
 	for (s = fm->shard_map.first; s; s = s->next)
 	{
 		t = BKE_create_fracture_shard(s->mvert, s->mpoly, s->mloop, s->totvert, s->totpoly, s->totloop, true);
-		t->parent_id = s->shard_id;
-		t->shard_id = i;
+		t->parent_id = s->parent_id;
+		t->shard_id = s->shard_id;
 
 		CustomData_reset(&t->vertData);
 		CustomData_reset(&t->loopData);
@@ -2801,7 +2801,7 @@ static void do_match_vertex_coords(MeshIsland* mi, MeshIsland *par, Object *ob,
 	//mul_qt_qtqt(rot, irot, rot);
 
 	add_v3_v3(mi->centroid, loc);
-	mul_qt_qtqt(mi->rot, mi->rot, rot);
+	//mul_qt_qtqt(mi->rot, mi->rot, rot);
 
 	//match vertices and vertco, perhaps vertno too, yuck...
 	for (j = 0; j < mi->vertex_count; j++)
@@ -2921,13 +2921,13 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
 		{
 			MeshIsland *par = NULL;
 			int frame = prev->frame;
-			par = BLI_findlink(&prev->meshIslands, s->parent_id);
+			par = BLI_findlink(&prev->meshIslands, s->shard_id);
 
 			if (par)
 			{
 				do_handle_parent_mi(fmd, mi, par, ob, frame);
 			}
-			else
+			/*else
 			{
 				printf("PAR NULL !!! %d %d \n", s->shard_id, s->parent_id);
 				par = BLI_findlink(&prev->meshIslands, s->shard_id);
@@ -2939,7 +2939,7 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
 				{
 					printf("PAR NULL AGAIN !!! %d %d \n", s->shard_id, s->parent_id);
 				}
-			}
+			}*/
 		}
 	}
 
@@ -3530,7 +3530,6 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
 {
 	if (fmd->refresh || fmd->modifier.scene->rigidbody_world->refresh_modifiers)
 	{
-		fmd->modifier.scene->rigidbody_world->refresh_modifiers = false;
 		if (fmd->last_frame == INT_MAX)
 		{
 			//data purge hack
@@ -3620,8 +3619,8 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
 				fmd->modifier.scene->rigidbody_world->object_changed = true;
 			}
 		}
-		else if ((fmd->last_frame < frame) && (fmd->current_mi_entry) && (fmd->current_mi_entry->next != NULL) &&
-		         (fmd->current_mi_entry->next->is_new == false))
+		else if ((fmd->last_frame < frame) && (fmd->current_mi_entry) && (fmd->current_mi_entry->next != NULL))// &&
+		         /*(fmd->current_mi_entry->next->is_new == false))*/
 		{
 			/*forward playback*/
 			if (frame >= fmd->current_mi_entry->frame)
@@ -3651,6 +3650,11 @@ static void do_modifier(FractureModifierData *fmd, Object *ob, DerivedMesh *dm)
 				fmd->refresh = true;
 				fmd->current_shard_entry->is_new = false;
 			}
+			else if (fmd->modifier.scene->rigidbody_world->refresh_modifiers)
+			{
+				fmd->modifier.scene->rigidbody_world->refresh_modifiers = false;
+				fmd->refresh = true;
+			}
 		}
 
 		fmd->last_frame = (int)frame;




More information about the Bf-blender-cvs mailing list