Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/group.c
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| /** Free (or release) any data used by this group (does not free the group itself). */ | /** Free (or release) any data used by this group (does not free the group itself). */ | ||||
| void BKE_group_free(Group *group) | void BKE_group_free(Group *group) | ||||
| { | { | ||||
| /* No animdata here. */ | /* No animdata here. */ | ||||
| BKE_previewimg_free(&group->preview); | BKE_previewimg_free(&group->preview); | ||||
| if (group->view_layer != NULL) { | if (group->view_layer != NULL) { | ||||
| BKE_view_layer_free(group->view_layer); | BKE_view_layer_free(group->view_layer, G.main); /* XXX pass as parameter */ | ||||
| group->view_layer = NULL; | group->view_layer = NULL; | ||||
| } | } | ||||
| if (group->collection != NULL) { | if (group->collection != NULL) { | ||||
| BKE_collection_master_free(&group->id, false); | BKE_collection_master_free(&group->id, false); | ||||
| MEM_freeN(group->collection); | MEM_freeN(group->collection); | ||||
| group->collection = NULL; | group->collection = NULL; | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Run when adding new groups or during doversion. | * Run when adding new groups or during doversion. | ||||
| */ | */ | ||||
| void BKE_group_init(Group *group) | void BKE_group_init(Group *group, const Main *bmain) | ||||
| { | { | ||||
| group->collection = MEM_callocN(sizeof(SceneCollection), __func__); | group->collection = MEM_callocN(sizeof(SceneCollection), __func__); | ||||
| BLI_strncpy(group->collection->name, "Master Collection", sizeof(group->collection->name)); | BLI_strncpy(group->collection->name, "Master Collection", sizeof(group->collection->name)); | ||||
| group->view_layer = BKE_view_layer_group_add(group); | group->view_layer = BKE_view_layer_group_add(group); | ||||
| /* Unlink the master collection. */ | /* Unlink the master collection. */ | ||||
| BKE_collection_unlink(group->view_layer, group->view_layer->layer_collections.first); | BKE_collection_unlink(group->view_layer, group->view_layer->layer_collections.first, bmain); | ||||
| /* Create and link a new default collection. */ | /* Create and link a new default collection. */ | ||||
| SceneCollection *defaut_collection = BKE_collection_add(&group->id, NULL, COLLECTION_TYPE_GROUP_INTERNAL, NULL); | SceneCollection *defaut_collection = BKE_collection_add(&group->id, NULL, COLLECTION_TYPE_GROUP_INTERNAL, NULL); | ||||
| BKE_collection_link(group->view_layer, defaut_collection); | BKE_collection_link(group->view_layer, defaut_collection); | ||||
| } | } | ||||
| Group *BKE_group_add(Main *bmain, const char *name) | Group *BKE_group_add(Main *bmain, const char *name) | ||||
| { | { | ||||
| Group *group; | Group *group; | ||||
| group = BKE_libblock_alloc(bmain, ID_GR, name, 0); | group = BKE_libblock_alloc(bmain, ID_GR, name, 0); | ||||
| id_us_min(&group->id); | id_us_min(&group->id); | ||||
| id_us_ensure_real(&group->id); | id_us_ensure_real(&group->id); | ||||
| group->layer = (1 << 20) - 1; | group->layer = (1 << 20) - 1; | ||||
| group->preview = NULL; | group->preview = NULL; | ||||
| BKE_group_init(group); | BKE_group_init(group, bmain); | ||||
| return group; | return group; | ||||
| } | } | ||||
| /** | /** | ||||
| * Only copy internal data of Group ID from source to already allocated/initialized destination. | * Only copy internal data of Group ID from source to already allocated/initialized destination. | ||||
| * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs. | * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs. | ||||
| * | * | ||||
| * WARNING! This function will not handle ID user count! | * WARNING! This function will not handle ID user count! | ||||
| ▲ Show 20 Lines • Show All 300 Lines • Show Last 20 Lines | |||||