diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-10-08 12:51:57 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-10-08 12:53:44 +0300 |
commit | 270562fe125d6902dc44aa55227125d874cd2c49 (patch) | |
tree | efb3132f0bbfa872fac28f09d0022471b3a32499 /source/blender/blenkernel/intern | |
parent | b1f1c8c33fabb3c03b90d101c8f9df2b5abe8740 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 13 |
1 files changed, 11 insertions, 2 deletions
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; |