Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-01-07 18:46:56 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-01-07 18:57:54 +0300
commitfdf89acc8634ecba4dfe66e20ff595c0c24ffdee (patch)
tree0c0f6398468259cca6e0f08ee5fca4079e3aca53 /source/blender/editors/sculpt_paint/paint_cursor.c
parentbd766f8f0608d04c473544274b8dd9dcc00ec39a (diff)
Sculpt: Pose Brush with Inverse Kinematics
This commits introduces the pose_ik_segments brush property in the Pose Brush. When increasing the IK segments count, the brush generates more segments and weights associations following the topology of the mesh. When moving the brush, these segments are transformed using an IK solver and they are used to deform the mesh. When pressing Ctrl, the brush controls the segments' roll rotation instead of using the IK solver. The brush falloff controls how much rotation is propagated from the first to the last segment in the chain. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D6389
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_cursor.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 9021666c001..9bc587de6da 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1461,15 +1461,30 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
cursor_draw_point_with_symmetry(pos, ar, gi.active_vertex_co, sd, vc.obact, rds);
}
- /* Draw pose brush origin */
+ /* Draw pose brush origins. */
if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
if (update_previews) {
BKE_sculpt_update_object_for_edit(depsgraph, vc.obact, true, false);
- sculpt_pose_calc_pose_data(
- sd, vc.obact, ss, gi.location, rds, brush->pose_offset, ss->pose_origin, NULL);
+
+ /* Free the previous pose brush preview. */
+ if (ss->pose_ik_chain_preview) {
+ sculpt_pose_ik_chain_free(ss->pose_ik_chain_preview);
+ }
+
+ /* Generate a new pose brush preview from the current cursor location. */
+ ss->pose_ik_chain_preview = sculpt_pose_ik_chain_init(
+ sd, vc.obact, ss, brush, gi.location, rds);
+ }
+
+ /* Draw the pose brush rotation origins. */
+ for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
+ cursor_draw_point_screen_space(pos,
+ ar,
+ ss->pose_ik_chain_preview->segments[i].initial_orig,
+ vc.obact->obmat,
+ 3);
}
- cursor_draw_point_screen_space(pos, ar, ss->pose_origin, vc.obact->obmat, 5);
}
/* Draw 3D brush cursor */
@@ -1518,9 +1533,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
GPU_line_width(2.0f);
- immBegin(GPU_PRIM_LINES, 2);
- immVertex3fv(pos, ss->pose_origin);
- immVertex3fv(pos, gi.location);
+
+ immBegin(GPU_PRIM_LINES, ss->pose_ik_chain_preview->tot_segments * 2);
+ for (int i = 0; i < ss->pose_ik_chain_preview->tot_segments; i++) {
+ immVertex3fv(pos, ss->pose_ik_chain_preview->segments[i].initial_orig);
+ immVertex3fv(pos, ss->pose_ik_chain_preview->segments[i].initial_head);
+ }
+
immEnd();
}