[Bf-blender-cvs] [c93971e] fracture_modifier: fix: convert to keyframes works directly from bake now, too

Martin Felke noreply at git.blender.org
Sat Dec 27 14:40:19 CET 2014


Commit: c93971e49ec4cc0a8f81a44901b84c61f97cb486
Author: Martin Felke
Date:   Sat Dec 27 14:40:05 2014 +0100
Branches: fracture_modifier
https://developer.blender.org/rBc93971e49ec4cc0a8f81a44901b84c61f97cb486

fix: convert to keyframes works directly from bake now, too

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

M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/editors/object/object_modifier.c

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 25ea922..9238245 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1705,7 +1705,7 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 
 		if (ob1->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION)
 		{
-			bool valid = true, valid2 = true;
+			bool valid = true; //, valid2 = true;
 			fmd1 = (FractureModifierData*)modifiers_findByType(ob1, eModifierType_Fracture);
 			valid = valid && (fmd1 != NULL);
 			valid = valid && (ob1->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
@@ -1741,7 +1741,7 @@ static int filterCallback(void* world, void* island1, void* island2, void *blend
 
 		if (ob2->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION)
 		{
-			bool valid = true, valid2 = true;
+			bool valid = true; // valid2 = true;
 			fmd2 = (FractureModifierData*)modifiers_findByType(ob2, eModifierType_Fracture);
 			valid = valid && (fmd2 != NULL);
 			valid = valid && (ob2->rigidbody_object->flag & RBO_FLAG_USE_KINEMATIC_DEACTIVATION);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 9803f28..ac1b33d 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2757,18 +2757,13 @@ static bool convert_modifier_to_keyframes(FractureModifierData* fmd, Group* gr,
 	if (cache && cache->flag & PTCACHE_BAKED)
 	{
 		start = cache->startframe;
-		end = cache->simframe;
+		end = cache->endframe;
+		/* need to "fill" the rigidbody world by doing 1 sim step, else bake cant be read properly */
+		BKE_rigidbody_do_simulation(scene, (float)(start+1));
 		BKE_ptcache_id_from_rigidbody(&pid, NULL, scene->rigidbody_world);
 		is_baked = true;
 	}
 
-#if 0
-	if (cache && (cache->flag & PTCACHE_OUTDATED) /* && !(cache->flag & PTCACHE_BAKED)*/)
-	{
-		return false;
-	}
-#endif
-
 	parent = BKE_object_add_named(G.main, scene, OB_EMPTY, name);
 	BKE_mesh_center_centroid(ob->data, obloc);
 	copy_v3_v3(parent->loc, ob->loc);
@@ -2788,7 +2783,7 @@ static bool convert_modifier_to_keyframes(FractureModifierData* fmd, Group* gr,
 		{
 			fmd->frac_mesh->cancel = 0;
 			fmd->frac_mesh->running = 0;
-			return true;
+			return false;
 		}
 
 		ob_new = BKE_object_add_named(G.main, scene, OB_MESH, name);
@@ -2968,7 +2963,7 @@ static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
 	{
 		PointCache* cache = NULL;
 		cache = scene->rigidbody_world->pointcache;
-		if (cache && (cache->flag & PTCACHE_OUTDATED))
+		if (cache && (cache->flag & PTCACHE_OUTDATED) && !(cache->flag & PTCACHE_BAKED))
 		{
 			convertable = false;
 		}
@@ -3049,7 +3044,7 @@ static int rigidbody_convert_keyframes_exec(bContext *C, wmOperator *op)
 	}
 	else
 	{
-		BKE_report(op->reports, RPT_WARNING, "No valid cache data found, please run simulation first (baked ones too !)");
+		BKE_report(op->reports, RPT_WARNING, "No valid cache data found, please run or bake simulation first");
 		return OPERATOR_CANCELLED;
 	}
 }




More information about the Bf-blender-cvs mailing list