[Bf-blender-cvs] [b7327017a05] fracture_modifier: fix for convert to keyframes, needs no bake and should be initialized properly after refracture
Martin Felke
noreply at git.blender.org
Wed May 31 13:41:41 CEST 2017
Commit: b7327017a05d19fc9a72427f3e9a162c85c38351
Author: Martin Felke
Date: Wed May 31 13:41:18 2017 +0200
Branches: fracture_modifier
https://developer.blender.org/rBb7327017a05d19fc9a72427f3e9a162c85c38351
fix for convert to keyframes, needs no bake and should be initialized properly after refracture
===================================================================
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/editors/object/object_modifier.c
M source/blender/modifiers/intern/MOD_fracture.c
===================================================================
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 338509453db..b42b94efea4 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -506,7 +506,7 @@ void BKE_rigidbody_update_cell(struct MeshIsland *mi, Object *ob, float loc[3],
//invert_m4_m4(ob->imat, ob->obmat);
mat4_to_size(size, ob->obmat);
- if (rmd->fracture_mode != MOD_FRACTURE_DYNAMIC && frame > -1) {
+ if (rmd->fracture_mode != MOD_FRACTURE_DYNAMIC && frame >= mi->start_frame) {
/*record only in prefracture case here, when you want to convert to keyframes*/
n = frame - mi->start_frame + 1;
x = frame - mi->start_frame;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 09ae0fb68b9..66624422637 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -3424,6 +3424,7 @@ static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
FractureModifierData* rmd = NULL;
bool convertable = false;
+#if 0
if (scene && scene->rigidbody_world)
{
PointCache* cache = NULL;
@@ -3434,6 +3435,7 @@ static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
+#endif
//if (convertable)
{
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 497b5897bec..77aad5a8b9c 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -2014,17 +2014,36 @@ static float do_setup_meshisland(FractureModifierData *fmd, Object *ob, int totv
{
MeshIsland *mi;
DerivedMesh *dm;
- float dummyloc[3], rot[4], min[3], max[3], vol = 0;
+ float min[3], max[3], vol = 0;
int i = 0;
short rb_type = RBO_TYPE_ACTIVE;
mi = MEM_callocN(sizeof(MeshIsland), "meshIsland");
+ unit_qt(mi->rot);
- if (fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED)
+ if (fmd->fracture_mode != MOD_FRACTURE_DYNAMIC)
{
+ float loc[3], rot[4], quat[4];
+
mi->locs = MEM_mallocN(sizeof(float)*3, "mi->locs");
mi->rots = MEM_mallocN(sizeof(float)*4, "mi->rots");
mi->frame_count = 0;
+
+ copy_v3_v3(loc, centroid);
+ mul_m4_v3(ob->obmat, loc);
+ mat4_to_quat(quat, ob->obmat);
+
+ copy_qt_qt(rot, mi->rot);
+ mul_qt_qtqt(rot, quat, rot);
+
+ mi->locs[0] = loc[0];
+ mi->locs[1] = loc[1];
+ mi->locs[2] = loc[2];
+
+ mi->rots[0] = rot[0];
+ mi->rots[1] = rot[1];
+ mi->rots[2] = rot[2];
+ mi->rots[3] = rot[3];
}
else
{
@@ -2078,7 +2097,7 @@ static float do_setup_meshisland(FractureModifierData *fmd, Object *ob, int totv
copy_v3_v3(mi->centroid, centroid);
//mat4_to_loc_quat(dummyloc, rot, ob->obmat);
//copy_qt_qt(mi->rot, rot);
- unit_qt(mi->rot);
+ //unit_qt(mi->rot);
mi->bb = BKE_boundbox_alloc_unit();
BKE_boundbox_init_from_minmax(mi->bb, min, max);
mi->participating_constraints = NULL;
@@ -3412,7 +3431,7 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
MeshIsland *par = NULL;
bool is_parent = false;
short rb_type = RBO_TYPE_ACTIVE;
- float dummyloc[3], rot[4];
+ //float dummyloc[3], rot[4];
if (s->totvert == 0) {
return;
@@ -3422,12 +3441,31 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
mi = MEM_callocN(sizeof(MeshIsland), "meshIsland");
BLI_addtail(&fmd->meshIslands, mi);
+ unit_qt(mi->rot);
- if (fmd->fracture_mode == MOD_FRACTURE_PREFRACTURED)
+ if (fmd->fracture_mode != MOD_FRACTURE_DYNAMIC)
{
+ float loc[3], rot[4], quat[4];
mi->locs = MEM_mallocN(sizeof(float)*3, "mi->locs");
mi->rots = MEM_mallocN(sizeof(float)*4, "mi->rots");
mi->frame_count = 0;
+
+ copy_v3_v3(loc, s->centroid);
+ mul_m4_v3(ob->obmat, loc);
+ mat4_to_quat(quat, ob->obmat);
+
+ copy_qt_qt(rot, mi->rot);
+ mul_qt_qtqt(rot, quat, rot);
+
+ mi->locs[0] = loc[0];
+ mi->locs[1] = loc[1];
+ mi->locs[2] = loc[2];
+
+ mi->rots[0] = rot[0];
+ mi->rots[1] = rot[1];
+ mi->rots[2] = rot[2];
+ mi->rots[3] = rot[3];
+
if (fmd->modifier.scene->rigidbody_world)
{
mi->start_frame = fmd->modifier.scene->rigidbody_world->pointcache->startframe;
@@ -3480,7 +3518,7 @@ static void do_island_from_shard(FractureModifierData *fmd, Object *ob, Shard* s
//mat4_to_loc_quat(dummyloc, rot, ob->obmat);
//copy_qt_qt(mi->rot, rot);
- unit_qt(mi->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