diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_paint_common.py | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 10 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 24 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_cloth.c | 11 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_brush_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 18 |
6 files changed, 62 insertions, 18 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index ee62a1115e3..01f9eedd96e 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -656,9 +656,12 @@ def brush_settings(layout, context, brush, popover=False): elif sculpt_tool == 'CLOTH': layout.separator() - layout.prop(brush, "cloth_sim_limit") - layout.prop(brush, "cloth_sim_falloff") - layout.prop(brush, "use_cloth_pin_simulation_boundary") + layout.prop(brush, "cloth_simulation_area_type") + if brush.cloth_simulation_area_type == 'LOCAL': + layout.prop(brush, "cloth_sim_limit") + layout.prop(brush, "cloth_sim_falloff") + layout.prop(brush, "use_cloth_pin_simulation_boundary") + layout.separator() layout.prop(brush, "cloth_deform_type") layout.prop(brush, "cloth_force_falloff_type") diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index e3027ead1f1..c5f1063d494 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1612,8 +1612,9 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * /* Main inactive cursor. */ paint_cursor_draw_main_inactive_cursor(pcontext); - /* Cloth brush simulation areas. */ - if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) { + /* Cloth brush local simulation areas. */ + if (brush->sculpt_tool == SCULPT_TOOL_CLOTH && + brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) { const float white[3] = {1.0f, 1.0f, 1.0f}; const float zero_v[3] = {0.0f}; /* This functions sets its own drawing space in order to draw the simulation limits when the @@ -1691,9 +1692,10 @@ static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorCont SCULPT_cloth_plane_falloff_preview_draw( pcontext->pos, ss, pcontext->outline_col, pcontext->outline_alpha); } - else if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_RADIAL) { + else if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_RADIAL && + brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) { /* Display the simulation limits if sculpting outside them. */ - /* This does not makes much sense of plane fallof as the fallof is infinte. */ + /* This does not makes much sense of plane fallof as the fallof is infinte or global. */ if (len_v3v3(ss->cache->true_location, ss->cache->true_initial_location) > ss->cache->radius * (1.0f + brush->cloth_sim_limit)) { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 48c13d69136..89fc0ac1a58 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5513,15 +5513,21 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); } else if (brush->sculpt_tool == SCULPT_TOOL_CLOTH) { - SculptSearchSphereData data = { - .ss = ss, - .sd = sd, - .radius_squared = square_f(ss->cache->initial_radius * (1.0 + brush->cloth_sim_limit)), - .original = false, - .ignore_fully_ineffective = false, - .center = ss->cache->initial_location, - }; - BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, &totnode); + if (brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) { + SculptSearchSphereData data = { + .ss = ss, + .sd = sd, + .radius_squared = square_f(ss->cache->initial_radius * (1.0 + brush->cloth_sim_limit)), + .original = false, + .ignore_fully_ineffective = false, + .center = ss->cache->initial_location, + }; + BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, &totnode); + } + else { + /* Gobal simulation, get all nodes. */ + BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); + } } else { const bool use_original = sculpt_tool_needs_original(brush->sculpt_tool) ? true : diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index dac8ef99fc0..c0862795594 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -108,6 +108,11 @@ static float cloth_brush_simulation_falloff_get(const Brush *brush, const float location[3], const float co[3]) { + /* Global simulation does not have any falloff as the entire mesh is being simulated. */ + if (brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) { + return 1.0f; + } + const float distance = len_v3v3(location, co); const float limit = radius + (radius * brush->cloth_sim_limit); const float falloff = radius + (radius * brush->cloth_sim_limit * brush->cloth_sim_falloff); @@ -249,7 +254,11 @@ static void do_cloth_brush_build_constraints_task_cb_ex( radius_squared = ss->cache->initial_radius * ss->cache->initial_radius; } - const float cloth_sim_radius_squared = data->cloth_sim_radius * data->cloth_sim_radius; + /* Only limit the contraint creation to a radius when the simulation is local. */ + const float cloth_sim_radius_squared = brush->cloth_simulation_area_type == + BRUSH_CLOTH_SIMULATION_AREA_LOCAL ? + data->cloth_sim_radius * data->cloth_sim_radius : + FLT_MAX; BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 7b3e9dabe9f..9d9c2354220 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -351,6 +351,11 @@ typedef enum eBrushClothForceFalloffType { BRUSH_CLOTH_FORCE_FALLOFF_PLANE = 1, } eBrushClothForceFalloffType; +typedef enum eBrushClothSimulationAreaType { + BRUSH_CLOTH_SIMULATION_AREA_LOCAL = 0, + BRUSH_CLOTH_SIMULATION_AREA_GLOBAL = 1, +} eBrushClothSimulationAreaType; + typedef enum eBrushPoseDeformType { BRUSH_POSE_DEFORM_ROTATE_TWIST = 0, BRUSH_POSE_DEFORM_SCALE_TRASLATE = 1, @@ -546,7 +551,7 @@ typedef struct Brush { char gpencil_sculpt_tool; /** Active grease pencil weight tool. */ char gpencil_weight_tool; - char _pad1[6]; + char _pad1[2]; float autosmooth_factor; @@ -585,6 +590,7 @@ typedef struct Brush { /* cloth */ int cloth_deform_type; int cloth_force_falloff_type; + int cloth_simulation_area_type; float cloth_mass; float cloth_damping; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index d20cec518bc..11b563dae52 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1983,6 +1983,16 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem brush_cloth_simulation_area_type_items[] = { + {BRUSH_CLOTH_SIMULATION_AREA_LOCAL, + "LOCAL", + 0, + "Local", + "Simulates only a specific area arround the brush limited by a fixed radius"}, + {BRUSH_CLOTH_SIMULATION_AREA_GLOBAL, "GLOBAL", 0, "Global", "Simulates the entire mesh"}, + {0, NULL, 0, NULL, NULL}, + }; + static const EnumPropertyItem brush_smooth_deform_type_items[] = { {BRUSH_SMOOTH_DEFORM_LAPLACIAN, "LAPLACIAN", @@ -2153,6 +2163,14 @@ static void rna_def_brush(BlenderRNA *brna) prop, "Force Falloff", "Shape used in the brush to apply force to the cloth"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "cloth_simulation_area_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, brush_cloth_simulation_area_type_items); + RNA_def_property_ui_text( + prop, + "Simulation Area", + "Part of the mesh that is going to be simulated when the stroke is active"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "smooth_deform_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_smooth_deform_type_items); RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush"); |