diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-10-18 14:50:04 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-10-18 17:06:40 +0300 |
commit | 5c1d2c5a9d336b7b41617139e04ace23229e8d1f (patch) | |
tree | 600740f4d0513c40399a028e1b33bcbaae818e3a /source/blender/blenkernel/intern/brush.cc | |
parent | 619ce8392b2122e326dcfad4fe195de8f01cedca (diff) |
Brush: Wrap mtex/mask_tex around functions.
`Brush` has two attributes for holding texture information (`MTex`).
One for color textures (`mtex`) and one for mask textures (`mask_mtex`).
Unfortunately sculpt mode due to reasons used `mtex` to store mask textures.
Changes like brush asset/paint mode require modes/tools to read the mask/color texture from
one place.
To start sanatizing this we isolate the attributes in functions.
`BKE_brush_color_texture_get` and `BKE_brush_mask_texture_get`. All object
paint modes should use these functions.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.cc')
-rw-r--r-- | source/blender/blenkernel/intern/brush.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index 20d86ea5a2d..6f1435e90b8 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -1974,19 +1974,37 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset) BKE_curvemapping_changed(cumap, false); } +const struct MTex *BKE_brush_mask_texture_get(const struct Brush *brush, + const eObjectMode object_mode) +{ + if (object_mode == OB_MODE_SCULPT) { + return &brush->mtex; + } + return &brush->mask_mtex; +} + +const struct MTex *BKE_brush_color_texture_get(const struct Brush *brush, + const eObjectMode object_mode) +{ + if (object_mode == OB_MODE_SCULPT) { + return &brush->mask_mtex; + } + return &brush->mtex; +} + float BKE_brush_sample_tex_3d(const Scene *scene, const Brush *br, + const MTex *mtex, const float point[3], float rgba[4], const int thread, struct ImagePool *pool) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - const MTex *mtex = &br->mtex; float intensity = 1.0; bool hasrgb = false; - if (!mtex->tex) { + if (mtex == nullptr || mtex->tex == nullptr) { intensity = 1; } else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) { |