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:
authorAntonioya <blendergit@gmail.com>2019-03-17 21:47:31 +0300
committerAntonioya <blendergit@gmail.com>2019-03-17 21:47:56 +0300
commit6577618d5bb93792c805e0c22e4de1a015ee25d5 (patch)
tree05d5056646b3aefd8be21bb1ff314e4373865683 /source/blender/editors/gpencil/gpencil_utils.c
parent887d052e56a515145f4dd7433e49c91c5d149169 (diff)
GPencil: Changes in Fill and new 3D Cursor View Plane
This commit groups several options that were tested in grease pencil branch: - Changes to fill algorithms and improves, specially in small areas and stroke corners. New options has been added in order to define how the fill is working and internally there are optimizations in detect the small areas in the extremes. Kudos to @charlie for coding this fill improvements. - New 3D cursor view plane option. Now it's possible to lock the drawing plane to the 3D cursor and use the 3D cursor orientation. This allows more flexibility when you are drawing and reduce the need to create geometry to draw over surfaces. - Canvas Grid now can be locked to 3D cursor. - New option to reproject stroke using 3D cursor. - Small tweaks and fixes. Changes reviewed by @pepeland and @mendio
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 84bfd709b10..1605353a156 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -937,8 +937,12 @@ void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *
* Reproject all points of the stroke to a plane locked to axis to avoid stroke offset
*/
void ED_gp_project_stroke_to_plane(
- const Object *ob, const RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis)
+ const Scene *scene, const Object *ob,
+ const RegionView3D *rv3d, bGPDstroke *gps,
+ const float origin[3], const int axis)
{
+ const ToolSettings *ts = scene->toolsettings;
+ const View3DCursor *cursor = &scene->cursor;
float plane_normal[3];
float vn[3];
@@ -953,13 +957,37 @@ void ED_gp_project_stroke_to_plane(
*/
ED_view3d_global_to_vector(rv3d, origin, plane_normal);
}
- else {
+ else if (axis < 3) {
plane_normal[axis] = 1.0f;
/* if object, apply object rotation */
if (ob && (ob->type == OB_GPENCIL)) {
- mul_mat3_m4_v3(ob->obmat, plane_normal);
+ float mat[4][4];
+ copy_m4_m4(mat, ob->obmat);
+
+ /* move origin to cursor */
+ if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+ copy_v3_v3(mat[3], cursor->location);
+ }
+
+ mul_mat3_m4_v3(mat, plane_normal);
}
}
+ else {
+ float scale[3] = { 1.0f, 1.0f, 1.0f };
+ plane_normal[2] = 1.0f;
+ float mat[4][4];
+ loc_eul_size_to_mat4(mat,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+
+ /* move origin to object */
+ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) {
+ copy_v3_v3(mat[3], ob->obmat[3]);
+ }
+
+ mul_mat3_m4_v3(mat, plane_normal);
+ }
/* Reproject the points in the plane */
for (int i = 0; i < gps->totpoints; i++) {
@@ -984,8 +1012,12 @@ void ED_gp_project_stroke_to_plane(
* \param[in, out] pt : Point to affect
*/
void ED_gp_project_point_to_plane(
- const Object *ob, const RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
+ const Scene *scene, const Object *ob,
+ const RegionView3D *rv3d, const float origin[3],
+ const int axis, bGPDspoint *pt)
{
+ const ToolSettings *ts = scene->toolsettings;
+ const View3DCursor *cursor = &scene->cursor;
float plane_normal[3];
float vn[3];
@@ -1000,14 +1032,37 @@ void ED_gp_project_point_to_plane(
*/
ED_view3d_global_to_vector(rv3d, origin, plane_normal);
}
- else {
+ else if (axis < 3) {
plane_normal[axis] = 1.0f;
/* if object, apply object rotation */
if (ob && (ob->type == OB_GPENCIL)) {
- mul_mat3_m4_v3(ob->obmat, plane_normal);
+ float mat[4][4];
+ copy_m4_m4(mat, ob->obmat);
+
+ /* move origin to cursor */
+ if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) {
+ copy_v3_v3(mat[3], cursor->location);
+ }
+
+ mul_mat3_m4_v3(mat, plane_normal);
}
}
+ else {
+ float scale[3] = { 1.0f, 1.0f, 1.0f };
+ plane_normal[2] = 1.0f;
+ float mat[4][4];
+ loc_eul_size_to_mat4(mat,
+ cursor->location,
+ cursor->rotation_euler,
+ scale);
+
+ /* move origin to object */
+ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) {
+ copy_v3_v3(mat[3], ob->obmat[3]);
+ }
+ mul_mat3_m4_v3(mat, plane_normal);
+ }
/* Reproject the points in the plane */
/* get a vector from the point with the current view direction of the viewport */