Paint: Add forward compatibility code for brush size
In 5.0, we plan to change the brush size from representing radius to diameter. This means that for 5.0 files loaded in 4.5, we need to scale the stored value when reading the relevant brush fields. Related to #134204 Pull Request: https://projects.blender.org/blender/blender/pulls/139561
This commit is contained in:
@@ -401,6 +401,13 @@ static void brush_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
|
||||
brush->icon_imbuf = nullptr;
|
||||
brush->has_unsaved_changes = false;
|
||||
|
||||
/* Prior to 5.0, the brush->size value is expected to be the radius, not the diameter. To ensure
|
||||
* correct behavior, convert this when reading newer files. */
|
||||
if (BLO_read_fileversion_get(reader) > 500) {
|
||||
brush->size = std::max(brush->size / 2, 1);
|
||||
brush->unprojected_radius = std::max(brush->unprojected_radius / 2, 0.001f);
|
||||
}
|
||||
}
|
||||
|
||||
static void brush_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
|
||||
|
||||
@@ -1224,6 +1224,13 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
zero_v3(ups->last_location);
|
||||
ups->last_hit = 0;
|
||||
|
||||
/* Prior to 5.0, the brush->size value is expected to be the radius, not the diameter. To
|
||||
* ensure correct behavior, convert this when reading newer files. */
|
||||
if (BLO_read_fileversion_get(reader)) {
|
||||
ups->size = std::max(ups->size / 2, 1);
|
||||
ups->unprojected_radius = std::max(ups->unprojected_radius / 2, 0.001f);
|
||||
}
|
||||
|
||||
BLO_read_struct(reader, CurveMapping, &ups->curve_rand_hue);
|
||||
if (ups->curve_rand_hue) {
|
||||
BKE_curvemapping_blend_read(reader, ups->curve_rand_hue);
|
||||
|
||||
Reference in New Issue
Block a user