[Bf-blender-cvs] [3632e925c23] greasepencil-object: GPencil: Use the cursor lock in Sculpt mode
Antonioya
noreply at git.blender.org
Fri Mar 15 19:36:43 CET 2019
Commit: 3632e925c233c7a27d5dd6fd6282ddfdc87d156d
Author: Antonioya
Date: Fri Mar 15 19:36:34 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB3632e925c233c7a27d5dd6fd6282ddfdc87d156d
GPencil: Use the cursor lock in Sculpt mode
The point is locked to a plane with the last point and the normal of the cursor orientation.
The moved point is projected over the cursor/point plane and the closet point is used as result of the sculpt operation.
===================================================================
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/editors/gpencil/gpencil_brush.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index c119e917253..d67cca415fc 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -663,7 +663,9 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
}
/* now move the origin to Object or Cursor */
- if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+ if ((ob->mode == OB_MODE_PAINT_GPENCIL) &&
+ (ts->gpencil_v3d_align & GP_PROJECT_CURSOR))
+ {
copy_v3_v3(stl->storage->grid_matrix[3], cursor->location);
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 0403a42a2c9..af7fc804d80 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -176,18 +176,54 @@ static void gpsculpt_compute_lock_axis(tGP_BrushEditData *gso, bGPDspoint *pt, c
return;
}
- ToolSettings *ts = gso->scene->toolsettings;
- int axis = ts->gp_sculpt.lock_axis;
+ const ToolSettings *ts = gso->scene->toolsettings;
+ const View3DCursor *cursor = &gso->scene->cursor;
+ const int axis = ts->gp_sculpt.lock_axis;
/* lock axis control */
- if (axis == 1) {
- pt->x = save_pt[0];
- }
- if (axis == 2) {
- pt->y = save_pt[1];
- }
- if (axis == 3) {
- pt->z = save_pt[2];
+ switch (axis) {
+ case GP_LOCKAXIS_X:
+ {
+ pt->x = save_pt[0];
+ break;
+ }
+ case GP_LOCKAXIS_Y:
+ {
+ pt->y = save_pt[1];
+ break;
+ }
+ case GP_LOCKAXIS_Z:
+ {
+ pt->z = save_pt[2];
+ break;
+ }
+ case GP_LOCKAXIS_CURSOR:
+ {
+ /* compute a plane with cursor normal and position of the point
+ before do the sculpt */
+ const float scale[3] = { 1.0f, 1.0f, 1.0f };
+ const float plane_normal[3] = { 0.0f, 0.0f, 1.0f };
+ float plane[4];
+ float mat[4][4];
+ float r_close[3];
+
+ loc_eul_size_to_mat4(mat,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+
+ mul_mat3_m4_v3(mat, plane_normal);
+ plane_from_point_normal_v3(plane, save_pt, plane_normal);
+
+ /* find closest point to the plane with the new position */
+ closest_to_plane_v3(r_close, plane, &pt->x);
+ copy_v3_v3(&pt->x, r_close);
+ break;
+ }
+ default:
+ {
+ break;
+ }
}
}
More information about the Bf-blender-cvs
mailing list