Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-08-05 00:34:55 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-08-05 00:34:55 +0300
commitdeb76548c108b3247a41ee273bad18de0f7d2ae1 (patch)
tree9f3ec253a31d5120bf4ecc3748656b13eed2e474 /source/blender/blenkernel/intern/paint.c
parentbf65820782a7b67c294587fa6f670bd9c7678b51 (diff)
parent3ebe97c06b67d1611dfeaa3919512155416b0378 (diff)
Merge branch 'blender-v2.90-release'
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r--source/blender/blenkernel/intern/paint.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index d4edcf88389..15d5b0cbf53 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1824,6 +1824,64 @@ static bool check_sculpt_object_deformed(Object *object, const bool for_construc
return deformed;
}
+static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
+{
+ int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
+ if (!face_sets) {
+ return;
+ }
+
+ for (int i = 0; i < mesh->totvert; i++) {
+ mesh->mvert[i].flag |= ME_HIDE;
+ }
+
+ for (int i = 0; i < mesh->totpoly; i++) {
+ if (face_sets[i] >= 0) {
+ for (int l = 0; l < mesh->mpoly[i].totloop; l++) {
+ MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l];
+ mesh->mvert[loop->v].flag &= ~ME_HIDE;
+ }
+ }
+ }
+}
+
+static void sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
+{
+ int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
+ if (!face_sets) {
+ return;
+ }
+
+ if (!subdiv_ccg) {
+ return;
+ }
+
+ CCGKey key;
+ BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
+ for (int i = 0; i < mesh->totloop; i++) {
+ const int face_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, i);
+ const bool is_hidden = (face_sets[face_index] < 0);
+
+ /* Avoid creating and modifying the grid_hidden bitmap if the base mesh face is visible and
+ * there is not bitmap for the grid. This is because missing grid_hidden implies grid is fully
+ * visible. */
+ if (is_hidden) {
+ BKE_subdiv_ccg_grid_hidden_ensure(subdiv_ccg, i);
+ }
+
+ BLI_bitmap *gh = subdiv_ccg->grid_hidden[i];
+ if (gh) {
+ BLI_bitmap_set_all(gh, is_hidden, key.grid_area);
+ }
+ }
+}
+
+void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg)
+{
+ sculpt_sync_face_sets_visibility_to_base_mesh(mesh);
+ sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg);
+}
+
static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
{
PBVH *pbvh = BKE_pbvh_new();
@@ -1849,6 +1907,8 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool
BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri);
+ BKE_sculpt_sync_face_set_visibility(me, NULL);
+
BKE_pbvh_build_mesh(pbvh,
me,
me->mpoly,
@@ -1881,6 +1941,10 @@ static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
PBVH *pbvh = BKE_pbvh_new();
BKE_pbvh_respect_hide_set(pbvh, respect_hide);
+
+ Mesh *base_mesh = BKE_mesh_from_object(ob);
+ BKE_sculpt_sync_face_set_visibility(base_mesh, subdiv_ccg);
+
BKE_pbvh_build_grids(pbvh,
subdiv_ccg->grids,
subdiv_ccg->num_grids,