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 16:22:51 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-08-18 18:04:24 +0300
commitbedd6f90ca70ede59adff10aaea4d0f17bf8d0b2 (patch)
tree8827ab3e04341011e166d859e6bde315096cbf3b
parent0957189d4a3a8623e4e88ba63bca2e23416679b1 (diff)
Sculpt: Erase Displacement Mesh Filter
Same concept as the Multires Displacement Eraser Brush but implemented as a mesh Filter. This allows to delete the displacement of an entire area uniformly. Reviewed By: sergey Differential Revision: https://developer.blender.org/D8608
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c27
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h3
2 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index af77e35aebe..abfbe035928 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -177,6 +177,7 @@ void SCULPT_filter_cache_free(SculptSession *ss)
MEM_SAFE_FREE(ss->filter_cache->surface_smooth_laplacian_disp);
MEM_SAFE_FREE(ss->filter_cache->sharpen_factor);
MEM_SAFE_FREE(ss->filter_cache->detail_directions);
+ MEM_SAFE_FREE(ss->filter_cache->limit_surface_co);
MEM_SAFE_FREE(ss->filter_cache);
}
@@ -191,6 +192,7 @@ typedef enum eSculptMeshFilterTypes {
MESH_FILTER_SURFACE_SMOOTH = 7,
MESH_FILTER_SHARPEN = 8,
MESH_FILTER_ENHANCE_DETAILS = 9,
+ MESH_FILTER_ERASE_DISPLACEMENT = 10,
} eSculptMeshFilterTypes;
static EnumPropertyItem prop_mesh_filter_types[] = {
@@ -216,6 +218,11 @@ static EnumPropertyItem prop_mesh_filter_types[] = {
0,
"Enhance Details",
"Enhance the high frequency surface detail"},
+ {MESH_FILTER_ERASE_DISPLACEMENT,
+ "ERASE_DISCPLACEMENT",
+ 0,
+ "Erase Displacement",
+ "Deletes the displacement of the Multires Modifier"},
{0, NULL, 0, NULL, NULL},
};
@@ -444,6 +451,12 @@ static void mesh_filter_task_cb(void *__restrict userdata,
case MESH_FILTER_ENHANCE_DETAILS: {
mul_v3_v3fl(disp, ss->filter_cache->detail_directions[vd.index], -fabsf(fade));
} break;
+ case MESH_FILTER_ERASE_DISPLACEMENT: {
+ fade = clamp_f(fade, 0.0f, 1.0f);
+ sub_v3_v3v3(disp, ss->filter_cache->limit_surface_co[vd.index], orig_co);
+ mul_v3_fl(disp, fade);
+ break;
+ }
}
SCULPT_filter_to_orientation_space(disp, ss->filter_cache);
@@ -480,6 +493,16 @@ static void mesh_filter_enhance_details_init_directions(SculptSession *ss)
}
}
+static void mesh_filter_init_limit_surface_co(SculptSession *ss)
+{
+ const int totvert = SCULPT_vertex_count_get(ss);
+ ss->filter_cache->limit_surface_co = MEM_malloc_arrayN(
+ 3 * sizeof(float), totvert, "limit surface co");
+ for (int i = 0; i < totvert; i++) {
+ SCULPT_vertex_limit_surface_get(ss, i, ss->filter_cache->limit_surface_co[i]);
+ }
+}
+
static void mesh_filter_sharpen_init_factors(SculptSession *ss)
{
const int totvert = SCULPT_vertex_count_get(ss);
@@ -708,6 +731,10 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
mesh_filter_enhance_details_init_directions(ss);
}
+ if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_ERASE_DISPLACEMENT) {
+ mesh_filter_init_limit_surface_co(ss);
+ }
+
ss->filter_cache->enabled_axis[0] = deform_axis & MESH_FILTER_DEFORM_X;
ss->filter_cache->enabled_axis[1] = deform_axis & MESH_FILTER_DEFORM_Y;
ss->filter_cache->enabled_axis[2] = deform_axis & MESH_FILTER_DEFORM_Z;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 6e170ad64fe..df81deeb9d4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -985,6 +985,9 @@ typedef struct FilterCache {
float viewmat[4][4];
float viewmat_inv[4][4];
+ /* Displacement eraser. */
+ float (*limit_surface_co)[3];
+
/* unmasked nodes */
PBVHNode **nodes;
int totnode;