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.
This commit is contained in:
parent
b1f1c8c33f
commit
270562fe12
Notes:
blender-bot
2023-02-14 09:24:53 +01:00
Referenced by issue #70588, Playing animation (after deleting rigid body obj) crashes blender.
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue