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/editors/physics/rigidbody_object.c | 38 +---------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'source/blender/editors/physics') diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index ed6d31dfd9b..aa323dc53eb 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -86,43 +86,7 @@ static bool ED_operator_rigidbody_add_poll(bContext *C) bool ED_rigidbody_object_add(Main *bmain, Scene *scene, Object *ob, int type, ReportList *reports) { - RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); - - if (ob->type != OB_MESH) { - BKE_report(reports, RPT_ERROR, "Can't add Rigid Body to non mesh object"); - return false; - } - - /* Add rigid body world and group if they don't exist for convenience */ - if (rbw == NULL) { - rbw = BKE_rigidbody_create_world(scene); - if (rbw == NULL) { - BKE_report(reports, RPT_ERROR, "Can't create Rigid Body world"); - return false; - } - BKE_rigidbody_validate_sim_world(scene, rbw, false); - scene->rigidbody_world = rbw; - } - if (rbw->group == NULL) { - rbw->group = BKE_collection_add(bmain, NULL, "RigidBodyWorld"); - id_fake_user_set(&rbw->group->id); - } - - /* make rigidbody object settings */ - if (ob->rigidbody_object == NULL) { - ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type); - } - ob->rigidbody_object->type = type; - ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE; - - /* add object to rigid body group */ - BKE_collection_object_add(bmain, rbw->group, ob); - - DEG_relations_tag_update(bmain); - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); - DEG_id_tag_update(&rbw->group->id, ID_RECALC_COPY_ON_WRITE); - - return true; + return BKE_rigidbody_add_object(bmain, scene, ob, type, reports); } void ED_rigidbody_object_remove(Main *bmain, Scene *scene, Object *ob) -- cgit v1.2.3