Commit: 270562fe125d6902dc44aa55227125d874cd2c49
Author: Bastien Montagne
Date:   Tue Oct 8 11:51:57 2019 +0200
Branches: master
https://developer.blender.org/rB270562fe125d6902dc44aa55227125d874cd2c49

Fix T70588: Playing animation (after deleting rigid body obj) crashes blender.

Fixing/working around another weakness of current RBW model... This is
not really nice, but it should work for now, and we cannot really do
anything else but that kind of monkey patching here anyway.

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

M       source/blender/blenkernel/intern/rigidbody.c

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index c7a5104619b..589e910e91c 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -174,13 +174,22 @@ void BKE_rigidbody_free_object(Object *ob, RigidBodyWorld 
*rbw)
   /* free physics references */
   if (is_orig) {
     if (rbo->shared->physics_object) {
-      BLI_assert(rbw);
-      if (rbw) {
+      if (rbw != NULL) {
         /* We can only remove the body from the world if the world is known.
          * The world is generally only unknown if it's an evaluated copy of
          * an object that's being freed, in which case this code isn't run 
anyway. */
         RB_dworld_remove_body(rbw->shared->physics_world, 
rbo->shared->physics_object);
       }
+      else {
+        /* We have no access to 'owner' RBW when deleting the object ID 
itself... No choice bu to
+         * loop over all scenes then. */
+        for (Scene *scene = G_MAIN->scenes.first; scene != NULL; scene = 
scene->id.next) {
+          RigidBodyWorld *scene_rbw = scene->rigidbody_world;
+          if (scene_rbw != NULL) {
+            RB_dworld_remove_body(scene_rbw->shared->physics_world, 
rbo->shared->physics_object);
+          }
+        }
+      }
 
       RB_body_delete(rbo->shared->physics_object);
       rbo->shared->physics_object = NULL;

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

Reply via email to