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-18 13:19:39 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-08-18 13:20:05 +0300
commitca7414c4cb4c85a337dbe3effb76b9a5b1ad7d83 (patch)
treeb6432195ea747b15717475c597f90fc16d29166a /source/blender/editors/sculpt_paint
parentdb4e08dfdc9c90680e4722e02a3c6f35d51f124f (diff)
Fix Mask Slice deleting the Face Sets
This was a TODO in the code. Previously the Face Set datalayer was deleted and recreated with a constant ID of 0. Now the datalayer is preserved and set to the SculptSession after slicing the mask and a new ID is calculated for the new faces that the slicing operation produced, so they can be easily isolated for further tweaking. Reviewed By: sergey Differential Revision: https://developer.blender.org/D8583
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index 2afa3556dd9..cd0720bbe1c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -71,6 +71,37 @@
#include <math.h>
#include <stdlib.h>
+/* Utils. */
+int ED_sculpt_face_sets_find_next_available_id(struct Mesh *mesh)
+{
+ int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
+ if (!face_sets) {
+ return SCULPT_FACE_SET_NONE;
+ }
+
+ int next_face_set_id = 0;
+ for (int i = 0; i < mesh->totpoly; i++) {
+ next_face_set_id = max_ii(next_face_set_id, abs(face_sets[i]));
+ }
+ next_face_set_id++;
+
+ return next_face_set_id;
+}
+
+void ED_sculpt_face_sets_initialize_none_to_id(struct Mesh *mesh, const int new_id)
+{
+ int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
+ if (!face_sets) {
+ return;
+ }
+
+ for (int i = 0; i < mesh->totpoly; i++) {
+ if (face_sets[i] == SCULPT_FACE_SET_NONE) {
+ face_sets[i] = new_id;
+ }
+ }
+}
+
/* Draw Face Sets Brush. */
static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,