1
1

Texture Paint: always respect edit mode hiding

Since e3801a2bd4, we would always respect
hiding for vertex paint and weight paint (drawing code and stroke based
painting), leaving an inconsistency between the different paintmodes.

To rectify this, now also always respect edit mode hiding for projection
painting as well.

Some feedback was gathered in #sculpt-paint-texture-module to ensure
this is desired behavior.

Note: this does not change the (experimental) texture painting in
sculptmode [this already respects hiding via PBVH, albeit in a manner
that bleeds into hidden faces if the brush center is over visible faces]

ref #106354

Pull Request: blender/blender#106544
This commit is contained in:
2023-04-06 09:28:25 +02:00
committed by Philipp Oeser
parent ce9be92adf
commit bd319f6561
2 changed files with 25 additions and 16 deletions

View File

@@ -219,13 +219,9 @@ int DRW_object_visibility_in_active_context(const Object *ob)
bool DRW_object_use_hide_faces(const struct Object *ob)
{
if (ob->type == OB_MESH) {
const Mesh *me = ob->data;
switch (ob->mode) {
case OB_MODE_SCULPT:
return true;
case OB_MODE_TEXTURE_PAINT:
return (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
case OB_MODE_VERTEX_PAINT:
case OB_MODE_WEIGHT_PAINT:
return true;

View File

@@ -416,6 +416,7 @@ struct ProjPaintState {
blender::OffsetIndices<int> polys_eval;
blender::Span<int> corner_verts_eval;
const bool *select_poly_eval;
const bool *hide_poly_eval;
const int *material_indices;
const bool *sharp_faces_eval;
blender::Span<MLoopTri> looptris_eval;
@@ -4079,6 +4080,8 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
ps->corner_verts_eval = ps->me_eval->corner_verts();
ps->select_poly_eval = (const bool *)CustomData_get_layer_named(
&ps->me_eval->pdata, CD_PROP_BOOL, ".select_poly");
ps->hide_poly_eval = (const bool *)CustomData_get_layer_named(
&ps->me_eval->pdata, CD_PROP_BOOL, ".hide_poly");
ps->material_indices = (const int *)CustomData_get_layer_named(
&ps->me_eval->pdata, CD_PROP_INT32, "material_index");
ps->sharp_faces_eval = static_cast<const bool *>(
@@ -4168,26 +4171,28 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps,
struct ProjPaintFaceLookup {
const bool *select_poly_orig;
const bool *hide_poly_orig;
const int *index_mp_to_orig;
};
static void proj_paint_face_lookup_init(const ProjPaintState *ps, ProjPaintFaceLookup *face_lookup)
{
memset(face_lookup, 0, sizeof(*face_lookup));
Mesh *orig_mesh = (Mesh *)ps->ob->data;
face_lookup->index_mp_to_orig = static_cast<const int *>(
CustomData_get_layer(&ps->me_eval->pdata, CD_ORIGINDEX));
if (ps->do_face_sel) {
Mesh *orig_mesh = (Mesh *)ps->ob->data;
face_lookup->index_mp_to_orig = static_cast<const int *>(
CustomData_get_layer(&ps->me_eval->pdata, CD_ORIGINDEX));
face_lookup->select_poly_orig = static_cast<const bool *>(
CustomData_get_layer_named(&orig_mesh->pdata, CD_PROP_BOOL, ".select_poly"));
}
face_lookup->hide_poly_orig = static_cast<const bool *>(
CustomData_get_layer_named(&orig_mesh->pdata, CD_PROP_BOOL, ".hide_poly"));
}
/* Return true if face should be considered selected, false otherwise */
static bool project_paint_check_face_sel(const ProjPaintState *ps,
const ProjPaintFaceLookup *face_lookup,
const MLoopTri *lt)
/* Return true if face should be considered paintable, false otherwise */
static bool project_paint_check_face_paintable(const ProjPaintState *ps,
const ProjPaintFaceLookup *face_lookup,
const MLoopTri *lt)
{
if (ps->do_face_sel) {
int orig_index;
@@ -4198,7 +4203,15 @@ static bool project_paint_check_face_sel(const ProjPaintState *ps,
}
return ps->select_poly_eval && ps->select_poly_eval[lt->poly];
}
return true;
else {
int orig_index;
if ((face_lookup->index_mp_to_orig != nullptr) &&
((orig_index = (face_lookup->index_mp_to_orig[lt->poly])) != ORIGINDEX_NONE)) {
return !(face_lookup->hide_poly_orig && face_lookup->hide_poly_orig[orig_index]);
}
return !(ps->hide_poly_eval && ps->hide_poly_eval[lt->poly]);
}
}
struct ProjPaintFaceCoSS {
@@ -4313,10 +4326,10 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
BLI_assert(ps->image_tot == 0);
for (tri_index = 0; tri_index < ps->looptris_eval.size(); tri_index++) {
bool is_face_sel;
bool is_face_paintable;
bool skip_tri = false;
is_face_sel = project_paint_check_face_sel(ps, face_lookup, &looptris[tri_index]);
is_face_paintable = project_paint_check_face_paintable(ps, face_lookup, &looptris[tri_index]);
if (!ps->do_stencil_brush) {
slot = project_paint_face_paint_slot(ps, tri_index);
@@ -4369,7 +4382,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
BLI_assert(mloopuv_base != nullptr);
if (is_face_sel && tpage) {
if (is_face_paintable && tpage) {
ProjPaintFaceCoSS coSS;
proj_paint_face_coSS_init(ps, &looptris[tri_index], &coSS);