diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-06 15:16:17 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-06 15:16:17 +0300 |
commit | 9ad2965921f064250830a8647de3dce68bcb2e4d (patch) | |
tree | dcfec730e0e71fc72e1852162a70aecee2145007 /source/blender/blenkernel/intern | |
parent | e810a16d75d346646720814740f8e2a241f4bd8b (diff) |
Refactor: move Paint .blend I/O to blenkernel
Ref T76372.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f2af5520d16..3e8bdbf0481 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1176,6 +1176,40 @@ void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3]) } } +void BKE_paint_blend_write(BlendWriter *writer, Paint *p) +{ + if (p->cavity_curve) { + BKE_curvemapping_blend_write(writer, p->cavity_curve); + } + BLO_write_struct_array(writer, PaintToolSlot, p->tool_slots_len, p->tool_slots); +} + +void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Paint *p) +{ + if (p->num_input_samples < 1) { + p->num_input_samples = 1; + } + + BLO_read_data_address(reader, &p->cavity_curve); + if (p->cavity_curve) { + BKE_curvemapping_blend_read(reader, p->cavity_curve); + } + else { + BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE); + } + + BLO_read_data_address(reader, &p->tool_slots); + + /* Workaround for invalid data written in older versions. */ + const size_t expected_size = sizeof(PaintToolSlot) * p->tool_slots_len; + if (p->tool_slots && MEM_allocN_len(p->tool_slots) < expected_size) { + MEM_freeN(p->tool_slots); + p->tool_slots = MEM_callocN(expected_size, "PaintToolSlot"); + } + + BKE_paint_runtime_init(scene->toolsettings, p); +} + /* returns non-zero if any of the face's vertices * are hidden, zero otherwise */ bool paint_is_face_hidden(const MLoopTri *lt, const MVert *mvert, const MLoop *mloop) |