Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/paint.c
| Show First 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| PaintCurve *pc; | PaintCurve *pc; | ||||
| pc = BKE_libblock_alloc(bmain, ID_PC, name); | pc = BKE_libblock_alloc(bmain, ID_PC, name); | ||||
| return pc; | return pc; | ||||
| } | } | ||||
| PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc) | /** | ||||
| * Only copy internal data of PaintCurve 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_paint_curve_copy_data(Main *UNUSED(bmain), PaintCurve *pc_dst, const PaintCurve *pc_src, const int UNUSED(flag)) | |||||
| { | { | ||||
| PaintCurve *pc_new; | if (pc_src->tot_points != 0) { | ||||
| pc_dst->points = MEM_dupallocN(pc_src->points); | |||||
| pc_new = BKE_libblock_copy(bmain, &pc->id); | } | ||||
| if (pc->tot_points != 0) { | |||||
| pc_new->points = MEM_dupallocN(pc->points); | |||||
| } | } | ||||
| BKE_id_copy_ensure_local(bmain, &pc->id, &pc_new->id); | PaintCurve *BKE_paint_curve_copy(Main *bmain, const PaintCurve *pc) | ||||
| { | |||||
| return pc_new; | PaintCurve *pc_copy; | ||||
| BKE_id_copy_ex(bmain, &pc->id, (ID **)&pc_copy, 0, false); | |||||
| return pc_copy; | |||||
| } | } | ||||
| void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const bool lib_local) | void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const bool lib_local) | ||||
| { | { | ||||
| BKE_id_make_local_generic(bmain, &pc->id, true, lib_local); | BKE_id_make_local_generic(bmain, &pc->id, true, lib_local); | ||||
| } | } | ||||
| Palette *BKE_paint_palette(Paint *p) | Palette *BKE_paint_palette(Paint *p) | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | Palette *BKE_palette_add(Main *bmain, const char *name) | ||||
| palette = BKE_libblock_alloc(bmain, ID_PAL, name); | palette = BKE_libblock_alloc(bmain, ID_PAL, name); | ||||
| /* enable fake user by default */ | /* enable fake user by default */ | ||||
| id_fake_user_set(&palette->id); | id_fake_user_set(&palette->id); | ||||
| return palette; | return palette; | ||||
| } | } | ||||
| Palette *BKE_palette_copy(Main *bmain, const Palette *palette) | /** | ||||
| * Only copy internal data of Palette 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_palette_copy_data(Main *UNUSED(bmain), Palette *palette_dst, const Palette *palette_src, const int UNUSED(flag)) | |||||
| { | { | ||||
| Palette *palette_new; | BLI_duplicatelist(&palette_dst->colors, &palette_src->colors); | ||||
| } | |||||
| palette_new = BKE_libblock_copy(bmain, &palette->id); | |||||
| BLI_duplicatelist(&palette_new->colors, &palette->colors); | |||||
| BKE_id_copy_ensure_local(bmain, &palette->id, &palette_new->id); | |||||
| return palette_new; | Palette *BKE_palette_copy(Main *bmain, const Palette *palette) | ||||
| { | |||||
| Palette *palette_copy; | |||||
| BKE_id_copy_ex(bmain, &palette->id, (ID **)&palette_copy, 0, false); | |||||
| return palette_copy; | |||||
| } | } | ||||
| void BKE_palette_make_local(Main *bmain, Palette *palette, const bool lib_local) | void BKE_palette_make_local(Main *bmain, Palette *palette, const bool lib_local) | ||||
| { | { | ||||
| BKE_id_make_local_generic(bmain, &palette->id, true, lib_local); | BKE_id_make_local_generic(bmain, &palette->id, true, lib_local); | ||||
| } | } | ||||
| /** Free (or release) any data used by this palette (does not free the palette itself). */ | /** Free (or release) any data used by this palette (does not free the palette itself). */ | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| curvemapping_free(paint->cavity_curve); | curvemapping_free(paint->cavity_curve); | ||||
| } | } | ||||
| /* called when copying scene settings, so even if 'src' and 'tar' are the same | /* called when copying scene settings, so even if 'src' and 'tar' are the same | ||||
| * still do a id_us_plus(), rather then if we were copying between 2 existing | * still do a id_us_plus(), rather then if we were copying between 2 existing | ||||
| * scenes where a matching value should decrease the existing user count as | * scenes where a matching value should decrease the existing user count as | ||||
| * with paint_brush_set() */ | * with paint_brush_set() */ | ||||
| void BKE_paint_copy(Paint *src, Paint *tar) | void BKE_paint_copy(Paint *src, Paint *tar, const int flag) | ||||
| { | { | ||||
| tar->brush = src->brush; | tar->brush = src->brush; | ||||
| tar->cavity_curve = curvemapping_copy(src->cavity_curve); | |||||
| if ((flag & LIB_ID_COPY_NO_USER_REFCOUNT) == 0) { | |||||
| id_us_plus((ID *)tar->brush); | id_us_plus((ID *)tar->brush); | ||||
| id_us_plus((ID *)tar->palette); | id_us_plus((ID *)tar->palette); | ||||
| tar->cavity_curve = curvemapping_copy(src->cavity_curve); | } | ||||
| } | } | ||||
| void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3]) | void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3]) | ||||
| { | { | ||||
| UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; | UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; | ||||
| if (ups->last_stroke_valid && ups->average_stroke_counter > 0) { | if (ups->last_stroke_valid && ups->average_stroke_counter > 0) { | ||||
| float fac = 1.0f / ups->average_stroke_counter; | float fac = 1.0f / ups->average_stroke_counter; | ||||
| mul_v3_v3fl(stroke, ups->average_stroke_accum, fac); | mul_v3_v3fl(stroke, ups->average_stroke_accum, fac); | ||||
| ▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines | |||||