Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/brush.c
| Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode) | ||||
| for (brush = bmain->brush.first; brush; brush = brush->id.next) { | for (brush = bmain->brush.first; brush; brush = brush->id.next) { | ||||
| if (brush->ob_mode & ob_mode) | if (brush->ob_mode & ob_mode) | ||||
| return brush; | return brush; | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Brush *BKE_brush_copy(Main *bmain, const Brush *brush) | /** | ||||
| * 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) | |||||
| { | { | ||||
| Brush *brushn; | if (brush_src->icon_imbuf) { | ||||
| brush_dst->icon_imbuf = IMB_dupImBuf(brush_src->icon_imbuf); | |||||
| brushn = BKE_libblock_copy(bmain, &brush->id); | } | ||||
| if (brush->mtex.tex) | |||||
| id_us_plus((ID *)brush->mtex.tex); | |||||
| if (brush->mask_mtex.tex) | |||||
| id_us_plus((ID *)brush->mask_mtex.tex); | |||||
| if (brush->paint_curve) | |||||
| id_us_plus((ID *)brush->paint_curve); | |||||
| if (brush->icon_imbuf) | |||||
| brushn->icon_imbuf = IMB_dupImBuf(brush->icon_imbuf); | |||||
| brushn->preview = NULL; | if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { | ||||
| BKE_previewimg_id_copy(&brush_dst->id, &brush_src->id); | |||||
| } | |||||
| else { | |||||
| brush_dst->preview = NULL; | |||||
| } | |||||
| brushn->curve = curvemapping_copy(brush->curve); | brush_dst->curve = curvemapping_copy(brush_src->curve); | ||||
| /* enable fake user by default */ | /* enable fake user by default */ | ||||
| id_fake_user_set(&brushn->id); | id_fake_user_set(&brush_dst->id); | ||||
| } | |||||
| BKE_id_copy_ensure_local(bmain, &brush->id, &brushn->id); | |||||
| return brushn; | Brush *BKE_brush_copy(Main *bmain, const Brush *brush) | ||||
| { | |||||
| Brush *brush_copy; | |||||
| BKE_id_copy_ex(bmain, &brush->id, (ID **)&brush_copy, 0, false); | |||||
| return brush_copy; | |||||
| } | } | ||||
| /** Free (or release) any data used by this brush (does not free the brush itself). */ | /** Free (or release) any data used by this brush (does not free the brush itself). */ | ||||
| void BKE_brush_free(Brush *brush) | void BKE_brush_free(Brush *brush) | ||||
| { | { | ||||
| if (brush->icon_imbuf) { | if (brush->icon_imbuf) { | ||||
| IMB_freeImBuf(brush->icon_imbuf); | IMB_freeImBuf(brush->icon_imbuf); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 851 Lines • Show Last 20 Lines | |||||