[Bf-blender-cvs] [b647f8653d6] greasepencil-object: Implement lock axis in Sculpt grab brush
Antonio Vazquez
noreply at git.blender.org
Fri Jun 9 20:26:54 CEST 2017
Commit: b647f8653d6018aab8358d196c15cda8225210e9
Author: Antonio Vazquez
Date: Fri Jun 9 13:13:38 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb647f8653d6018aab8358d196c15cda8225210e9
Implement lock axis in Sculpt grab brush
This is the first implementation to lock the axis while sculpt. In some extreme angles the result is not perfect, so maybe need a review.
We keep in this way while we found a better approach, maybe using the reprojection of the point as it is done when draw new strokes could work better.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/editors/gpencil/gpencil_brush.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index e793da19f78..867592d12cb 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -143,6 +143,12 @@ class VIEW3D_HT_header(Header):
if toolsettings.gpencil_stroke_placement_view3d in ('SURFACE', 'STROKE'):
row.prop(toolsettings, "use_gpencil_stroke_endpoints")
+ if ob.grease_pencil.is_stroke_sculpt_mode:
+ settings = context.tool_settings.gpencil_sculpt
+ if settings.tool == 'GRAB':
+ row.separator()
+ row.prop(toolsettings.gpencil_sculpt, "lockaxis", text='')
+
if context.gpencil_data:
if context.gpencil_data.use_stroke_edit_mode:
row = layout.row(align=True)
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 5cbaf05263a..14a078b953b 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -148,6 +148,30 @@ typedef bool (*GP_BrushApplyCb)(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
/* ************************************************ */
/* Utility Functions */
+/* compute vector for locking one axis */
+static void gp_brush_compute_lock_axis(tGP_BrushEditData *gso, float diff_mat[4][4], float vec[3])
+{
+ ToolSettings *ts = gso->scene->toolsettings;
+ int axis = ts->gp_sculpt.lock_axis;
+ if (axis == GP_LOCKAXIS_NONE) {
+ return;
+ }
+
+ /* calculate a unit vector in the local locked axis direction */
+ float unit_vector[3];
+ float sub_vector[3];
+ zero_v3(unit_vector);
+ unit_vector[axis - 1] = 1.0f;
+ mul_mat3_m4_v3(diff_mat, unit_vector); /* only rotation component */
+
+ /* mult displacement vector by unit vector to get what we need to substract
+ * This need more work because in some extreme angles the result is not perfect */
+ sub_vector[0] = vec[0] * unit_vector[0];
+ sub_vector[1] = vec[1] * unit_vector[1];
+ sub_vector[2] = vec[2] * unit_vector[2];
+
+ sub_v3_v3(vec, sub_vector);
+}
/* Context ---------------------------------------- */
@@ -444,6 +468,7 @@ static void gp_brush_grab_apply_cached(
/* apply transformation */
mul_v3_m4v3(fpt, diff_mat, &pt->x);
/* apply */
+ gp_brush_compute_lock_axis(gso, diff_mat, delta);
add_v3_v3(fpt, delta);
copy_v3_v3(&pt->x, fpt);
/* undo transformation to the init parent position */
More information about the Bf-blender-cvs
mailing list