From 438bd823714a24475962ab89ad38b0d7e36349fe Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Tue, 23 Jun 2020 16:10:47 +0200 Subject: Sculpt: Pose Brush option to affect loose parts This option allows posing meshes with different disconnected elements using the Pose Brush. This is achieved by doing the following: - Creating an ID per vertex that stores the connected component of that vertex. - By using those IDs, one fake topology connection is created per vertex to the nearest vertex in a different ID. The maximum distance to create that connection is determined by the "Max Element Distance" property. These fake connectivity neighbors are used in the Sculpt API functions iterators, so all the algorithms of the Pose Brush can run without modifications as if everything was part of the same mesh. In order to make this work, the "Connected only" property of the Pose Brush needs to be disabled. This will add an extra performance cost to the Pose Brush and its preview. To achieve optimal results, max element distance should be as low as possible. Reviewed By: sergey, campbellbarton Differential Revision: https://developer.blender.org/D7282 --- source/blender/makesdna/DNA_brush_defaults.h | 1 + source/blender/makesdna/DNA_brush_types.h | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/makesdna') diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h index f315cc4b8a0..2ec4f4ee991 100644 --- a/source/blender/makesdna/DNA_brush_defaults.h +++ b/source/blender/makesdna/DNA_brush_defaults.h @@ -47,6 +47,7 @@ .crease_pinch_factor = 0.5f, \ .normal_radius_factor = 0.5f, \ .area_radius_factor = 0.5f, \ + .disconnected_distance_max = 0.1f, \ .sculpt_plane = SCULPT_DISP_DIR_AREA, \ .cloth_damping = 0.01, \ .cloth_mass = 1, \ diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index a1c69af4750..4056faf359f 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -474,7 +474,7 @@ typedef struct Brush { /** Source for fill tool color gradient application. */ char gradient_fill_mode; - char _pad0[5]; + char _pad0[1]; /** Projection shape (sphere, circle). */ char falloff_shape; @@ -519,6 +519,9 @@ typedef struct Brush { int curve_preset; + /* Maximun distance to search fake neighbors from a vertex. */ + float disconnected_distance_max; + /* automasking */ int automasking_flags; int automasking_boundary_edges_propagation_steps; @@ -680,6 +683,7 @@ typedef enum eBrushFlags2 { BRUSH_MULTIPLANE_SCRAPE_DYNAMIC = (1 << 0), BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW = (1 << 1), BRUSH_POSE_IK_ANCHORED = (1 << 2), + BRUSH_USE_CONNECTED_ONLY = (1 << 3), } eBrushFlags2; typedef enum { -- cgit v1.2.3