Sculpt: Cloth Deform target for transform
This commit is contained in:
parent
5775efba2f
commit
243e329ec3
|
@ -269,6 +269,7 @@ class _defs_transform:
|
|||
def draw_transform_sculpt_tool_settings(context, layout):
|
||||
if context.mode != 'SCULPT':
|
||||
return
|
||||
layout.prop(context.tool_settings.sculpt, "transform_deform_target")
|
||||
layout.prop(context.tool_settings.sculpt, "transform_mode")
|
||||
|
||||
@ToolDef.from_fn
|
||||
|
|
|
@ -6210,7 +6210,14 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
|
|||
add_v3_v3(val, proxies[p].co[vd.i]);
|
||||
}
|
||||
|
||||
SCULPT_clip(sd, ss, vd.co, val);
|
||||
if (ss->filter_cache->cloth_sim) {
|
||||
/* When there is a simulation running in the filter cache that was created by a tool, combine
|
||||
* the proxies into the simulation instead of directly into the mesh. */
|
||||
SCULPT_clip(sd, ss, ss->filter_cache->cloth_sim->pos[vd.index], val);
|
||||
}
|
||||
else {
|
||||
SCULPT_clip(sd, ss, vd.co, val);
|
||||
}
|
||||
|
||||
if (ss->deform_modifiers_active) {
|
||||
sculpt_flush_pbvhvert_deform(ob, &vd);
|
||||
|
|
|
@ -75,16 +75,35 @@ void ED_sculpt_init_transform(struct bContext *C)
|
|||
copy_v3_v3(ss->prev_pivot_pos, ss->pivot_pos);
|
||||
copy_v4_v4(ss->prev_pivot_rot, ss->pivot_rot);
|
||||
copy_v3_v3(ss->prev_pivot_scale, ss->pivot_scale);
|
||||
|
||||
SCULPT_undo_push_begin(ob, "Transform");
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false, false);
|
||||
|
||||
ss->pivot_rot[3] = 1.0f;
|
||||
|
||||
SCULPT_undo_push_begin(ob, "Transform");
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COORDS);
|
||||
|
||||
if (sd->transform_mode == SCULPT_TRANSFORM_MODE_RADIUS_ELASTIC) {
|
||||
switch (sd->transform_deform_target) {
|
||||
case SCULPT_TRANSFORM_DEFORM_TARGET_GEOMETRY:
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false, false);
|
||||
break;
|
||||
case SCULPT_TRANSFORM_DEFORM_TARGET_CLOTH_SIM:
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
|
||||
ss->filter_cache->cloth_sim = SCULPT_cloth_brush_simulation_create(
|
||||
ss, 1.0f, 1.0f, 0.0f, true, false);
|
||||
SCULPT_cloth_brush_simulation_init(ss, ss->filter_cache->cloth_sim);
|
||||
SCULPT_cloth_brush_store_simulation_state(ss, ss->filter_cache->cloth_sim);
|
||||
SCULPT_cloth_brush_ensure_nodes_constraints(sd,
|
||||
ob,
|
||||
ss->filter_cache->nodes,
|
||||
ss->filter_cache->totnode,
|
||||
ss->filter_cache->cloth_sim,
|
||||
ss->pivot_pos,
|
||||
FLT_MAX);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (sd->transform_mode == SCULPT_TRANSFORM_MODE_RADIUS_ELASTIC ||
|
||||
sd->transform_deform_target == SCULPT_TRANSFORM_DEFORM_TARGET_CLOTH_SIM) {
|
||||
ss->filter_cache->transform_displacement_mode = SCULPT_TRANSFORM_DISPLACEMENT_INCREMENTAL;
|
||||
}
|
||||
else {
|
||||
|
@ -193,7 +212,15 @@ static void sculpt_transform_task_cb(void *__restrict userdata,
|
|||
mul_m4_v3(data->transform_mats[(int)symm_area], transformed_co);
|
||||
sub_v3_v3v3(disp, transformed_co, start_co);
|
||||
mul_v3_fl(disp, 1.0f - fade);
|
||||
add_v3_v3v3(vd.co, start_co, disp);
|
||||
|
||||
switch (data->sd->transform_deform_target) {
|
||||
case SCULPT_TRANSFORM_DEFORM_TARGET_GEOMETRY:
|
||||
add_v3_v3v3(vd.co, start_co, disp);
|
||||
break;
|
||||
case SCULPT_TRANSFORM_DEFORM_TARGET_CLOTH_SIM:
|
||||
add_v3_v3v3(ss->filter_cache->cloth_sim->pos[vd.index], start_co, disp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (vd.mvert) {
|
||||
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
|
||||
|
@ -342,6 +369,13 @@ void ED_sculpt_update_modal_transform(struct bContext *C)
|
|||
copy_v4_v4(ss->prev_pivot_rot, ss->pivot_rot);
|
||||
copy_v3_v3(ss->prev_pivot_scale, ss->pivot_scale);
|
||||
|
||||
if (sd->transform_deform_target == SCULPT_TRANSFORM_DEFORM_TARGET_CLOTH_SIM) {
|
||||
SCULPT_cloth_sim_activate_nodes(
|
||||
ss->filter_cache->cloth_sim, ss->filter_cache->nodes, ss->filter_cache->totnode);
|
||||
SCULPT_cloth_brush_do_simulation_step(
|
||||
sd, ob, ss->filter_cache->cloth_sim, ss->filter_cache->nodes, ss->filter_cache->totnode);
|
||||
}
|
||||
|
||||
if (ss->deform_modifiers_active || ss->shapekey_active) {
|
||||
SCULPT_flush_stroke_deform(sd, ob, true);
|
||||
}
|
||||
|
|
|
@ -970,6 +970,7 @@ typedef struct Sculpt {
|
|||
|
||||
/* Transform tool. */
|
||||
int transform_mode;
|
||||
int transform_deform_target;
|
||||
|
||||
int automasking_flags;
|
||||
|
||||
|
@ -991,8 +992,6 @@ typedef struct Sculpt {
|
|||
float constant_detail;
|
||||
float detail_percent;
|
||||
|
||||
char _pad[4];
|
||||
|
||||
struct Object *gravity_object;
|
||||
} Sculpt;
|
||||
|
||||
|
@ -2215,6 +2214,12 @@ typedef enum eSculptTransformMode {
|
|||
SCULPT_TRANSFORM_MODE_RADIUS_ELASTIC = 1,
|
||||
} eSculptTrasnformMode;
|
||||
|
||||
/* Sculpt.transform_deform_target */
|
||||
typedef enum eSculptTransformDeformTarget {
|
||||
SCULPT_TRANSFORM_DEFORM_TARGET_GEOMETRY = 0,
|
||||
SCULPT_TRANSFORM_DEFORM_TARGET_CLOTH_SIM = 1,
|
||||
} eSculptTransformDeformTarget;
|
||||
|
||||
/* ImagePaintSettings.mode */
|
||||
typedef enum eImagePaintMode {
|
||||
IMAGEPAINT_MODE_MATERIAL = 0, /* detect texture paint slots from the material */
|
||||
|
|
|
@ -748,6 +748,20 @@ static void rna_def_sculpt(BlenderRNA *brna)
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem sculpt_transform_deform_target_items[] = {
|
||||
{SCULPT_TRANSFORM_DEFORM_TARGET_GEOMETRY,
|
||||
"GEOMETRY",
|
||||
0,
|
||||
"Geometry",
|
||||
"Transform displaces the vertices of the mesh"},
|
||||
{SCULPT_TRANSFORM_DEFORM_TARGET_CLOTH_SIM,
|
||||
"CLOTH_SIM",
|
||||
0,
|
||||
"Cloth Simulation",
|
||||
"Transform displaces the positions of the cloth simulation"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
|
@ -891,6 +905,12 @@ static void rna_def_sculpt(BlenderRNA *brna)
|
|||
prop, "Transform Mode", "How the transformation is going to be applied to the target");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "transform_deform_target", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, sculpt_transform_deform_target_items);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Deformation Target", "Target for the displacement of the transformation");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "gravity_object", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(
|
||||
|
|
Loading…
Reference in New Issue