[Bf-blender-cvs] [c0f19d6082e] sculpt-dev: Sculpt: Cloth Brush elastic drag deform type
Pablo Dobarro
noreply at git.blender.org
Wed Dec 16 21:36:55 CET 2020
Commit: c0f19d6082e740aa4f9d847340cecffb2b68275e
Author: Pablo Dobarro
Date: Wed Dec 16 20:49:02 2020 +0100
Branches: sculpt-dev
https://developer.blender.org/rBc0f19d6082e740aa4f9d847340cecffb2b68275e
Sculpt: Cloth Brush elastic drag deform type
===================================================================
M source/blender/editors/sculpt_paint/sculpt_cloth.c
M source/blender/makesdna/DNA_brush_enums.h
M source/blender/makesdna/DNA_brush_types.h
M source/blender/makesrna/intern/rna_brush.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 3549284eae3..99083680711 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -512,6 +512,15 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
plane_from_point_normal_v3(deform_plane, data->area_co, plane_normal);
}
+ KelvinletParams params;
+ const float kv_force = 1.0f;
+ const float kv_shear_modulus = 1.0f;
+ const float kv_poisson_ratio = 0.4f;
+ if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_ELASTIC_DRAG) {
+ BKE_kelvinlet_init_params(
+ ¶ms, ss->cache->radius, kv_force, kv_shear_modulus, kv_poisson_ratio);
+ }
+
/* Gravity */
float gravity[3] = {0.0f};
if (ss->cache->supports_gravity) {
@@ -627,6 +636,17 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
cloth_sim->length_constraint_tweak[vd.index] += fade * 0.1f;
zero_v3(force);
break;
+ case BRUSH_CLOTH_DEFORM_ELASTIC_DRAG: {
+ float final_disp[3];
+ sub_v3_v3v3(brush_disp, ss->cache->location, ss->cache->last_location);
+ mul_v3_v3fl(final_disp, brush_disp, ss->cache->bstrength);
+ BKE_kelvinlet_grab_triscale(final_disp, ¶ms, vd.co, ss->cache->location, brush_disp);
+ mul_v3_fl(final_disp, 20.0f * (1.0f - fade));
+ add_v3_v3(cloth_sim->pos[vd.index], final_disp);
+ zero_v3(force);
+ }
+
+ break;
}
cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, force, vd.index);
diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h
index 3a22d0b3d4f..b17f9dc3be8 100644
--- a/source/blender/makesdna/DNA_brush_enums.h
+++ b/source/blender/makesdna/DNA_brush_enums.h
@@ -224,6 +224,7 @@ typedef enum eBrushClothDeformType {
BRUSH_CLOTH_DEFORM_INFLATE = 5,
BRUSH_CLOTH_DEFORM_EXPAND = 6,
BRUSH_CLOTH_DEFORM_SNAKE_HOOK = 7,
+ BRUSH_CLOTH_DEFORM_ELASTIC_DRAG = 8,
} eBrushClothDeformType;
typedef enum eBrushSmoothDeformType {
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 1709ea5dc63..4b020019062 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -373,7 +373,7 @@ typedef struct Brush {
typedef struct tPaletteColorHSV {
float rgb[3];
float value;
- float h;
+ float h;
float s;
float v;
} tPaletteColorHSV;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 8659498de05..2df36168d9a 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -2102,6 +2102,7 @@ static void rna_def_brush(BlenderRNA *brna)
{BRUSH_CLOTH_DEFORM_GRAB, "GRAB", 0, "Grab", ""},
{BRUSH_CLOTH_DEFORM_EXPAND, "EXPAND", 0, "Expand", ""},
{BRUSH_CLOTH_DEFORM_SNAKE_HOOK, "SNAKE_HOOK", 0, "Snake Hook", ""},
+ {BRUSH_CLOTH_DEFORM_ELASTIC_DRAG, "ELASTIC", 0, "Elastic Drag", ""},
{0, NULL, 0, NULL, NULL},
};
More information about the Bf-blender-cvs
mailing list