Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/rigidbody_object.c
| Show All 36 Lines | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_rigidbody.h" | #include "BKE_rigidbody.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if (rbw == NULL) { | ||||
| if (rbw == NULL) { | if (rbw == NULL) { | ||||
| BKE_report(reports, RPT_ERROR, "Can't create Rigid Body world"); | BKE_report(reports, RPT_ERROR, "Can't create Rigid Body world"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| BKE_rigidbody_validate_sim_world(scene, rbw, false); | BKE_rigidbody_validate_sim_world(scene, rbw, false); | ||||
| scene->rigidbody_world = rbw; | scene->rigidbody_world = rbw; | ||||
| } | } | ||||
| if (rbw->group == NULL) { | if (rbw->group == NULL) { | ||||
| rbw->group = BKE_group_add(bmain, "RigidBodyWorld"); | rbw->group = BKE_collection_add(bmain, NULL, "RigidBodyWorld"); | ||||
| } | } | ||||
| /* make rigidbody object settings */ | /* make rigidbody object settings */ | ||||
| if (ob->rigidbody_object == NULL) { | if (ob->rigidbody_object == NULL) { | ||||
| ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type); | ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type); | ||||
| } | } | ||||
| ob->rigidbody_object->type = type; | ob->rigidbody_object->type = type; | ||||
| ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE; | ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE; | ||||
| /* add object to rigid body group */ | /* add object to rigid body group */ | ||||
| BKE_group_object_add(rbw->group, ob); | BKE_collection_object_add(bmain, rbw->group, ob); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB); | DEG_id_tag_update(&ob->id, OB_RECALC_OB); | ||||
| return true; | return true; | ||||
| } | } | ||||
| void ED_rigidbody_object_remove(Main *bmain, Scene *scene, Object *ob) | void ED_rigidbody_object_remove(Main *bmain, Scene *scene, Object *ob) | ||||
| { | { | ||||
| RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); | RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); | ||||
| BKE_rigidbody_remove_object(scene, ob); | BKE_rigidbody_remove_object(scene, ob); | ||||
| if (rbw) | if (rbw) | ||||
| BKE_group_object_unlink(rbw->group, ob); | BKE_collection_object_remove(bmain, rbw->group, ob, false); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB); | DEG_id_tag_update(&ob->id, OB_RECALC_OB); | ||||
| } | } | ||||
| /* ********************************************** */ | /* ********************************************** */ | ||||
| /* Active Object Add/Remove Operators */ | /* Active Object Add/Remove Operators */ | ||||
| ▲ Show 20 Lines • Show All 436 Lines • Show Last 20 Lines | |||||