[Bf-blender-cvs] [f8a043a] fracture_modifier: another fix attempt for rotational anomalies

Martin Felke noreply at git.blender.org
Wed Oct 12 01:35:19 CEST 2016


Commit: f8a043a10685984d09054d0818c7d3080d38f5e4
Author: Martin Felke
Date:   Wed Oct 12 01:23:07 2016 +0200
Branches: fracture_modifier
https://developer.blender.org/rBf8a043a10685984d09054d0818c7d3080d38f5e4

another fix attempt for rotational anomalies

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

M	source/blender/blenkernel/intern/fracture.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 af342d5..70a4306 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -2096,6 +2096,7 @@ void BKE_match_vertex_coords(MeshIsland* mi, MeshIsland *par, Object *ob, int fr
 	float mat[4][4];
 	float quat[4] = {1.0f, 0.0f, 0.0f, 0.0f};
 	float qrot[4] = {1.0f, 0.0f, 0.0f, 0.0f};
+	float iquat[4] =  {1.0f, 0.0f, 0.0f, 0.0f};
 
 	int val = shards_to_islands ? -1 : 0;
 
@@ -2111,24 +2112,25 @@ void BKE_match_vertex_coords(MeshIsland* mi, MeshIsland *par, Object *ob, int fr
 	mi->rots[3] = rot[3] = par->rots[4*frame+3];
 
 	mul_m4_v3(mat, loc);
-	mat4_to_quat(quat, mat);
+	mat4_to_quat(quat, ob->obmat);
+	invert_qt_qt(iquat, quat);
 
-
-	if (par->id > val)
+	if (par->id == val)
 	{
-		mul_qt_qtqt(qrot, rot, par->rot);
+		invert_qt_qt(qrot, par->rot);
+		mul_qt_qtqt(qrot, rot, qrot);
 		mul_qt_qtqt(qrot, quat, qrot);
 	}
 	else
 	{
-		invert_qt_qt(qrot, par->rot);
-		mul_qt_qtqt(qrot, rot, qrot);
+		mul_qt_qtqt(qrot, rot, par->rot);
+		mul_qt_qtqt(qrot, iquat, qrot);
 	}
 
 	if (is_parent)
 	{
 		copy_v3_v3(centr, mi->centroid);
-		//mul_qt_v3(qrot, centr);
+		mul_qt_v3(qrot, centr);
 		add_v3_v3(centr, loc);
 	}
 	else
@@ -2144,7 +2146,7 @@ void BKE_match_vertex_coords(MeshIsland* mi, MeshIsland *par, Object *ob, int fr
 		copy_v3_v3(co, mi->vertices_cached[j]->co);
 
 		sub_v3_v3(co, mi->centroid);
-		//mul_qt_v3(qrot, co);
+		mul_qt_v3(qrot, co);
 		add_v3_v3(co, centr);
 
 		copy_v3_v3(mi->vertices_cached[j]->co, co);
@@ -2153,7 +2155,7 @@ void BKE_match_vertex_coords(MeshIsland* mi, MeshIsland *par, Object *ob, int fr
 		mi->vertco[3*j+1] = co[1];
 		mi->vertco[3*j+2] = co[2];
 	}
-#if 0
+
 	{
 		DerivedMesh *dm = mi->physics_mesh;
 		MVert* mv, *mvert = dm->getVertArray(dm);
@@ -2166,7 +2168,6 @@ void BKE_match_vertex_coords(MeshIsland* mi, MeshIsland *par, Object *ob, int fr
 			mul_qt_v3(qrot, mv->co);
 		}
 	}
-#endif
 
 	//init rigidbody properly ?
 	copy_v3_v3(mi->centroid, centr);
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 03f281f..ebf8270 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -2024,8 +2024,9 @@ static float do_setup_meshisland(FractureModifierData *fmd, Object *ob, int totv
 	do_fix_normals(fmd, mi);
 
 	copy_v3_v3(mi->centroid, centroid);
-	mat4_to_loc_quat(dummyloc, rot, ob->obmat);
-	copy_qt_qt(mi->rot, rot);
+	//mat4_to_loc_quat(dummyloc, rot, ob->obmat);
+	//copy_qt_qt(mi->rot, rot);
+	unit_qt(mi->rot);
 	mi->bb = BKE_boundbox_alloc_unit();
 	BKE_boundbox_init_from_minmax(mi->bb, min, max);
 	mi->participating_constraints = NULL;
@@ -3369,8 +3370,9 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
 	BKE_shard_calc_minmax(s);
 	copy_v3_v3(mi->centroid, s->centroid);
 
-	mat4_to_loc_quat(dummyloc, rot, ob->obmat);
-	copy_qt_qt(mi->rot, rot);
+	//mat4_to_loc_quat(dummyloc, rot, ob->obmat);
+	//copy_qt_qt(mi->rot, rot);
+	unit_qt(mi->rot);
 	mi->id = s->shard_id;
 	BLI_snprintf(mi->name, 64, "%d", mi->id);




More information about the Bf-blender-cvs mailing list