[Bf-blender-cvs] [e779eab729f] sculpt-dev: Sculpt: Implement elastic surface falloff
Pablo Dobarro
noreply at git.blender.org
Tue Jan 26 20:52:07 CET 2021
Commit: e779eab729fb8b5892057878b1f57b5e98fb8254
Author: Pablo Dobarro
Date: Tue Jan 26 20:51:53 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rBe779eab729fb8b5892057878b1f57b5e98fb8254
Sculpt: Implement elastic surface falloff
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M source/blender/editors/sculpt_paint/sculpt.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index a34798494d9..5de0ba71280 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -640,6 +640,7 @@ def brush_settings(layout, context, brush, popover=False):
layout.separator()
layout.prop(brush, "elastic_deform_type")
layout.prop(brush, "elastic_deform_volume_preservation", slider=True)
+ layout.prop(brush, "use_surface_falloff")
layout.separator()
elif sculpt_tool == 'SNAKE_HOOK':
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 11ad030f3ae..f1e4aecbd3e 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4500,28 +4500,39 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
{
SCULPT_orig_vert_data_update(&orig_data, &vd);
float final_disp[3];
+
+ float orig_co[3];
+ if (brush->flag2 & BRUSH_USE_SURFACE_FALLOFF) {
+ float disp[3];
+ sub_v3_v3v3(disp, orig_data.co, ss->cache->initial_location);
+ normalize_v3(disp);
+ mul_v3_fl(disp, ss->cache->geodesic_dists[ss->cache->mirror_symmetry_pass][vd.index]);
+ add_v3_v3v3(orig_co, ss->cache->initial_location, disp);
+ }
+ else {
+ copy_v3_v3(orig_co, orig_data.co);
+ }
+
switch (brush->elastic_deform_type) {
case BRUSH_ELASTIC_DEFORM_GRAB:
- BKE_kelvinlet_grab(final_disp, ¶ms, orig_data.co, location, grab_delta);
+ BKE_kelvinlet_grab(final_disp, ¶ms, orig_co, location, grab_delta);
mul_v3_fl(final_disp, bstrength * 20.0f);
break;
case BRUSH_ELASTIC_DEFORM_GRAB_BISCALE: {
- BKE_kelvinlet_grab_biscale(final_disp, ¶ms, orig_data.co, location, grab_delta);
+ BKE_kelvinlet_grab_biscale(final_disp, ¶ms, orig_co, location, grab_delta);
mul_v3_fl(final_disp, bstrength * 20.0f);
break;
}
case BRUSH_ELASTIC_DEFORM_GRAB_TRISCALE: {
- BKE_kelvinlet_grab_triscale(final_disp, ¶ms, orig_data.co, location, grab_delta);
+ BKE_kelvinlet_grab_triscale(final_disp, ¶ms, orig_co, location, grab_delta);
mul_v3_fl(final_disp, bstrength * 20.0f);
break;
}
case BRUSH_ELASTIC_DEFORM_SCALE:
- BKE_kelvinlet_scale(
- final_disp, ¶ms, orig_data.co, location, ss->cache->sculpt_normal_symm);
+ BKE_kelvinlet_scale(final_disp, ¶ms, orig_co, location, ss->cache->sculpt_normal_symm);
break;
case BRUSH_ELASTIC_DEFORM_TWIST:
- BKE_kelvinlet_twist(
- final_disp, ¶ms, orig_data.co, location, ss->cache->sculpt_normal_symm);
+ BKE_kelvinlet_twist(final_disp, ¶ms, orig_co, location, ss->cache->sculpt_normal_symm);
break;
}
@@ -4552,6 +4563,16 @@ static void do_elastic_deform_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in
sculpt_project_v3_normal_align(ss, ss->cache->normal_weight, grab_delta);
}
+ if (brush->flag2 & BRUSH_USE_SURFACE_FALLOFF) {
+ if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
+ const int symm_pass = ss->cache->mirror_symmetry_pass;
+ float location[3];
+ flip_v3_v3(location, SCULPT_active_vertex_co_get(ss), symm_pass);
+ int v = SCULPT_nearest_vertex_get(sd, ob, location, ss->cache->initial_radius, false);
+ ss->cache->geodesic_dists[symm_pass] = SCULPT_geodesic_from_vertex(ob, v, FLT_MAX);
+ }
+ }
+
SculptThreadedTaskData data = {
.sd = sd,
.ob = ob,
More information about the Bf-blender-cvs
mailing list