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 | |
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')
-rw-r--r-- | source/blender/blenkernel/BKE_brush.h | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.cc | 22 |
2 files changed, 41 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 4d728002c87..8f069841fbc 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -18,7 +18,9 @@ extern "C" { struct Brush; struct ImBuf; struct ImagePool; +struct Object; struct Main; +struct MTex; struct Scene; struct ToolSettings; struct UnifiedPaintSettings; @@ -109,6 +111,7 @@ float BKE_brush_curve_strength(const struct Brush *br, float p, float len); */ float BKE_brush_sample_tex_3d(const struct Scene *scene, const struct Brush *br, + const struct MTex *mtex, const float point[3], float rgba[4], int thread, @@ -120,6 +123,24 @@ float BKE_brush_sample_masktex(const struct Scene *scene, struct ImagePool *pool); /** + * Get the mask texture for this given object mode. + * + * This is preferred above using mtex/mask_mtex attributes directly as due to legacy these + * attributes got switched in sculpt mode. + */ +const struct MTex *BKE_brush_mask_texture_get(const struct Brush *brush, + const eObjectMode object_mode); + +/** + * Get the color texture for this given object mode. + * + * This is preferred above using mtex/mask_mtex attributes directly as due to legacy these + * attributes got switched in sculpt mode. + */ +const struct MTex *BKE_brush_color_texture_get(const struct Brush *brush, + const eObjectMode object_mode); + +/** * Radial control. */ struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br, 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) { |