Cleanup: Use BKE_brush_mask_texture_get in sculpt code.
In preparation to sanatize the mask texture and color texture in sculpt code. In sculpt mode the mask texture is read from mtex, leaving the mask_mtex when we want to use color textures in sculpt mode.
This commit is contained in:
parent
e6e57cebec
commit
8f5df25f33
|
@ -1319,6 +1319,7 @@ static bool sculpt_brush_use_topology_rake(const SculptSession *ss, const Brush
|
|||
*/
|
||||
static int sculpt_brush_needs_normal(const SculptSession *ss, Sculpt *sd, const Brush *brush)
|
||||
{
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
return ((SCULPT_TOOL_HAS_NORMAL_WEIGHT(brush->sculpt_tool) &&
|
||||
(ss->cache->normal_weight > 0.0f)) ||
|
||||
SCULPT_automasking_needs_normal(ss, sd, brush) ||
|
||||
|
@ -1334,7 +1335,7 @@ static int sculpt_brush_needs_normal(const SculptSession *ss, Sculpt *sd, const
|
|||
SCULPT_TOOL_ELASTIC_DEFORM,
|
||||
SCULPT_TOOL_THUMB) ||
|
||||
|
||||
(brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA)) ||
|
||||
(mask_tex->brush_map_mode == MTEX_MAP_MODE_AREA)) ||
|
||||
sculpt_brush_use_topology_rake(ss, brush);
|
||||
}
|
||||
|
||||
|
@ -2861,7 +2862,10 @@ static void calc_local_y(ViewContext *vc, const float center[3], float y[3])
|
|||
mul_m4_v3(ob->world_to_object, y);
|
||||
}
|
||||
|
||||
static void calc_brush_local_mat(const Brush *brush, Object *ob, float local_mat[4][4])
|
||||
static void calc_brush_local_mat(const Brush *brush,
|
||||
const MTex *mtex,
|
||||
Object *ob,
|
||||
float local_mat[4][4])
|
||||
{
|
||||
const StrokeCache *cache = ob->sculpt->cache;
|
||||
float tmat[4][4];
|
||||
|
@ -2885,7 +2889,7 @@ static void calc_brush_local_mat(const Brush *brush, Object *ob, float local_mat
|
|||
/* Calculate the X axis of the local matrix. */
|
||||
cross_v3_v3v3(v, up, cache->sculpt_normal);
|
||||
/* Apply rotation (user angle, rake, etc.) to X axis. */
|
||||
angle = brush->mtex.rot - cache->special_rotation;
|
||||
angle = mtex->rot - cache->special_rotation;
|
||||
rotate_v3_v3v3fl(mat[0], v, cache->sculpt_normal, angle);
|
||||
|
||||
/* Get other axes. */
|
||||
|
@ -2932,7 +2936,9 @@ static void update_brush_local_mat(Sculpt *sd, Object *ob)
|
|||
StrokeCache *cache = ob->sculpt->cache;
|
||||
|
||||
if (cache->mirror_symmetry_pass == 0 && cache->radial_symmetry_pass == 0) {
|
||||
calc_brush_local_mat(BKE_paint_brush(&sd->paint), ob, cache->brush_local_mat);
|
||||
const Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
calc_brush_local_mat(brush, mask_tex, ob, cache->brush_local_mat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3512,7 +3518,8 @@ static void do_brush_action(Sculpt *sd,
|
|||
update_sculpt_normal(sd, ob, nodes, totnode);
|
||||
}
|
||||
|
||||
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA) {
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(brush, static_cast<eObjectMode>(ob->mode));
|
||||
if (mask_tex->brush_map_mode == MTEX_MAP_MODE_AREA) {
|
||||
update_brush_local_mat(sd, ob);
|
||||
}
|
||||
|
||||
|
@ -4047,7 +4054,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
|
|||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
MTex *mtex = &brush->mtex;
|
||||
const MTex *mtex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
|
||||
if (ss->multires.active && mtex->tex && mtex->tex->type == TEX_NOISE) {
|
||||
multires_stitch_grids(ob);
|
||||
|
@ -5196,12 +5203,12 @@ bool SCULPT_stroke_get_location(bContext *C,
|
|||
static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
|
||||
{
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
MTex *mtex = &brush->mtex;
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
|
||||
/* Init mtex nodes. */
|
||||
if (mtex->tex && mtex->tex->nodetree) {
|
||||
if (mask_tex->tex && mask_tex->tex->nodetree) {
|
||||
/* Has internal flag to detect it only does it once. */
|
||||
ntreeTexBeginExecTree(mtex->tex->nodetree);
|
||||
ntreeTexBeginExecTree(mask_tex->tex->nodetree);
|
||||
}
|
||||
|
||||
if (ss->tex_pool == nullptr) {
|
||||
|
@ -5630,10 +5637,10 @@ static void sculpt_stroke_update_step(bContext *C,
|
|||
static void sculpt_brush_exit_tex(Sculpt *sd)
|
||||
{
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
MTex *mtex = &brush->mtex;
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(brush, OB_MODE_SCULPT);
|
||||
|
||||
if (mtex->tex && mtex->tex->nodetree) {
|
||||
ntreeTexEndExecTree(mtex->tex->nodetree->runtime->execdata);
|
||||
if (mask_tex->tex && mask_tex->tex->nodetree) {
|
||||
ntreeTexEndExecTree(mask_tex->tex->nodetree->runtime->execdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ static float sculpt_expand_max_vertex_falloff_get(ExpandCache *expand_cache)
|
|||
return expand_cache->max_vert_falloff;
|
||||
}
|
||||
|
||||
if (!expand_cache->brush->mtex.tex) {
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(expand_cache->brush, OB_MODE_SCULPT);
|
||||
if (!mask_tex->tex) {
|
||||
return expand_cache->max_vert_falloff;
|
||||
}
|
||||
|
||||
|
@ -1882,13 +1883,14 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
}
|
||||
case SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE: {
|
||||
if (expand_cache->texture_distortion_strength == 0.0f) {
|
||||
if (expand_cache->brush->mtex.tex == NULL) {
|
||||
const MTex *mask_tex = BKE_brush_mask_texture_get(expand_cache->brush, OB_MODE_SCULPT);
|
||||
if (mask_tex->tex == NULL) {
|
||||
BKE_report(op->reports,
|
||||
RPT_WARNING,
|
||||
"Active brush does not contain any texture to distort the expand boundary");
|
||||
break;
|
||||
}
|
||||
if (expand_cache->brush->mtex.brush_map_mode != MTEX_MAP_MODE_3D) {
|
||||
if (mask_tex->brush_map_mode != MTEX_MAP_MODE_3D) {
|
||||
BKE_report(op->reports,
|
||||
RPT_WARNING,
|
||||
"Texture mapping not set to 3D, results may be unpredictable");
|
||||
|
@ -2052,7 +2054,6 @@ static void sculpt_expand_cache_initial_config_set(bContext *C,
|
|||
IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache->fill_color, expand_cache->fill_color);
|
||||
|
||||
expand_cache->scene = CTX_data_scene(C);
|
||||
expand_cache->mtex = &expand_cache->brush->mtex;
|
||||
expand_cache->texture_distortion_strength = 0.0f;
|
||||
expand_cache->blend_mode = expand_cache->brush->blend;
|
||||
}
|
||||
|
|
|
@ -752,7 +752,7 @@ typedef struct ExpandCache {
|
|||
/* Texture distortion data. */
|
||||
Brush *brush;
|
||||
struct Scene *scene;
|
||||
struct MTex *mtex;
|
||||
// struct MTex *mtex;
|
||||
|
||||
/* Controls how much texture distortion will be applied to the current falloff */
|
||||
float texture_distortion_strength;
|
||||
|
|
Loading…
Reference in New Issue