From a5ff780065bf6768811bf459953a1a1eabe989c1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 24 Jun 2019 14:57:52 +0200 Subject: Fix T63828, T62005: copy/paste or append loses rigid body object Previously settings were removed, now add to the rigid body world automatically even if it's a bit ill defined, since this is confusing for users. Fundamentally the concept of a rigid body world collection could be revised, and left only as an optional thing. --- source/blender/blenkernel/intern/library.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel/intern/library.c') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 5e54344c80e..974c6d6e0a6 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -57,6 +57,7 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_lightprobe_types.h" +#include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_speaker_types.h" @@ -2038,6 +2039,10 @@ void BKE_library_make_local(Main *bmain, id_clear_lib_data_ex(bmain, id, true); BKE_id_expand_local(bmain, id); id->tag &= ~LIB_TAG_DOIT; + + if (GS(id->name) == ID_OB) { + BKE_rigidbody_ensure_local_object(bmain, (Object *)id); + } } else { /* In this specific case, we do want to make ID local even if it has no local usage yet... @@ -2053,6 +2058,10 @@ void BKE_library_make_local(Main *bmain, } if (id->newid) { + if (GS(id->newid->name) == ID_OB) { + BKE_rigidbody_ensure_local_object(bmain, (Object *)id->newid); + } + /* Reuse already allocated LinkNode (transferring it from todo_ids to copied_ids). */ BLI_linklist_prepend_nlink(&copied_ids, id, it); } @@ -2178,25 +2187,6 @@ void BKE_library_make_local(Main *bmain, } } - /* Reset rigid body objects. */ - for (LinkNode *it = copied_ids; it; it = it->next) { - ID *id = it->link; - if (GS(id->name) == ID_OB) { - Object *ob = (Object *)id; - - /* If there was ever any rigidbody settings in the object, we reset it. */ - if (ob->rigidbody_object) { - for (Scene *scene_iter = bmain->scenes.first; scene_iter; - scene_iter = scene_iter->id.next) { - if (scene_iter->rigidbody_world) { - BKE_rigidbody_remove_object(bmain, scene_iter, ob); - } - } - BKE_rigidbody_free_object(ob, NULL); - } - } - } - #ifdef DEBUG_TIME printf("Hack: Forcefully rebuild armature object poses: Done.\n"); TIMEIT_VALUE_PRINT(make_local); -- cgit v1.2.3