Commit: 3bc11a9cf2362d172244d3f81464b6957144fbaf
Author: Martin Felke
Date:   Sun Feb 1 18:44:44 2015 +0100
Branches: fracture_modifier
https://developer.blender.org/rB3bc11a9cf2362d172244d3f81464b6957144fbaf

fix: crasher when removing the modifier on frame > 1 and trying to rerun the 
sim , fix: crasher when reverting the file with fracture modifier on it

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

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 895d784..515bf99 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -3266,6 +3266,12 @@ void BKE_rigidbody_rebuild_world(Scene *scene, float 
ctime)
        int startframe, endframe;
        int shards = 0, objects = 0;
 
+       if (ctime == -1)
+       {
+               rigidbody_update_simulation(scene, rbw, true);
+               return;
+       }
+
        BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw);
        BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
        cache = rbw->pointcache;
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index aa8a14a..25814a1 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -284,6 +284,10 @@ static bool object_modifier_safe_to_delete(Main *bmain, 
Object *ob,
 static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
                                    bool *r_sort_depsgraph)
 {
+       /* keep some data from modifier which is necessary for the afterwards 
cleanup */
+       bool do_rigidbody_cleanup = (md->type == eModifierType_Fracture);
+       Scene *scene = md->scene;
+
        /* It seems on rapid delete it is possible to
         * get called twice on same modifier, so make
         * sure it is in list. */
@@ -335,6 +339,14 @@ static bool object_modifier_remove(Main *bmain, Object 
*ob, ModifierData *md,
        BLI_remlink(&ob->modifiers, md);
        modifier_free(md);
 
+       if (do_rigidbody_cleanup)
+       {
+               /* need to clean up modifier remainders inside the rigidbody 
world
+                * AFTER the modifier is gone...  but only from the operator ?*/
+               BKE_rigidbody_rebuild_world(scene, -1);
+               BKE_scene_frame_set(scene, 1.0);
+       }
+
        return 1;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to