/** * Only copy internal data of Brush ID from source * to already allocated/initialized destination. * You probably never want to use that directly, * use #BKE_id_copy or #BKE_id_copy_ex for typical needs. * * WARNING! This function will not handle ID user count! * * \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_brush_copy_data(Main *UNUSED(bmain), Brush *brush_dst, const Brush *brush_src, const int flag) { if (brush_src->icon_imbuf) { brush_dst->icon_imbuf = IMB_dupImBuf(brush_src->icon_imbuf); } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { BKE_previewimg_id_copy(&brush_dst->id, &brush_src->id); } else { brush_dst->preview = NULL; } brush_dst->curve = curvemapping_copy(brush_src->curve); if (brush_src->gpencil_settings != NULL) { brush_dst->gpencil_settings = MEM_dupallocN(brush_src->gpencil_settings); brush_dst->gpencil_settings->curve_sensitivity = curvemapping_copy( brush_src->gpencil_settings->curve_sensitivity); brush_dst->gpencil_settings->curve_strength = curvemapping_copy( brush_src->gpencil_settings->curve_strength); brush_dst->gpencil_settings->curve_jitter = curvemapping_copy( brush_src->gpencil_settings->curve_jitter); } /* enable fake user by default */ id_fake_user_set(&brush_dst->id); }
/** * Only copy internal data of Collection ID from source * to already allocated/initialized destination. * You probably never want to use that directly, * use #BKE_id_copy or #BKE_id_copy_ex for typical needs. * * WARNING! This function will not handle ID user count! * * \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_collection_copy_data(Main *bmain, Collection *collection_dst, const Collection *collection_src, const int flag) { /* Do not copy collection's preview (same behavior as for objects). */ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */ BKE_previewimg_id_copy(&collection_dst->id, &collection_src->id); } else { collection_dst->preview = NULL; } collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE; BLI_listbase_clear(&collection_dst->object_cache); BLI_listbase_clear(&collection_dst->gobject); BLI_listbase_clear(&collection_dst->children); BLI_listbase_clear(&collection_dst->parents); for (CollectionChild *child = collection_src->children.first; child; child = child->next) { collection_child_add(collection_dst, child->collection, flag, false); } for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) { collection_object_add(bmain, collection_dst, cob->ob, flag, false); } }
/** * Only copy internal data of Light ID from source * to already allocated/initialized destination. * You probably never want to use that directly, * use #BKE_id_copy or #BKE_id_copy_ex for typical needs. * * WARNING! This function will not handle ID user count! * * \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_light_copy_data(Main *bmain, Light *la_dst, const Light *la_src, const int flag) { la_dst->curfalloff = curvemapping_copy(la_src->curfalloff); if (la_src->nodetree) { /* Note: nodetree is *not* in bmain, however this specific case is handled at lower level * (see BKE_libblock_copy_ex()). */ BKE_id_copy_ex(bmain, (ID *)la_src->nodetree, (ID **)&la_dst->nodetree, flag); } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { BKE_previewimg_id_copy(&la_dst->id, &la_src->id); } else { la_dst->preview = NULL; } }
/** * Only copy internal data of Brush 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. * * WARNING! This function will not handle ID user count! * * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_brush_copy_data(Main *UNUSED(bmain), Brush *brush_dst, const Brush *brush_src, const int flag) { if (brush_src->icon_imbuf) { brush_dst->icon_imbuf = IMB_dupImBuf(brush_src->icon_imbuf); } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { BKE_previewimg_id_copy(&brush_dst->id, &brush_src->id); } else { brush_dst->preview = NULL; } brush_dst->curve = curvemapping_copy(brush_src->curve); /* enable fake user by default */ id_fake_user_set(&brush_dst->id); }
/** * Only copy internal data of Texture 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. * * WARNING! This function will not handle ID user count! * * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const int flag) { /* We never handle usercount here for own data. */ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT; if (!BKE_texture_is_image_user(tex_src)) { tex_dst->ima = NULL; } if (tex_dst->coba) { tex_dst->coba = MEM_dupallocN(tex_dst->coba); } if (tex_dst->env) { tex_dst->env = BKE_texture_envmap_copy(tex_dst->env, flag_subdata); } if (tex_dst->pd) { tex_dst->pd = BKE_texture_pointdensity_copy(tex_dst->pd, flag_subdata); } if (tex_dst->vd) { tex_dst->vd = MEM_dupallocN(tex_dst->vd); } if (tex_dst->ot) { tex_dst->ot = BKE_texture_ocean_copy(tex_dst->ot, flag_subdata); } if (tex_src->nodetree) { if (tex_src->nodetree->execdata) { ntreeTexEndExecTree(tex_src->nodetree->execdata); } /* Note: nodetree is *not* in bmain, however this specific case is handled at lower level * (see BKE_libblock_copy_ex()). */ BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag, false); } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { BKE_previewimg_id_copy(&tex_dst->id, &tex_src->id); } else { tex_dst->preview = NULL; } }