static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *old_ob, Object *new_ob) { if (old_ob->flag & OB_FROMGROUP) { /* Note that for Scene's BaseObject->flag, either we: * - unlinked old_ob (i.e. new_ob is NULL), in which case scenes' bases have been removed already. * - remapped old_ob by new_ob, in which case scenes' bases are still valid as is. * So in any case, no need to update them here. */ if (BKE_group_object_find(NULL, old_ob) == NULL) { old_ob->flag &= ~OB_FROMGROUP; } if (new_ob == NULL) { /* We need to remove NULL-ified groupobjects... */ for (Group *group = bmain->group.first; group; group = group->id.next) { BKE_group_object_unlink(group, NULL, NULL, NULL); } } else { new_ob->flag |= OB_FROMGROUP; } } if (old_ob->type == OB_MBALL) { for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->type == OB_MBALL && BKE_mball_is_basis_for(ob, old_ob)) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } } }
static int objects_remove_active_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = OBACT; int single_group_index = RNA_enum_get(op->ptr, "group"); Group *single_group = group_object_active_find_index(ob, single_group_index); Group *group; bool ok = false; if (ob == NULL) return OPERATOR_CANCELLED; /* linking to same group requires its own loop so we can avoid * looking up the active objects groups each time */ for (group = bmain->group.first; group; group = group->id.next) { if (single_group && group != single_group) continue; if (BKE_group_object_exists(group, ob)) { /* Remove groups from selected objects */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { BKE_group_object_unlink(group, base->object, scene, base); ok = 1; } CTX_DATA_END; } }
static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object) { if (!BKE_group_object_unlink(group, object, CTX_data_scene(C), NULL)) { BKE_reportf(reports, RPT_ERROR, "Object '%s' not in group '%s'", object->id.name + 2, group->id.name + 2); return; } WM_main_add_notifier(NC_OBJECT | ND_DRAW, &object->id); }
void ED_rigidbody_object_remove(Scene *scene, Object *ob) { RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene); BKE_rigidbody_remove_object(scene, ob); if (rbw) BKE_group_object_unlink(rbw->group, ob, scene, NULL); DAG_id_tag_update(&ob->id, OB_RECALC_OB); }
static int objects_remove_active_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = OBACT; Group *group; int ok = 0; if (!ob) return OPERATOR_CANCELLED; /* linking to same group requires its own loop so we can avoid * looking up the active objects groups each time */ for (group = bmain->group.first; group; group = group->id.next) { if (BKE_group_object_exists(group, ob)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { BKE_group_object_unlink(group, base->object, scene, base); ok = 1; } CTX_DATA_END; } }