[Bf-blender-cvs] [975a17c816c] sculpt-dev: Sculpt: Auto detect the sphere radius in the sphere mesh filter
Pablo Dobarro
noreply at git.blender.org
Sun Dec 27 00:15:22 CET 2020
Commit: 975a17c816c3bb5cadaf7dd3cbb8334175d0a19a
Author: Pablo Dobarro
Date: Sun Dec 27 00:14:57 2020 +0100
Branches: sculpt-dev
https://developer.blender.org/rB975a17c816c3bb5cadaf7dd3cbb8334175d0a19a
Sculpt: Auto detect the sphere radius in the sphere mesh filter
===================================================================
M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index e11894a8c01..cf200751f3f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -289,6 +289,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
SculptThreadedTaskData *data = userdata;
SculptSession *ss = data->ob->sculpt;
PBVHNode *node = data->nodes[i];
+ FilterCache *filter_cache = ss->filter_cache;
const eSculptMeshFilterType filter_type = data->filter_type;
@@ -354,10 +355,10 @@ static void mesh_filter_task_cb(void *__restrict userdata,
case MESH_FILTER_SPHERE:
normalize_v3_v3(disp, orig_co);
if (fade > 0.0f) {
- mul_v3_v3fl(disp, disp, fade);
+ mul_v3_v3fl(disp, disp, filter_cache->sphere_radius * fade);
}
else {
- mul_v3_v3fl(disp, disp, -fade);
+ mul_v3_v3fl(disp, disp, filter_cache->sphere_radius * -fade);
}
unit_m3(transform);
@@ -370,7 +371,6 @@ static void mesh_filter_task_cb(void *__restrict userdata,
copy_v3_v3(val, orig_co);
mul_m3_v3(transform, val);
sub_v3_v3v3(disp2, val, orig_co);
-
mid_v3_v3v3(disp, disp, disp2);
break;
case MESH_FILTER_RANDOM: {
@@ -493,6 +493,17 @@ static void mesh_filter_enhance_details_init_directions(SculptSession *ss)
}
}
+static void mesh_filter_sphere_radius_calculate(SculptSession *ss)
+{
+ const int totvert = SCULPT_vertex_count_get(ss);
+ FilterCache *filter_cache = ss->filter_cache;
+ float accum = 0.0f;
+ for (int i = 0; i < totvert; i++) {
+ accum += len_v3(SCULPT_vertex_co_get(ss, i));
+ }
+ filter_cache->sphere_radius = accum / totvert;
+}
+
static void mesh_filter_surface_smooth_init(SculptSession *ss,
const float shape_preservation,
const float current_vertex_displacement)
@@ -733,6 +744,10 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
mesh_filter_enhance_details_init_directions(ss);
break;
}
+ case MESH_FILTER_SPHERE: {
+ mesh_filter_sphere_radius_calculate(ss);
+ break;
+ }
case MESH_FILTER_ERASE_DISPLACEMENT: {
mesh_filter_init_limit_surface_co(ss);
break;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 45019fc6cd9..f915345ade1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1158,6 +1158,9 @@ typedef struct FilterCache {
float *sharpen_factor;
float (*detail_directions)[3];
+ /* Sphere mesh filter. */
+ float sphere_radius;
+
/* Filter orientaiton. */
SculptFilterOrientation orientation;
float obmat[4][4];
More information about the Bf-blender-cvs
mailing list