[Bf-blender-cvs] [b25b4c550eb] fracture_modifier: use areabased centroid calculation again for shards + small fix in loading routine

Martin Felke noreply at git.blender.org
Tue Aug 22 14:48:40 CEST 2017


Commit: b25b4c550eb3b3a94e29b131189ca65bd397be0c
Author: Martin Felke
Date:   Tue Aug 22 14:48:24 2017 +0200
Branches: fracture_modifier
https://developer.blender.org/rBb25b4c550eb3b3a94e29b131189ca65bd397be0c

use areabased centroid calculation again for shards + small fix in loading routine

new volumebased method gave incorrect results with nonmanifolds

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

M	source/blender/blenkernel/intern/fracture.c
M	source/blender/blenkernel/intern/fracture_util.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index 61fc9679a6e..b0cc6af9fcf 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -561,7 +561,7 @@ Shard *BKE_create_fracture_shard(MVert *mvert, MPoly *mpoly, MLoop *mloop, MEdge
 	shard->flag = SHARD_INTACT;
 	BKE_shard_calc_minmax(shard);
 
-	BKE_fracture_shard_center_centroid(shard, shard->centroid);
+	BKE_fracture_shard_center_centroid_area(shard, shard->centroid);
 	copy_v3_v3(shard->raw_centroid, shard->centroid);
 	zero_v3(shard->impact_loc);
 	shard->impact_size[0] = 1.0f;
diff --git a/source/blender/blenkernel/intern/fracture_util.c b/source/blender/blenkernel/intern/fracture_util.c
index eca33896a36..f0d6e58ecc7 100644
--- a/source/blender/blenkernel/intern/fracture_util.c
+++ b/source/blender/blenkernel/intern/fracture_util.c
@@ -339,7 +339,7 @@ static bool do_other_output(DerivedMesh** other_dm, Shard** other, DerivedMesh**
 		output_s->neighbor_ids = MEM_mallocN(sizeof(int) * child->neighbor_count, __func__);
 		memcpy(output_s->neighbor_ids, child->neighbor_ids, sizeof(int) * child->neighbor_count);
 	#endif
-		BKE_fracture_shard_center_centroid(*other, (*other)->centroid);
+		BKE_fracture_shard_center_centroid_area(*other, (*other)->centroid);
 
 		/* free the temp derivedmesh */
 		(*other_dm)->needsFree = 1;
@@ -401,7 +401,7 @@ static Shard *do_output_shard_dm(DerivedMesh** output_dm, Shard *child, int num_
 		output_s->raw_volume = child->raw_volume;
 	}
 
-	BKE_fracture_shard_center_centroid(output_s, output_s->centroid);
+	BKE_fracture_shard_center_centroid_area(output_s, output_s->centroid);
 
 	/* free the temp derivedmesh */
 	(*output_dm)->needsFree = 1;
@@ -687,7 +687,7 @@ static Shard *do_output_shard(BMesh* bm_parent, Shard *child, char uv_layer[64])
 		output_s->neighbor_count = child->neighbor_count;
 		output_s->neighbor_ids = MEM_mallocN(sizeof(int) * child->neighbor_count, __func__);
 		memcpy(output_s->neighbor_ids, child->neighbor_ids, sizeof(int) * child->neighbor_count);
-		BKE_fracture_shard_center_centroid(output_s, output_s->centroid);
+		BKE_fracture_shard_center_centroid_area(output_s, output_s->centroid);
 		copy_v3_v3(output_s->raw_centroid, child->raw_centroid);
 		output_s->raw_volume = child->raw_volume;
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 414b515ac71..482ecec8d93 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5468,7 +5468,7 @@ static void load_fracture_modifier(FileData* fd, FractureModifierData *fmd)
 			for (mi = fmd->meshIslands.first; mi; mi = mi->next) {
 				Shard *sh = NULL;
 				sh = shards[i]; //skip "empty" shards
-				while (sh->shard_id < mi->id)
+				while (sh && (sh->shard_id < mi->id))
 				{
 					if (sh->next) {
 						sh = sh->next;



More information about the Bf-blender-cvs mailing list