diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-08-10 18:57:01 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-08-10 19:04:00 +0300 |
commit | ed9c0464bae66411384c216ba3f34f65658e0f68 (patch) | |
tree | b0a5004801180bbf67ae220f92932d007397671f /source/blender/editors/sculpt_paint/paint_cursor.c | |
parent | 71639cc8627fb26e50233b9bb942776a950b6ab1 (diff) |
Sculpt: Boundary Brush
This brush includes a set of deformation modes designed to deform and
control the shape of the mesh boundaries, which are really hard to do
with regular sculpt brushes (and even in edit mode). This is useful
for creating cloth assets and hard surface base meshes.
The brush detects the mesh boundary closest to the active vertex and
propagates the deformation using the brush falloff into the mesh.
It includes bend, expand, inflate, grab and twist deform modes.
The main use cases of this brush are the Bend and Expand deformation
modes, which depend on a grid topology to create the best results.
In order to do further adjustments and tweaks to the result of these
deformation modes, the brush also includes the Inflate, Grab and
Twist deformation modes, which do not depend that much on the topology.
Grab and Inflate are the same operation that is implemented in the
Grab and Inflate tools, they are also available in the boundary brush
as producing deformations with regular brushes in these areas is very
hard to control.
Even if this brush can produce deformations in triangle meshes and
meshes with a non-regular quad grid, the more regular and clean the
topology is, the better. Most of the assets this brush is intended to
deform are always created from a cylindrical or plane quad grid, so it
should be fine. Also, its algorithms can be improved in future versions
to handle more corner cases and topology patterns.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D8356
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_cursor.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index b8af33fb7cc..a4101bdd89f 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1508,6 +1508,43 @@ static void paint_cursor_pose_brush_origins_draw(PaintCursorContext *pcontext) } } +static void paint_cursor_preview_boundary_data_pivot_draw(PaintCursorContext *pcontext) +{ + + if (!pcontext->ss->boundary_preview) { + /* There is no guarantee that a boundary preview exists as there may be no boundaries + * inside the brush radius. */ + return; + } + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f); + cursor_draw_point_screen_space( + pcontext->pos, + pcontext->region, + SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->boundary_preview->pivot_vertex), + pcontext->vc.obact->obmat, + 3); +} + +static void paint_cursor_preview_boundary_data_update(PaintCursorContext *pcontext, + const bool update_previews) +{ + SculptSession *ss = pcontext->ss; + if (!(update_previews || !ss->boundary_preview)) { + return; + } + + /* Needed for updating the necessary SculptSession data in order to initialize the + * boundary data for the preview. */ + BKE_sculpt_update_object_for_edit(pcontext->depsgraph, pcontext->vc.obact, true, false, false); + + if (ss->boundary_preview) { + SCULPT_boundary_data_free(ss->boundary_preview); + } + + ss->boundary_preview = SCULPT_boundary_data_init( + pcontext->vc.obact, ss->active_vertex_index, pcontext->radius); +} + static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *pcontext) { Brush *brush = pcontext->brush; @@ -1577,6 +1614,11 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * paint_cursor_pose_brush_origins_draw(pcontext); } + if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { + paint_cursor_preview_boundary_data_update(pcontext, update_previews); + paint_cursor_preview_boundary_data_pivot_draw(pcontext); + } + /* Setup 3D perspective drawing. */ GPU_matrix_push_projection(); ED_view3d_draw_setup_view(pcontext->wm, @@ -1603,6 +1645,12 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * paint_cursor_pose_brush_segments_draw(pcontext); } + if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { + SCULPT_boundary_edges_preview_draw( + pcontext->pos, pcontext->ss, pcontext->outline_col, pcontext->outline_alpha); + SCULPT_boundary_pivot_line_preview_draw(pcontext->pos, pcontext->ss); + } + GPU_matrix_pop(); /* Drawing Cursor overlays in Paint Cursor space (as additional info on top of the brush cursor) |