Fix #131836: Texture paint: "Texture Mask" stencil is not drawing

Reason for this is that all the brushes in essentials assets have a zero
default `mask_stencil_pos` / `mask_stencil_dimension`.
At that time, they have been created resetting a brush to defaults and
using that as a starting point.
At that time though, these settings didnt have a default (which
b2dd308dca fixed, so that method should not result in those settings
being zero).

The brushes in essentials assets still do though, now correct these in
versioning code.

Pull Request: https://projects.blender.org/blender/blender/pulls/133374
This commit is contained in:
Philipp Oeser 2025-01-22 09:16:25 +01:00 committed by Philipp Oeser
parent 00968fe6db
commit 2a52ca42bd
2 changed files with 15 additions and 1 deletions

View file

@ -31,7 +31,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 25
#define BLENDER_FILE_SUBVERSION 26
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View file

@ -5689,6 +5689,20 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 404, 26)) {
const Brush *default_brush = DNA_struct_default_get(Brush);
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
if ((brush->mask_stencil_dimension[0] == 0) && (brush->mask_stencil_dimension[1] == 0)) {
brush->mask_stencil_dimension[0] = default_brush->mask_stencil_dimension[0];
brush->mask_stencil_dimension[1] = default_brush->mask_stencil_dimension[1];
}
if ((brush->mask_stencil_pos[0] == 0) && (brush->mask_stencil_pos[1] == 0)) {
brush->mask_stencil_pos[0] = default_brush->mask_stencil_pos[0];
brush->mask_stencil_pos[1] = default_brush->mask_stencil_pos[1];
}
}
}
/* Always run this versioning; meshes are written with the legacy format which always needs to
* be converted to the new format on file load. Can be moved to a subversion check in a larger
* breaking release. */